Monitor Linux Server With Prometheus and Grafana

Step-by-step guide to monitoring Linux servers with Prometheus and Grafana. Install Node Exporter, configure Prometheus scrape jobs, and build dashboards for CPU, memory, disk, and network metrics.

Monitoring your Linux servers is essential for understanding resource usage, spotting issues before they cause outages, and planning capacity. Prometheus and Grafana are two of the most widely used open source tools for collecting and visualizing metrics: Prometheus scrapes metrics from your hosts and applications, and Grafana turns that data into clear, actionable dashboards.

In this guide you will learn how to monitor a Linux server with Prometheus and Grafana by:

  • Installing and running the Prometheus Node Exporter on the host to expose hardware and OS metrics
  • Configuring Prometheus to scrape the Node Exporter
  • Installing Grafana and connecting it to Prometheus
  • Importing a ready-made Node Exporter dashboard to visualize CPU, memory, disk, and network metrics

By the end, you will have a working monitoring stack you can extend to more servers or add alerting to.

What is Prometheus?

Prometheus is an open source systems monitoring and alerting toolkit. It works by pulling (scraping) metrics over HTTP from targets you define—such as the Node Exporter on a Linux server—and storing them in a time-series database. You can then query that data with PromQL (Prometheus Query Language) or use it in Grafana for dashboards and alerting.

Prometheus is well-suited to server and application metrics, is widely adopted in DevOps and cloud-native environments, and integrates with many exporters and alerting systems.

What is Grafana?

Grafana is an open source platform for analytics and visualization. It connects to multiple data sources (including Prometheus) and lets you build dashboards with graphs, gauges, and tables. Grafana does not store metrics itself; it queries Prometheus (and other backends) in real time and displays the results in a clear, visual way.

Together, Prometheus and Grafana give you a full pipeline: collect metrics (Prometheus) → visualize and explore (Grafana).

Architecture Overview

A typical setup for monitoring a single Linux server looks like this:

  1. Node Exporter runs on the Linux server and exposes metrics on http://localhost:9100/metrics.
  2. Prometheus runs on a monitoring host (or the same server) and periodically scrapes the Node Exporter endpoint. It stores the metrics and serves them for queries.
  3. Grafana runs on a host with a web UI (often the same as Prometheus). It is configured with Prometheus as a data source and queries it to render dashboards.
1
2
3
4
┌─────────────────┐     scrape      ┌─────────────────┐     query      ┌─────────────────┐
│  Linux Server   │ ◄────────────── │   Prometheus    │ ◄───────────── │    Grafana      │
│  Node Exporter  │   (e.g. :9100)  │   (e.g. :9090)  │   (PromQL)     │   (e.g. :3000)   │
└─────────────────┘                 └─────────────────┘                 └─────────────────┘

You can run Prometheus and Grafana on the same machine as Node Exporter for a single-server setup, or on a dedicated monitoring host when you have multiple servers.

Prerequisites

Before you start, ensure you have:

  • A Linux server to monitor (e.g. Ubuntu 20.04+, Debian 11+, or RHEL/CentOS/Rocky 8+). The steps below use a generic systemd-based distribution.
  • Root or sudo access to install packages and create systemd units.
  • Prometheus and Grafana installed somewhere that can reach the Linux server (same host or another). If you do not have them yet, you can install Prometheus and Grafana on the same server for a minimal setup.
  • Ports used in this guide: Node Exporter 9100, Prometheus 9090, Grafana 3000. Adjust firewall rules if needed.

The following sections assume you are logged in to the Linux server you want to monitor and have sudo available.

Installing Node Exporter

The Prometheus Node Exporter is the standard way to expose hardware and kernel-related metrics from a Linux host. It runs as a small binary and serves a /metrics endpoint in Prometheus text format.

Download and Install the Binary

Check the Node Exporter releases page for the latest version. The examples below use v1.2.0; replace the version number and architecture (e.g. linux-arm64) if your system is different.

1
2
3
4
5
6
7
8
# Set version and architecture (adjust if needed)
NODE_EXPORTER_VERSION="1.2.0"
ARCH="linux-amd64"

# Download and extract
curl -LO "https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.${ARCH}.tar.gz"
tar -xzf "node_exporter-${NODE_EXPORTER_VERSION}.${ARCH}.tar.gz"
sudo mv "node_exporter-${NODE_EXPORTER_VERSION}.${ARCH}/node_exporter" /usr/local/bin/

This places the node_exporter binary in /usr/local/bin so it is available system-wide.

Running Node Exporter as an unprivileged user follows the principle of least privilege:

1
sudo useradd -rs /sbin/nologin prometheus

-r creates a system user; -s /sbin/nologin prevents login.

Create a systemd Service

Create a systemd unit so Node Exporter starts on boot and can be managed with systemctl:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
sudo tee /etc/systemd/system/node_exporter.service <<'EOF'
[Unit]
Description=Prometheus Node Exporter
Documentation=https://github.com/prometheus/node_exporter
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target
EOF

Reload systemd, enable the service to start on boot, and start it:

1
2
3
sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter
sudo systemctl status node_exporter

You should see active (running). If the user was created after moving the binary, ensure /usr/local/bin/node_exporter is readable by the prometheus user (default permissions are usually sufficient).

Verifying Node Exporter Metrics

Node Exporter listens on TCP port 9100 by default. You can confirm it is serving metrics with:

1
curl -s http://localhost:9100/metrics | head -30

You should see lines in Prometheus exposition format, for example:

  • node_cpu_seconds_total – CPU time per mode
  • node_memory_* – Memory stats
  • node_filesystem_* – Disk usage
  • node_network_* – Network I/O

