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:
- Node Exporter runs on the Linux server and exposes metrics on
http://localhost:9100/metrics. - 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.
- 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.
βββββββββββββββββββ 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, Prometheus9090, Grafana3000. 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.
# 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.
Create a Dedicated User (Recommended)
Running Node Exporter as an unprivileged user follows the principle of least privilege:
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:
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:
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:
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 modenode_memory_*β Memory statsnode_filesystem_*β Disk usagenode_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:
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. Uselocalhost:9100if 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:
# 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:
- targets: ["192.168.1.10:9100"]
For multiple servers, add more targets or use a list:
- 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):
sudo chown -R prometheus:prometheus /etc/prometheus
Reload or restart Prometheus so it picks up the new config:
# 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:
# 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
- In Grafana, go to Configuration (gear icon) β Data sources.
- Click Add data source and choose Prometheus.
- Set URL to your Prometheus address, e.g.
http://localhost:9090(orhttp://<prometheus-host>:9090if Grafana is on another host). - 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.
- In Grafana, go to Dashboards β Import (or the + icon β Import).
- Enter the dashboard ID 1860 (Node Exporter Full) and click Load.
- 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:
| Component | Check |
|---|---|
| Node Exporter | curl http://localhost:9100/metrics returns metrics. |
| Prometheus | Targets page shows node_exporter as UP; query node_up returns 1 for the job. |
| Grafana | Prometheus data source βSave & testβ succeeds. |
| Dashboard | Import 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_exporterandss -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:
- Node Exporter on the server exposes metrics at
:9100/metrics. - Prometheus scrapes that endpoint and stores the time-series data.
- 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.