Simple Python script to fetch an Ethereum 2.0 Validator Balances from a local beacon node HTTP server and export them as a Prometheus Gauge metric.
pip3 install prometheus_client
- Replace the
VALIDATOR_INDICES
array with the indices of the validators you want to track (you can check beaconscan.com if you don't know your indices). - Replace the
UPDATE_INTEVAL
with the desired refresh rate of your metric. - Run
python3 /PATH/TO/SCRIPT/balance-logger.py
as a service to keep it running permanently. - Add port
http://127.0.0.1:9010
as a prometheus target in yourprometheus.yml
. - Metric will appear as
validator_balance
in Grafana.
-
You should probably wait for your ETH2 beacon-node HTTP server to be up before starting this script, otherwise this script will crash.
-
For bonus points, install CryptoWat to convert the balances to local currency.