Recent versions of Substrate record metrics, such as how many peers your node is connected to, how much memory your node is using, etc. To visualize these metrics, you can use a tool called Grafana.
Step 1: Install and run Grafana
If you're on macOS, the easiest way to do that is via Homebrew:
brew install grafana
Grafana runs via a server, which you can run via
brew services start grafana
Downloads for other platforms are available here.
Step 2: Install the Grafana JSON DataSource plugin:
We use a simple JSON interface to serve metrics. The Grafana JSON DataSource plugin can be installed with:
grafana-cli plugins install simpod-json-datasource
Step 3: Run your node
As long as you're running a version of Substrate at or after commit
a server serving metrics for Grafana will start on port
9955. You can specify
this port with
--grafana-port <PORT> and enable it to be accessed over a
Step 4: Set Up Grafana
We will not cover setting up and running Grafana in great detail - there's the Getting Started guide for that. Here are a few pointers though:
- On the 'Add data source' screen, select the JSON data source in the 'Others' section.
- Set the url of the running servers (e.g.
Save & Test.
Grafana should ping the server and show that the data source is working:
Creating queries is a lot simpler than in other data sources. Simply click the drop-down and select the metric you want to visualize:
Step 5: Create Your Dashboard
Once you've done all that, you should be able to make a pretty neat node dashboard!
There's a lot of work still to be done on the metrics system. Hopefully, in the future you'll be able to log metrics from anywhere in the node runtime to a variety of databases, such as Prometheus.
If you have any suggestions, feel free to file an issue on the substrate repository.
- Learn how to set up a private Substrate network.
- Take a look at the Grafana dashboard configuration for the Polkadot network.
- Visit the source code for grafana-data-source.