Once you have selected a plan we can now copy our API Key
📝 Copy this to a save place as we will need it later.
Copy Pool ID
If you don't know your pool id off the top of your head copy it from Cexploer.io while you are on their site.
📝 Copy this to a save place as we will need it later.
Step 3 - Create poolStat Directory
Create poolStat directory by running the following commands:
Step 4 -Create script getstat.sh
Now we will create a script in the poolStat directory to pull pool stat json file and trim non-numeric strings.
Prometheus can work only with numeric data, so we must trim non-numeric strings which is returned from the JSON file provided by Cexplorer.
Replace "YOUR_SECRET_TOKEN" with the Key that you copied from Step 2
Also replace "YOUR_POOL_ID" with your pool id from Step 2
Replace ${NODE_HOME} with full path
Step 5 - Add Permissions and Run the getstat Script
Add permissions and run getstat script by running these commands:
Step 6 - Check Output File
Check output file to make sure it contains only numeric values by running:
Your results should look similar to this example:
Step 7 - Configure Prometheus to Grab Data from poolStat.prom File
Configure prometheus-node-exporter.service to grab data from poolStat.prom file.
First let's backup the prometheus-node-exporter.service file by running the following:
Then let's edit file by running the following command:
Now we need to change ExecStart line to:
Replace "< YOUR NODE FULL PATH >"
Hint: to find your full path run:
cd $NODE_HOME
readlink -f poolStat
Step 8 - Change Default User for prometheus-node-exporter.service
hange the default user to your Linux user name in prometheus-node-exporter.service. Replace below.
Or Alternatively: The default user of prometheus-node-exporter is “prometheus”. So, you could give the user “prometheus” read and write rights for poolStat.prom
Step 9 - Reload Daemon and Restart Services
Reload daemon and restart services by running:
Verify that the services are running properly:
Step 10 - Setup Cron Job to Update Data
The data will constantly change so we need to setup a cron job to grab the new data every so often. In this example we will grab new data every 6 hours.
First run:
Add the following to your cronjobs.
Replace "<YOUR NODE FULL PATH>"
Hint: to find your full path run:
find ~+ -type f -name getstats.sh
Last Block Slot Number = cexplorer_last_block_slot_number
Last Block Epoch Number = cexplorer_last_block_epoch_number
Congratulations you did it!
Contributors
Thanks to the following pools for helping to put together these guides. Please consider delegating to their pools to support them. Are you a pool? Consider buying them a coffee
#!/bin/bash
set -euo pipefail
API_KEY="YOUR_SECRET_TOKEN"
POOL_ID="YOUR_POOL_ID"
API_URL="https://api-mainnet-stage.cexplorer.io/v1/pool/detail?pool_id=${POOL_ID}"
OUTPUT_FILE="${NODE_HOME}/poolStat/poolStat.prom"
# Fetch JSON
response=$(curl -s -H "api-key: ${API_KEY}" "$API_URL")
# Extract values
live_stake=$(echo "$response" | jq -r '.data.live_stake')
active_stake=$(echo "$response" | jq -r '.data.active_stake')
delegators=$(echo "$response" | jq -r '.data.delegators')
pledged=$(echo "$response" | jq -r '.data.pledged')
saturation=$(echo "$response" | jq -r '.data.saturation')
blocks_epoch=$(echo "$response" | jq -r '.data.blocks.epoch')
blocks_total=$(echo "$response" | jq -r '.data.blocks.total')
lifetime_roa=$(echo "$response" | jq -r '.data.stats.lifetime.roa')
lifetime_luck=$(echo "$response" | jq -r '.data.stats.lifetime.luck')
recent_roa=$(echo "$response" | jq -r '.data.stats.recent.roa')
recent_luck=$(echo "$response" | jq -r '.data.stats.recent.luck')
last_block_time=$(echo "$response" | jq -r '.data.last_block.time')
last_block_proto=$(echo "$response" | jq -r '.data.last_block.proto')
last_block_slot_number=$(echo "$response" | jq -r '.data.last_block.slot_no')
last_block_epoch_number=$(echo "$response" | jq -r '.data.last_block.epoch_no')
# Convert lovelace to ADA
active_stake_ada=$(echo "$active_stake / 1000000" | bc -l)
live_stake_ada=$(echo "$live_stake / 1000000" | bc -l)
pledged_ada=$(echo "$pledged / 1000000" | bc -l)
# Convert ISO → epoch milliseconds
if [[ -n "$last_block_time" ]]; then
last_block_time_ms=$(($(date -d "$last_block_time" +%s) * 1000))
else
last_block_time_ms=0
fi
# Write Prometheus metrics file
cat <<EOF > "${OUTPUT_FILE}"
# HELP cexplorer_active_stake_ada - Active stake in ADA
cexplorer_active_stake_ada ${active_stake_ada}
# HELP cexplorer_live_stake_ada - Live stake in ADA
cexplorer_live_stake_ada ${live_stake_ada}
# HELP cexplorer_delegators - Number of delegators
cexplorer_delegators ${delegators}
# HELP cexplorer_pledge - Pool Pledge in ADA
cexplorer_pledge_ada ${pledged_ada}
# HELP cexplorer_saturation - Pool Saturation
cexplorer_saturation ${saturation}
# HELP cexplorer_blocks_epoch - Blocks minted in current epoch
cexplorer_blocks_epoch ${blocks_epoch}
# HELP cexplorer_blocks_total - Total blocks minted lifetime
cexplorer_blocks_total ${blocks_total}
# HELP cexplorer_lifetime_roa - Lifetime ROA percentage
cexplorer_lifetime_roa ${lifetime_roa}
# HELP cexplorer_lifetime_luck - Lifetime Luck percentage
cexplorer_lifetime_luck ${lifetime_luck}
# HELP cexplorer_recent_roa - Recent epoch ROA percentage
cexplorer_recent_roa ${recent_roa}
# HELP cexplorer_recent_luck - Recent epoch Luck percentage
cexplorer_recent_luck ${recent_luck}
# HELP cexplorer_last_block_time_ms - Last Block time
cexplorer_last_block_time_ms ${last_block_time_ms}
# HELP cexplorer_last_block_proto - Last Block Protocol
cexplorer_last_block_proto ${last_block_proto}
# HELP cexplorer_last_block_slot_number - Last Block Slot Number
cexplorer_last_block_slot_number ${last_block_slot_number}
# HELP cexplorer_last_block_epoch_number - Last Block Epoch Number
cexplorer_last_block_epoch_number ${last_block_epoch_number}
EOF
chmod +x getstats.sh
./getstats.sh
cd $NODE_HOME/poolStat
cat poolStat.prom
# HELP cexplorer_active_stake_ada - Active stake in ADA
cexplorer_active_stake_ada 807189.69016300000000000000
# HELP cexplorer_live_stake_ada - Live stake in ADA
cexplorer_live_stake_ada 847049.41978400000000000000
# HELP cexplorer_delegators - Number of delegators
cexplorer_delegators 65
# HELP cexplorer_pledge - Pool Pledge in ADA
cexplorer_pledge_ada 113027.96825000000000000000
# HELP cexplorer_saturation - Pool Saturation
cexplorer_saturation 0.011
# HELP cexplorer_blocks_epoch - Blocks minted in current epoch
cexplorer_blocks_epoch 0
# HELP cexplorer_blocks_total - Total blocks minted lifetime
cexplorer_blocks_total 242
# HELP cexplorer_lifetime_roa - Lifetime ROA percentage
cexplorer_lifetime_roa 1.95399410812197
# HELP cexplorer_lifetime_luck - Lifetime Luck percentage
cexplorer_lifetime_luck 0.9997108660683562
# HELP cexplorer_recent_roa - Recent epoch ROA percentage
cexplorer_recent_roa 1.309502264533149
# HELP cexplorer_recent_luck - Recent epoch Luck percentage
cexplorer_recent_luck 1.1085345058639466
# HELP cexplorer_last_block_time_ms - Last Block time
cexplorer_last_block_time_ms 1771643550000
# HELP cexplorer_last_block_proto - Last Block Protocol
cexplorer_last_block_proto 10.6
# HELP cexplorer_last_block_slot_number - Last Block Slot Number
cexplorer_last_block_slot_number 180077259
# HELP cexplorer_last_block_epoch_number - Last Block Epoch Number
cexplorer_last_block_epoch_number 614