Add data from ADApools to your public dashboard (v1.1)
Tested on Ubutnu 20.04, Grafana 7.4.3, Pormetheus 2.15.2
Inspired by BUFFY page
https://crypto2099.io/adding-pool-stats-to-grafana-dashboard/

Prerequisites
  • Grafana installed and running
  • Prometheus installed and running as service
  • Prometheus-node-exporter installed and running as service
  1. Copy your JSON link or your Pool ID from apapools.org



  2. Prometheus can only use numeric data, so we must first trim the JSON file.
    cd /$NODE_HOME or < YOUR NODE FULL PATH >
    mkdir -p adapools
    cd adapools
    echo "curl https://js.adapools.org/pools/< YOUR POOL ID >/summary.json 2>/dev/null \
    | jq '.data | del(.pool_id_bech32, .hist_bpe, .handles, .hist_roa, .db_ticker, .db_name, .db_url, .ticker_orig, .group_basic, .pool_id, .direct, .db_description, .tax_ratio_old, .tax_fix_old)' \
    | tr -d \\\"{},: \
    | awk NF \
    | sed -e 's/^[ \t]*/adapools_/' > adapools.prom" > getstats.sh
    chmod +x getstats.sh
    ./getstats.sh

  3. Look at adapools.prom content
    nano adapools.prom
    You should have something like...
    adapools_id 1919
    adapools_total_stake 6193451722
    adapools_rewards_epoch 0
    adapools_tax_ratio 0
    adapools_tax_fix 340000000
    ...


  4. Configure promethues-node-exporter.service to grab data from adapools.prom file.
    sudo cp /lib/systemd/system/prometheus-node-exporter.service /lib/systemd/system/prometheus-node-exporter.service_backup
    sudo nano /lib/systemd/system/prometheus-node-exporter.service
    Change ExecStart line for
    ExecStart=/usr/bin/prometheus-node-exporter --collector.textfile.directory=< YOUR NODE FULL PATH >/adapools --collector.textfile
    Reload daemon and restart services
    sudo systemctl daemon-reload
    sudo systemctl restart prometheus-node-exporter.service
    sudo systemctl restart prometheus.service

  5. Assuming Grafana and Prometheus are active and running, you can now add data coming directly from ADApools to your public dashboard. Let's add the active stake.
    1. Add a new panel.

    2. From Prometheus datasource, select Metrics, adapools, adapools_total_stake.
    3. Data from the pledge, active_stake and total_stake are lovelaces, you must divide by 1 000 000 to get it in ADA.
    4. Add a title to your panel, choose Stat for visualization template and don't forget to tick Instant if you don't want the graph.
    5. Set thresholds to change color.
    6. Save and that's it.

  6. Set cron job to update data from ADApools everyday.
    crontab -e
    Add those lines
    #Get data from ADApools every day at 00:00
    0 0 * * * cd < YOUR NODE FULL PATH >/adapools/ && ./getstats.sh

  7. Now, you can create any panel you want with all data from ADApools.
    * *
    *Would like to...but not my data.


@ Level Up! 2021