How to Add Pool Data from Cexplorer to your Grafana Dashboard
Last updated
Last updated
This guide will walk you through the process of adding your pool stats from Cexploer.io to your Grafana dashboard.
Credits to Envy Stake Pool and Earn Coin Pool for documenting the procedure.
Also credit to sanskys for documenting original procedure for adapools
Copy your Json file from Cexplorer.io. Navigate to your pool then click on Share Tab. Then scroll down to "Data" and copy link to "JSON data output" file. Copy URL.
Keep this URL you will need it later
Create poolStat directory by running the following commands:
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 "https://js.cexplorer.io/api-static/pool/poolID.json" with the URL that you copied from Step 1
Add permissions and run getstat script by running these commands:
Check output file to make sure it contains only numeric values by running:
Your results should look similar to this example:
cexplorer_stake 1172188909230 cexplorer_stake_active 1172188909230 cexplorer_tax_ratio 1 cexplorer_tax_fix 340000000 cexplorer_blocks_epoch 0 cexplorer_blocks_lifetime 19 cexplorer_roa_short 1.226 cexplorer_roa_lifetime 1.52 cexplorer_pledge 25000000000 cexplorer_delegators 18 cexplorer_position 672 cexplorer_blocks_est_epoch 1.01 cexplorer_luck_lifetime 0.89 cexplorer_saturation 0.016733
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
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
Reload daemon and restart services by running:
Verify that the services are running properly:
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
Now for your data source select Prometheus:
Now you should see all the "cexplorer_" Metrics
Some of the data you might want to display:
Remember amounts are given in lovelace so you need to divide by 1,000,000 to display in ADA
Pledge = (cexplorer_pledge)/1000000
Active Stake = (cexplorer_stake)/1000000
Lifetime Blocks = cexplorer_blocks_lifetime
Estimated Blocks per Epoch = cexplorer_blocks_est_epoch
Lifetime ROA = cexplorer_roa_lifetime
Current Number of Delegators = cexplorer_delegators
Pool Rank = cexplorer_position
Lifetime Luck = (cexplorer_luck_lifetime)*100
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