Giter Site home page Giter Site logo

ssc-slot-monitoring's Introduction

Monitoring SlotsBehind for your Solana RPC node with Grafana and Prometheus

This guide aims to help export your node's slotsBehind stats in near real-time so you can monitor with Grafana.

Step 1 - Create a directory for the nodeexperter Textfile Collector to read

sudo mkdir /var/lib/node_exporter/textfile_collector

Step 2 - Create the cron jobs to schedule the stats export

Add a cron job to place the stats into text files in that directory for the Textfile Collector, in a format fit for nodeExporter:

To monitor slot status:

sudo nano /etc/cron.d/solana_slots_stats

In the "solana_slots_stats" file paste the following (*/2 means I have mine updating every 2 minutes):

*/2 * * * * root curl http://localhost:8899 -k -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getHealth"}' 2>&1 | sed -nr 's/^(.*)(numSlotsBehind":)([0-9]+)(.*)$/node_solana_slots_status{Stats="SlotsBehind"} \3/p' > /var/lib/node_exporter/textfile_collector/solana_slots_stats.prom.$$ && mv /var/lib/node_exporter/textfile_collector/solana_slots_stats.prom.$$ /var/lib/node_exporter/textfile_collector/solana_slots_stats.prom

Bonus - To monitor directory sizes:

sudo nano /etc/cron.d/directory_size

In the directory_size file paste the following (*/5 means I have mine updating every 5 minutes, and I'm monitoring the sizes of three directories; /mt/accounts, /mt/ledger/validator-ledger/rocksdb and /mt/ledger/validator-ledger/accounts_index ):

*/5 * * * * root du -sb /mt/accounts /mt/ledger/validator-ledger/rocksdb /mt/ledger/validator-ledger/accounts_index | sed -ne 's/^\([0-9]\+\)\t\(.*\)$/node_directory_size_bytes{directory="\2"} \1/p' > /var/lib/node_exporter/textfile_collector/directory_size.prom.$$ && mv /var/lib/node_exporter/textfile_collector/directory_size.prom.$$ /var/lib/node_exporter/textfile_collector/directory_size.prom`

Step 3 - Modify the nodeExporter config in docker-compose.yml:

sudo nano docker-compose.yml

Under the "nodeexperter" section in the docker-compose.yml file, add the directory we created earlier to the container's mapped volumes:

- /var/lib/node_exporter/textfile_collector/:/host/textfile_collector:ro

Also add the command for nodeExporter to run the Textfile Collector on that directory:

- '--collector.textfile.directory=/host/textfile_collector'

e.g. docker-compse.yml file snippet:

	[...]
	nodeexporter:
		image: prom/node-exporter
		container_name: nodeexporter
		volumes:
		  - /proc:/host/proc:ro
		  - /sys:/host/sys:ro
		  - /var/lib/node_exporter/textfile_collector/:/host/textfile_collector:ro
		  - /:/rootfs:ro
		command:
		  - '--path.procfs=/host/proc'
		  - '--path.rootfs=/rootfs'
		  - '--path.sysfs=/host/sys'
		  - '--collector.textfile.directory=/host/textfile_collector'
		  - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
	[...]

Once you've made the changes to the docker-comse.yml file, change directory to where your docker-compose.yml resides and restart the containers to make the changes take effect (e.g. cd ~/shadow-monitoring):

sudo docker-compose up -d

Step 4 - Check in Grafana that the stats have made it to Prometheus

In Grafana, after 5 or so minutes we can verify that the stats are visible.

Open Explorer, and begin typing node_sol, if everything is working, you should see the new node name we're collecting autofill:

image

Select it, and type { and click "Stats":

image

Then click "SlotsBehind":

image

Now run the query:

image

If it's working (and your node is behind) you should now see the graph:

image

You can now add this query to your dashboard!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.