Two Node Monitoring with Node Exporter, Prometheus & Grafana

In today’s dynamic infrastructure, monitoring servers effectively is very important. There are lot of monitoring tools available but I was looking for something that can help me monitoring my DB servers for its disk utilization. For Linux administrators and DevOps engineers, tools like Node Exporter, Prometheus, and Grafana play a crucial role in collecting and visualizing system metrics. In this article, we’ll walk through how to set up Node Exporter + Prometheus + Grafana for two-node monitoring, ensuring real-time visibility and performance tracking.

Although this setup may seem complex initially to some guys but it becomes easy once you follow the steps sequentially. Furthermore, each component in the stack has a specific role that makes the architecture modular and efficient.

What Is Node Exporter?

Node Exporter is a lightweight agent that collects hardware and OS metrics such as CPU, memory, disk, and network usage. You can typically install on every Linux machine that needs to be monitored. Here we will install in two nodes to which are going to monitor.

Why Use Prometheus?

Prometheus acts as the time-series database that scrapes metrics from Node Exporter on each node at regular intervals so that you can use it. While Node Exporter exposes the metrics, Prometheus collects and stores them. Most importantly, Prometheus supports service discovery, alerting, and flexible configuration. Later we can use that in Grafana for Visualization.

Grafana for Visualization

Once Node Exporter done and Prometheus starts collecting data, you need a way to visualize those metrics. That’s where Grafana comes in. It connects to Prometheus and provides beautiful dashboards with real-time graphs. Consequently, you can monitor system performance at a glance. You can easily see CPU utilization, Disk Read/Write details and etc.

Step-by-Step Setup Guide

Server Details:

Hostname: server1 , IP Address: 192.168.1.10
Hostname: server2 , IP Address: 192.168.1.11

I have a server3 on which I’ll setup it as Monitoring Server.

Let’s break down the installation process for each component.

1. Install Node Exporter on Both Nodes

wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xvf node_exporter-1.8.0.linux-amd64.tar.gz
cd node_exporter-1.8.0.linux-amd64
./node_exporter &  # You can start manually it, But I'll prefer it as a service. 

ln -s /opt/node_exporter-1.8.0.linux-amd64/node_exporter /usr/local/bin/node_exporter

Creating Service for the same

vi /etc/systemd/system/node_exporter.service   # Edit the file and add below content

[Unit]
Description=Node Exporter
After=network.target

[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=default.target

systemctl daemon-reload
systemctl enable --now node_exporter
systemctl status node_exporter

Now you can open below page for metrices.

http://server1:9100 and http://server2:9100

2. Download, Install and Configure Prometheus to Scrape both nodes on Monitoring server

wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
tar -xvf prometheus-2.52.0.linux-amd64.tar.gz
cd prometheus-2.52.0.linux-amd64

ln -s /opt/prometheus-2.52.0.linux-amd64/prometheus /usr/local/bin/prometheus
ln -s /opt/prometheus-2.52.0.linux-amd64/promtool /usr/local/bin/promtool

Or you can move the folder to /usr/local/bin/

Configuration

mkdir /etc/prometheus
cp prometheus.yml /etc/prometheus/   # Or create a new one if you don't have. 

Edit prometheus.yml file:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'node_exporters'
    static_configs:
      - targets: ['192.168.1.10:9100', '192.168.1.11:9100']


./prometheus --config.file=prometheus.yml &  # Manual Run, I'll suggest to create a service of it as well. 

vi /etc/systemd/system/prometheus.service # Edit the file and add below content

[Unit]
Description=Prometheus
After=network.target

[Service]
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus
User=nobody

[Install]
WantedBy=multi-user.target


mkdir /var/lib/prometheus
systemctl daemon-reload
systemctl enable --now prometheus
systemctl status prometheus

Step 3: Install Grafana on the Monitoring Node

Setup repo and then install required package

tee /etc/yum.repos.d/grafana.repo<<EOF
[grafana]
name=Grafana OSS
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
EOF


yum install -y grafana
systemctl enable --now grafana-server


Grafana UI: http://server3:3000
Default login: admin / admin

Step 4: Connect Grafana to Prometheus

Add Prometheus as data source (http://localhost:9090).

Import dashboard ID 1860 for Node Exporter.

Conclusion

By using Node Exporter, Prometheus, and Grafana, you can monitor two Linux nodes easily, while keeping your monitoring services on a dedicated monitoring node. The benefits of real-time metrics, scalability, and open-source flexibility are undeniable. Consequently, this is ideal for modern DevOps environments.

Keep exploring. Continue reading on our blog.

Nagios and NagioSQL

Leave a Reply

Your email address will not be published. Required fields are marked *