How to Add Pool Data from Cexplorer to your Grafana Dashboard

Before we get started

This guide will walk you through the process of adding your pool stats from Cexploer.ioarrow-up-right to your Grafana dashboard.

circle-info

Credits to Envy Stake Poolarrow-up-right and Earn Coin Poolarrow-up-right for documenting the procedure.

Also credit to sanskysarrow-up-right for documenting original procedure for adapools

Copy your Json file from Cexplorer.ioarrow-up-right. Navigate to your pool then click on Share Tab. Then scroll down to "Data" and copy link to "JSON data output" file. Copy URL.

circle-info

Keep this URL you will need it later

click on Share Tab
scroll down to "Data" copy link to "JSON data output"
Copy URL

Step 2 - Create poolStat Directory

Create poolStat directory by running the following commands:

Step 3 -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.

circle-exclamation

Step 4 - Add Permissions and Run the getstat Script

Add permissions and run getstat script by running these commands:

Step 5 - Check Output File

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

Step 6 - 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:

circle-exclamation

Step 7 - Change Default User for prometheus-node-exporter.service

hange the default user to your Linux user name in prometheus-node-exporter.service. Replace below.

circle-info

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 8 - Reload Daemon and Restart Services

Reload daemon and restart services by running:

Verify that the services are running properly:

Step 9 - 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.

circle-exclamation

Step 10 - Display Data in Grafana

Now for your data source select Prometheus:

Select Prometheus for Data source

Now you should see all the "cexplorer_" Metrics

Some of the data you might want to display:

circle-info

Remember amounts are given in lovelace so you need to divide by 1,000,000 to display in ADA

  1. Pledge = (cexplorer_pledge)/1000000

  2. Active Stake = (cexplorer_stake)/1000000

  3. Lifetime Blocks = cexplorer_blocks_lifetime

  4. Estimated Blocks per Epoch = cexplorer_blocks_est_epoch

  5. Lifetime ROA = cexplorer_roa_lifetime

  6. Current Number of Delegators = cexplorer_delegators

  7. Pool Rank = cexplorer_position

  8. Lifetime Luck = (cexplorer_luck_lifetime)*100

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

Envy Stake Pool - Ticker ENVYarrow-up-right

Earn Coin Pool - Ticker: ECParrow-up-right

xSPO Alliance Logo xSPO Alliancearrow-up-right

Last updated