Skip to content

Commit

Permalink
add prometheus config / change plutus exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
sadMaxim committed Nov 13, 2023
1 parent 0224842 commit b002aea
Show file tree
Hide file tree
Showing 16 changed files with 1,167 additions and 198 deletions.
16 changes: 8 additions & 8 deletions cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pkgs.writeScriptBin "runnet" ''
export ROOT=$(git rev-parse --show-toplevel)
export CARDANO_TAG=${cardano-tag}
${./runnet.sh}
while true; do
if ${./ada-transfer-from-genesis-to-wallet0.sh} | grep -q "Transaction successfully submitted"; then
break
else
echo "Transaction not successful yet. Retrying..."
sleep 1
fi
done
# while true; do
# if ${./ada-transfer-from-genesis-to-wallet0.sh} | grep -q "Transaction successfully submitted"; then
# break
# else
# echo "Transaction not successful yet. Retrying..."
# sleep 1
# fi
# done
''
42 changes: 32 additions & 10 deletions cluster/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ services:
- 3000
- 6000
- 12789
- 12788
- 12798
ports:
- 3000
- 12789
- "3000:3000"
- "12789:12789"
- "12788:12788"
- "12798:12798"
volumes:
- node-relay-1-db:/data/db
- ../cardano-conf/sockets/node-relay-1-socket:/socket
Expand Down Expand Up @@ -159,24 +163,41 @@ services:
volumes:
- ../cardano-conf:/config
entrypoint: "/bin/kupo \
--node-socket /config/node-spo1/node.socket \
--node-socket /config/sockets/node-relay-1-socket/node.socket \
--node-config /config/configuration.yaml \
--host 0.0.0.0 \
--since origin \
--match '*/*' \
--workdir /data"

# prometheus:
# image: prom/prometheus:v2.43.1
prometheus:
image: prom/prometheus:v2.43.1
networks:
mynet:
aliases:
- prometheus.local
ports:
- 9090:9090
volumes:
- ../cardano-conf/:/etc/prometheus
- prom-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
restart: unless-stopped

# node_exporter:
# image: quay.io/prometheus/node-exporter:latest
# container_name: node_exporter
# command:
# - '--path.rootfs=/host'
# networks:
# mynet:
# aliases:
# - prometheus.local
# ports:
# - 9090:9090
# - node_exporter.local
# pid: host
# restart: unless-stopped
# volumes:
# - ../cardano-conf:/config

# - '/:/host:ro,rslave'

networks:
mynet:
Expand All @@ -185,4 +206,5 @@ volumes:
node-spo-1-db:
node-spo-2-db:
node-relay-1-db:
prom-data:

4 changes: 2 additions & 2 deletions cluster/runnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ sudo systemctl start docker
echo "shutdown old testnet"
sudo docker compose --file cluster/docker-compose.yaml down -v
echo "generate foler with configuration and sockets"
sudo rm -rf cardano-conf
# sudo rm -rf cardano-conf
echo "add configs to start network"
nix run .#config
# nix run .#config
echo "start docker-compose environment"
sudo CARDANO_TAG=$CARDANO_TAG docker compose --file cluster/docker-compose.yaml up -d --remove-orphans --force-recreate --build

