January 30

Installing and configuring monitoring

The example of Prometheus+Grafana+Node_exporter+autonomys_exporter


Grafana and Prometheus form a powerful bundle for real-time monitoring and visualization of metrics. Grafana is a popular tool for creating informative and interactive dashboards that help users visually track performance, logs, and notifications. Prometheus, on the other hand, is an open source monitoring and alerting system designed to collect metrics in highly dynamic environments such as containerized applications.

What we will do


In this article, we'll go step-by-step through how to install Grafana and Prometheus on your system, as well as import a dashboard to track key metrics for your server.

1) Node-exporter


Install node-exporter on the server we want to see on the chart.

. <(wget -qO- https://raw.githubusercontent.com/g7AzaZLO/NodeExporter-autoinstaller/main/NodeExporter-auto-install.sh)

You can verify that everything installed well

sudo journalctl -u exporterd -f

**You can also see a list of metrics that the server gives out

Go to http://<IP_ADDRESS>:9100/metrics , where <IP_ADDRESS> is the ip of our server

2) Prometheus


Install Prometheus on the same or any other server, it serves as a metrics aggregator and we will need it in a single quantity

Download and install

wget https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz && \tar xvf prometheus-2.28.1.linux-amd64.tar.gz && \rm prometheus-2.28.1.linux-amd64.tar.gz && \mv prometheus-2.28.1.linux-amd64 prometheus

Add our server (on which node-exporter is installed) to the target list
Open our Prometheus config for customization

nano $HOME/prometheus/prometheus.yml

Add our node-exporter (ip-server + port) to the targets

Example:

Grant execution rights to our file

chmod +x $HOME/prometheus/prometheus

Create a service file to run at startup

sudo tee /etc/systemd/system/prometheusd.service > /dev/null <<EOF
[Unit]
Description=node_exporter
After=network-online.target
[Service]
User=$USER
ExecStart=$HOME/prometheus/prometheus --config.file="$HOME/prometheus/prometheus.yml" 
Restart=always 
RestartSec=3 
LimitNOFILE=65535 
[Install] 
WantedBy=multi-user.target 
EOF

After that we start the service

sudo systemctl daemon-reload && \sudo systemctl enable prometheusd && \sudo systemctl restart prometheusd

You can check the logs like this

sudo journalctl -u prometheusd -f

You can also check if the target is visible for monitoring (our server with exporter(s)).

Go to the address in the browser:

http://<IP_ADDRESS>:9090/targets

where <IP_ADDRESS> is the IP of the server we just installed prometheus on.

3) Grafana

Grafana serves us for beautiful display of metrics and creation of simple alerts to messengers or mail

Install on any server, in my case the server is the same where Prometheus is located:

sudo apt-get install -y adduser libfontconfig1 && \wget https://dl.grafana.com/oss/release/grafana_8.0.6_amd64.deb && \sudo dpkg -i grafana_8.0.6_amd64.deb

*It is possible to install a newer version

Start and activate the service with graphana

sudo systemctl daemon-reload && \sudo systemctl enable grafana-server && \sudo systemctl restart grafana-server

You can check the logs like this:

sudo journalctl -u grafana-server -f

Finally, log into grafana, the default path is as follows:


http://<IP_ADDRESS>:3000, where <IP_ADDRESS> is the IP of the server we installed grafana on.

login : admin

password : admin

*Make sure you change your password

4) Add DataSource

It is necessary to show the grafana from where to take data for plotting.

In our case it is Prometheus

5) Import and edit graphics

Grafana has its own gallery of dashboards, in our case this one will do:

https://grafana.com/grafana/dashboards/1860-node-exporter-full/

It can be imported by ID or as a whole.

The result is something like this

This is just a basic dashboard for tracking basic server metrics, there are a great number of them and can be easily customized.

In the next part we will talk about alerts and metrics exporter for Autonomys (Subspace)