Introduction

Monitoring your node’s performance in real time allows you to ensure that it is running smoothly and efficiently. The go-quai client bundles a monitoring solution that allows you to track the health and performance of your node. This guide will walk you through setting up Grafana and Prometheus to monitor your node.

Prerequisites

Quai Network NodeA Quai Network node to enable monitoring for.
GrafanaAn open-source analytics and monitoring solution.
PrometheusAn open-source monitoring and alerting toolkit.

Install Dependencies

If you are configuring monitoring for an external node, you will need to forward the Prometheus and Grafana ports to your local machine. Grafana runs on port 3000, and Prometheus runs on port 9090 by default.

Prometheus

Installing Prometheus can be done from the command line using your favorite package manager. Run the following command to install Prometheus on a Linux machine:

sudo apt install prometheus -y

On first install, it can be useful to enable the Prometheus service to start on boot. This will prevent you from having to manually start the service every time you reboot your machine. To enable the Prometheus service, run the following command:

sudo systemctl enable prometheus

Grafana

You can install Grafana by following the instructions on the official Grafana download page.

For example, on Ubuntu, you can install Grafana using the following commands:

sudo apt-get install -y adduser libfontconfig1 musl
wget https://dl.grafana.com/oss/release/grafana_10.4.2_amd64.deb
sudo dpkg -i grafana_10.4.2_amd64.deb

Configuration

Prometheus requires a configuration file to scrape metrics from your node. go-quai has a pre-configured Prometheus configuration file that you can use. To use this configuration file, run the following command:

# navigate to the go-quai directory
cd go-quai

# copy the configuration file
sudo cp metrics_config/prometheus.yml /etc/prometheus/

You only need to copy the configuration file once. If you have already copied the file, you do not need to run the command again.

Initialize Node Monitoring

To start monitoring your node, you’ll need to ensure that both Prometheus and Grafana are running. You can start both services using the following commands:

sudo systemctl start prometheus
sudo systemctl start grafana-server.service

Once both services are running, you’ll need to start your Quai Network node with the --metrics.enabled flag. This will enable Prometheus to scrape metrics from your node. To start your node with the --metrics.enabled flag, run your normal node startup command with the metrics flag added to it:

# start your node with the added metrics flag
./build/bin/go-quai start <--startup-flags> --metrics.enabled

If you’re not familiar with other go-quai startup flags, refer to the Run a Node guide.

Access Grafana

To access Grafana, open your web browser and navigate to http://localhost:3000. You will be prompted to log in. The default username and password are both admin.

If you are monitoring a local machine, you may keep the default password and username or change them. If you are monitoring an external node, i.e. you have forwarded your ports, it is highly recommended to change the default password and username.

Add Prometheus to Grafana

Once you have logged into Grafana, we need to add Prometheus as a data source. To do this, follow these steps:

1

Open Connections Menu

Click on Connections in the left-hand menu.
2

Add New Connection

In the connections menu, Click on Add new connection.
3

Select Prometheus

Select Prometheus from the list of data sources. You may need to search for it.
4

Add New Data Source

Click on Add new data source in the upper right. This will take you to a settings tab where you can configure Prometheus.

5

Set Prometheus Server URL

In the Connection section of the settings tab, enter the following URL:

  • http://localhost:9090 if you’re monitoring a local machine
  • http://EXTERNALIPADDRESS:9090 if you are monitoring an external node

After adding Prometheus as a data source, we can create a dashboard to monitor our node. To do this, follow these steps:

1

Open Dashboards

Click on Dashboards in the left-hand menu.
2

Create New Dashboard

Click the New button.
3

Import Configuration

Click the Import button.
4

Paste Configuration

Paste the configuration file located in metrics_config/grafana_metrics.json into the text box. You can find the configuration file here

Monitor Your Node

After setting the data source and importing the configuration file, you should see a dashboard similar to the one below that displays the health and performance of your node. Your node is now being monitored in real time.