If you see output like that, Node Exporter is working. Keep this endpoint in mind: Prometheus will scrape http://<host>:9100/metrics.

Adding the Server to Prometheus

Your Prometheus server must be configured to scrape the Node Exporter. This section assumes Prometheus is already installed (on the same host or another) and that you can edit its configuration.

Prometheus Configuration Example

A minimal Prometheus config that scrapes the local Node Exporter every 15 seconds looks like this:

1
2
3
4
5
6
7
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "node_exporter"
    static_configs:
      - targets: ["localhost:9100"]
  • scrape_interval – How often Prometheus scrapes all targets (here, every 15s).
  • job_name – Label for this job; it shows up in Prometheus and Grafana.
  • targets – List of <host>:port> endpoints. Use localhost:9100 if Prometheus runs on the same host as Node Exporter; otherwise use the server’s IP or hostname, e.g. 192.168.1.10:9100.

Creating the Configuration File

On the host where Prometheus runs, create or update the config (common path is /etc/prometheus/prometheus.yml). Example using a here-document:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Create directory if it does not exist
sudo mkdir -p /etc/prometheus

# Write config (adjust targets if Prometheus is on a different host)
sudo tee /etc/prometheus/prometheus.yml <<'EOF'
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']
EOF

If Node Exporter runs on another machine, replace localhost:9100 with that machine’s address, for example:

1
- targets: ["192.168.1.10:9100"]

For multiple servers, add more targets or use a list:

1
2
3
4
5
- job_name: "node_exporter"
  static_configs:
    - targets:
        - "server1:9100"
        - "server2:9100"

Set ownership so Prometheus can read the file (replace prometheus with the user that runs Prometheus if different):

1
sudo chown -R prometheus:prometheus /etc/prometheus

Reload or restart Prometheus so it picks up the new config:

1
2
3
4
# If using systemd
sudo systemctl reload prometheus
# or
sudo systemctl restart prometheus

Checking That Prometheus Is Scraping

Open the Prometheus UI (e.g. http://<prometheus-host>:9090), go to Status → Targets, and confirm the node_exporter job is UP. You can also run a quick query, e.g. node_cpu_seconds_total, to see that metrics are being stored.

Installing and Configuring Grafana

Grafana provides the dashboards and UI for your metrics. Install it on the same host as Prometheus or on a separate machine that can reach Prometheus.

Install Grafana

Installation varies by distribution. Example for Ubuntu/Debian:

1
2
3
4
5
6
7
8
# Add Grafana APT repository
sudo apt-get install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install -y grafana

sudo systemctl enable --now grafana-server

For RHEL/CentOS/Rocky, use the official Grafana install instructions. After installation, the web UI is usually at http://<grafana-host>:3000. Default login is admin / admin; you will be prompted to change the password on first login.

Add Prometheus as a Data Source

  1. In Grafana, go to Configuration (gear icon) → Data sources.
  2. Click Add data source and choose Prometheus.
  3. Set URL to your Prometheus address, e.g. http://localhost:9090 (or http://<prometheus-host>:9090 if Grafana is on another host).
  4. Click Save & test. Grafana should report “Data source is working”.

Once this is done, you can build or import dashboards that query Prometheus.

Importing the Node Exporter Dashboard

Pre-built dashboards make it easy to visualize Node Exporter metrics without writing queries from scratch.

  1. In Grafana, go to DashboardsImport (or the + icon → Import).
  2. Enter the dashboard ID 1860 (Node Exporter Full) and click Load.
  3. Select the Prometheus data source you added and click Import.

You should see a dashboard with panels for CPU, memory, disk, network, and other metrics. If you have multiple targets, use the instance or job dropdown at the top to switch between hosts.

Dashboard 1860 is available on Grafana.com. You can browse other Node Exporter dashboards (e.g. 11074, 405) and import them the same way.

Verifying the Full Stack

A quick checklist to confirm everything is wired correctly:

ComponentCheck
Node Exportercurl http://localhost:9100/metrics returns metrics.
PrometheusTargets page shows node_exporter as UP; query node_up returns 1 for the job.
GrafanaPrometheus data source “Save & test” succeeds.
DashboardImport dashboard 1860; panels show data and instance selector lists your host(s).

If the dashboard shows “No data”, ensure the time range (top-right) includes the period when Prometheus was scraping, and that the selected data source is the one pointing to your Prometheus.

Troubleshooting

  • Connection refused to :9100 Node Exporter may not be running or may be bound to a different port. Check sudo systemctl status node_exporter and ss -tlnp | grep 9100.

  • Prometheus target is DOWN Check network and firewall between Prometheus and the Node Exporter host. From the Prometheus server, run curl http://<node-exporter-host>:9100/metrics.

  • Grafana: “Data source is not working” Confirm Prometheus is listening (e.g. on 9090) and that the Grafana host can reach it. Check Prometheus listen address and firewall.

  • Dashboard shows no data Confirm the scrape target is UP in Prometheus and that the dashboard’s Prometheus data source and time range are correct. Try a simple query in Explore, e.g. node_cpu_seconds_total.

Summary

You now have a full path from the Linux server to Grafana:

  1. Node Exporter on the server exposes metrics at :9100/metrics.
  2. Prometheus scrapes that endpoint and stores the time-series data.
  3. Grafana uses Prometheus as a data source and displays the imported Node Exporter dashboard.

From here you can add more hosts (install Node Exporter and add them to prometheus.yml), add Alertmanager for alerts, or use the same Prometheus instance for application metrics. For a production-ready Prometheus setup on Kubernetes, including high availability and secure authentication, see the Production-Ready Prometheus on Kubernetes guide.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy