βš’οΈNode-exporter + Grafana + Prometheus + Alertmanager

In this guide, we will set up a monitoring system that will collect metrics from all our servers and visualize them in Grafana. You can also install Alertmanager to receive notifications about server problems, in our case, in Telegram

We need a separate server for Prometheus, Grafana, Node Exporter, Alertmanager. All other servers will only have Node Exporter installed


Prometheus is an open source DBMS written in Go. An interesting feature of Prometheus is that it pulls metrics from a given set of services. Due to this, Prometheus cannot have any data queues clogged, which means monitoring will never become a bottleneck in the system

Node Exporter is a service whose job is to export machine information in a format that Prometheus can understand. There are actually many other exporters for Prometheus, but Node Exporter is perfect for our purposes of server monitoring

Grafana is an open web frontend to various time series DBMSs, such as Graphite, InfluxDB, and, of course, Prometheus. With Grafana, we can see beautiful graphs through our browser. It is characteristic that Prometheus also has its own web interface, but even the Prometheus developers themselves recommend using Grafana

Default ports:

  • prometheus - 9090 (in our guide changed to 8080)

echo -e "\033[0;32mhttp://$(wget -qO- eth0.me):8080/\033[0m"

  • node exporter - 9100

echo -e "\033[0;32mhttp://$(wget -qO- eth0.me):9100/\033[0m"

  • grafana - 3000

echo -e "\033[0;32mhttp://$(wget -qO- eth0.me):3000/\033[0m"

Node Exporter

Can find the latest binaries along with their checksums on the Prometheus download page

Create a service file

Check that the metrics are being given

Now is the time to check the metrics in the browser

We see that everything is fine and we get the necessary data, which will later be displayed in Grafana

Prometheus, Grafana, AlertManager

Step 1 - Preparing the Server

Step 2 - Create a Prometheus User

For security purposes, let's create a prometheus account

Step 3 - Install Prometheus

Step 4 - Configure Prometheus

Now we need to configure prometheus.yml and add 1 or more parameters to it depending on the number of servers and nodes used

Open the default config and bring it to the following form

Create a service file

Check that the metrics are being given

Now is the time to check the information in the browser

Go to Targets

In the future, you can add additional information about your other servers to prometheus.yml to monitor several servers at once. The configuration will depend on your settings and json for Grafana

Step 5 - Install Grafana

Now it's time to go to the browser

When you first open it, you must enter your login and password

Login - admin

Password - admin

The system immediately asks us to come up with a new password. Don't skip this!!!
Go to Data sources to configure Grafana

Now we need to specify the URL address to our server with Prometheus in the column. If Prometheus is on the same server as Grafana, then set http://localhost:8080 and save the settings

Now the most interesting part and we need to upload json files for our dashboard. To do this, you need to know the ID of the json file or download it from someone or create it yourself

If we have downloaded json, then we upload it ourselves

You can load several json at once and switch between them. Or create your own, spending a certain amount of time on it)

Step 6 - Install Alert manager

First, let's set up Prometheus rules. To do this, create a rules.yml file in the /etc/prometheus/ section, which will contain our rules for alerts In our configuration file, we will monitor the operation of node exporter, CPU load, RAM, and disk space

Adding information about our rules to the existing prometheus config

Adding lines

Check the created rules. The output should be #SUCCESS

After making all the changes, restart Prometheus

Downloading binary files

Set up alertmanager.yml, in which we register the bot token and chat ID from Telegram, to which notifications will be sent

Now you can try to make a test run and temporarily disable node exporter on another server. You should receive a notification in Telegram

The web interface will be available on port 9093. Find out the address and paste it into the browser

Create a service file

Setting up UFW

In order to ensure the protection of your data, you must at least close our ports from others, since without this, anyone knowing the server IP and port will be able to receive Node exporter or Prometheus data from Grafana We can configure UFW so that data from Prometheus and Grafana are available only from the IP we need (for example, a home PC). And data from Node exporter is available only to the server where Prometheus is installed

Useful commands

Temporarily load the CPU

Temporarily load RAM

Remove Alert manager

Remove Prometheus

Remove Grafana

Last updated