Expand Down
53 changes: 6 additions & 47 deletions config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
echo "TestEnableDevelopmentNetworkProtocols: True" >> "$ROOT/configuration.yaml"
echo "EnableP2P: True" >> "$ROOT/configuration.yaml"
echo "hasPrometheus:" >> "$ROOT/configuration.yaml"
# echo ' - "127.0.0.1"' >> "$ROOT/configuration.yaml"
# echo ' - 9090' >> "$ROOT/configuration.yaml"
echo ' - "127.0.0.1"' >> "$ROOT/configuration.yaml"
echo ' - 12789' >> "$ROOT/configuration.yaml"
# Copy the cost mode
Expand Down Expand Up @@ -162,53 +162,12 @@
cp "$ROOT/byron-gen-command/delegation-cert.000.json" "$ROOT/node-spo1/byron-delegation.cert"
cp "$ROOT/byron-gen-command/delegation-cert.001.json" "$ROOT/node-spo2/byron-delegation.cert"
#Prometheus
'';
};
config-old = pkgs.writeScriptBin "config-old" ''
#!/bin/sh
cd $(git rev-parse --show-toplevel)
ROOT=cardano-conf
sudo rm -rf $ROOT
mkdir $ROOT
GENESIS_DIR=$ROOT/genesis
NUM_GENESIS_KEYS=2
TESTNET_MAGIC=2
SECURITY_PARAM=432
TEMPLATE_DIR=${cardano-world}/docs/environments/private
${pkgs.jq}/bin/jq '.blockVersionData' $TEMPLATE_DIR/byron-genesis.json > $ROOT/byron.json
${cardano}/bin/cardano-cli genesis create-cardano \
--genesis-dir "$GENESIS_DIR" \
--gen-genesis-keys "$NUM_GENESIS_KEYS" \
--gen-utxo-keys 2 \
--supply 11234567890123456 \
--testnet-magic "$TESTNET_MAGIC" \
--byron-template "$ROOT/byron.json" \
--shelley-template "$TEMPLATE_DIR/shelley-genesis.json" \
--alonzo-template "$TEMPLATE_DIR/alonzo-genesis.json" \
--node-config-template "$TEMPLATE_DIR/config.json"
cp "${./prometheus.yml}" "$ROOT/prometheus.yml"
#### copy alonzo and conway from repo , and fix issues in node config
cp $TEMPLATE_DIR/alonzo-genesis.json $GENESIS_DIR/
cp $TEMPLATE_DIR/conway-genesis.json $GENESIS_DIR/
ALONZO_HASH=$(echo $(${pkgs.jq}/bin/jq '.AlonzoGenesisHash' $TEMPLATE_DIR/config.json) | tr -d '"')
${pkgs.jq}/bin/jq --arg HASH $ALONZO_HASH '.AlonzoGenesisHash = $HASH | .RequiresNetworkMagic = "RequiresMagic" | .TestEnableDevelopmentNetworkProtocols = true | .TestBabbageHardForkAtEpoch = 0 | .TraceBlockFetchClient = true | .TraceBlockFetchDecisions = true | .TraceBlockFetchProtocol = true | .TraceBlockFetchProtocolSerialised = true | .TraceBlockFetchServer = true | .TraceChainSyncBlockServer = true | .TraceChainSyncClient = true | .TraceChainSyncHeaderServer = true | .TraceChainSyncProtocol = true | .TraceHandshake = true | .TraceLocalChainSyncProtocol = true | .TraceLocalHandshake = true | .TraceLocalTxSubmissionProtocol = true | .TraceLocalTxSubmissionServer = true | .TraceMux = true | .TraceTxInbound = true | .TraceTxOutbound = true | .TraceTxSubmissionProtocol = true | .ExperimentalProtocolsEnabled = true' \
$GENESIS_DIR/node-config.json > temp.json && cp temp.json $GENESIS_DIR/node-config.json
cat $GENESIS_DIR/node-config.json | jq
cp "${./topology-spo-1.json}" $ROOT/topology-spo-1.json
cp "${./topology-relay-1.json}" $ROOT/topology-relay-1.json
cp "${./topology-spo-2.json}" $ROOT/topology-spo-2.json
cp "${./topology-relay-2.json}" $ROOT/topology-relay-2.json
cp "${./topology-passive-3.json}" $ROOT/topology-passive-3.json
'';
'';
};
}
33 changes: 33 additions & 0 deletions config/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'CARDANO-NODE' # To scrape data from the Cardano node
scrape_interval: 5s
static_configs:
- targets: ['127.0.0.1:12789']
# - targets: ['y.y.y.y:12798']
# - targets: ['z.z.z.z:12798']
# - job_name: 'EXPORTER' # To scrape data from a node exporter to monitor your Linux host metrics.
# scrape_interval: 5s
# static_configs:
# - targets: ['x.x.x.x:9100']
# - targets: ['y.y.y.y:9100']
# - targets: ['z.z.z.z:9100']
10 changes: 7 additions & 3 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
- The testnet will offer a mechanism to submit custom transactions.

## Architechture
![Design](./imgs/design.svg)
<p align="center">
<img src="./imgs/design.svg"/>
</p>

##### In our Cardano testnet, some nodes will be integrated with the following APIs:
- Faucet API. This api will be connected with few testnet nodes annd will be used to send 100 tADA to a specified address.
```bash
Expand All @@ -16,12 +19,13 @@
-d '{"address": $USER_ADDRESS}'
```
- [BlockFrost API](https://github.com/blockfrost/blockfrost-backend-ryo). This api will allows users to submit transactions to the testnet
- Mempool Monitoring. This API requests information from each node in the testnet to estimate the current mempool usage percentage for each node, as well as the average across the testnet. It will be collected into [PrometheusDB](https://prometheus.io/)
- Spammer.
- Spammer continually submits random transactions in round robin manner to each node on the testnet in order to simulate constant congestion.
- Spammer continually submits random transactions in round robin manner to each node on the testnet in order to simulate congestion as in [historical peak](./congestion-statistics.md)
- The size of the transaction and its CPU/memory usage will be regulated by alwaysTrue validators performing varying computational tasks.
- Transaction parameters such as transaction size, cpu/mem usage will be sampled from [congestion distribution](./congestion-statistics.md)
- It will be built on top of [Cardano transaction library(CTL)](https://github.com/Plutonomicon/cardano-transaction-lib) which connects with testnet nodes via [ogmios](https://github.com/CardanoSolutions/ogmios) and [kupo](https://github.com/CardanoSolutions/kupo).
- All necessary data for spam transactions, such as random addresses, scripts, and policies, along with parameters from the [congestion distribution](./congestion-statistics.md), will be stored in database (`SpammerDB`).

- Mempool Monitoring. This API requests information from each node in the testnet to estimate the current mempool usage percentage for each node, as well as the average across the testnet.


Binary file modified docs/imgs/design.dia
Binary file not shown.

0 comments on commit b002aea

Please sign in to comment.