🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux Monitoring with Prometheus and Grafana: The Complete 2026 Setup Guide

Linux Monitoring with Prometheus and Grafana: The Complete 2026 Setup Guide

Why Prometheus + Grafana Is the Industry Standard

Every production Linux environment needs proper monitoring. Without it, you are flying blind — unable to detect performance issues, capacity problems, or security incidents until they cause downtime. In 2026, the Prometheus + Grafana stack remains the undisputed industry standard for open-source monitoring.

Prometheus collects and stores time-series metrics with a powerful query language (PromQL), while Grafana provides beautiful, interactive dashboards for visualization. Together, they give you complete visibility into your infrastructure.

Architecture Overview

The monitoring stack consists of these components:

  • Prometheus Server: Scrapes metrics from targets at regular intervals and stores them in its time-series database
  • Node Exporter: Runs on each Linux server and exposes system metrics (CPU, memory, disk, network)
  • Grafana: Connects to Prometheus as a data source and renders dashboards
  • Alertmanager: Receives alerts from Prometheus and routes them to email, Slack, PagerDuty, etc.

Step 1: Install Prometheus

Download and install Prometheus on your monitoring server:

# Create prometheus user
sudo useradd --no-create-home --shell /bin/false prometheus

# Create directories
sudo mkdir -p /etc/prometheus /var/lib/prometheus

# Download Prometheus (check for latest version)
wget https://github.com/prometheus/prometheus/releases/download/v2.53.0/prometheus-2.53.0.linux-amd64.tar.gz
tar xzf prometheus-2.53.0.linux-amd64.tar.gz

# Install binaries
sudo cp prometheus-2.53.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.53.0.linux-amd64/promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool

Configure Prometheus

Create the main configuration file at /etc/prometheus/prometheus.yml:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

alerting:
  alertmanagers:
    - static_configs:
        - targets:
          - localhost:9093

rule_files:
  - "alert_rules.yml"

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]

  - job_name: "linux_servers"
    static_configs:
      - targets:
        - "server1:9100"
        - "server2:9100"
        - "server3:9100"

Step 2: Install Node Exporter on Each Server

Node Exporter must run on every Linux server you want to monitor:

# Create user
sudo useradd --no-create-home --shell /bin/false node_exporter

# Download and install
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xzf node_exporter-1.8.0.linux-amd64.tar.gz
sudo cp node_exporter-1.8.0.linux-amd64/node_exporter /usr/local/bin/
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter

# Create systemd service
sudo tee /etc/systemd/system/node_exporter.service <<EOF
[Unit]
Description=Node Exporter
After=network.target

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

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter

Step 3: Install and Configure Grafana

# Add Grafana repository (Debian/Ubuntu)
sudo apt-get install -y 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 /etc/apt/sources.list.d/grafana.list

sudo apt-get update
sudo apt-get install -y grafana

sudo systemctl enable --now grafana-server

Access Grafana at http://your-server:3000. Default credentials: admin/admin (change immediately).

Add Prometheus as Data Source

  1. Go to Configuration → Data Sources → Add Data Source
  2. Select Prometheus
  3. Set URL to http://localhost:9090
  4. Click Save & Test

Step 4: Essential Dashboards

Import community dashboards for instant visibility:

  • Dashboard ID 1860: Node Exporter Full — comprehensive system metrics
  • Dashboard ID 11074: Node Exporter for Prometheus — clean, modern view
  • Dashboard ID 3662: Prometheus Overview — monitor Prometheus itself

Key Metrics to Monitor

MetricPromQL QueryPurpose
CPU Usage100 - (avg(rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)Overall CPU utilization
Memory Usage(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100RAM utilization percentage
Disk Usage(1 - (node_filesystem_avail_bytes / node_filesystem_size_bytes)) * 100Filesystem capacity
Network Inrate(node_network_receive_bytes_total[5m])Incoming bandwidth
System Loadnode_load1515-minute load average

Step 5: Configure Alerting

Create alert rules in /etc/prometheus/alert_rules.yml:

groups:
  - name: linux_alerts
    rules:
    - alert: HighCPUUsage
      expr: 100 - (avg by(instance)(rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 85
      for: 5m
      labels:
        severity: warning
      annotations:
        summary: "High CPU usage on {{ $labels.instance }}"

    - alert: DiskSpaceLow
      expr: (1 - (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"})) * 100 > 85
      for: 10m
      labels:
        severity: critical
      annotations:
        summary: "Disk space critically low on {{ $labels.instance }}"

    - alert: HighMemoryUsage
      expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 > 90
      for: 5m
      labels:
        severity: warning
      annotations:
        summary: "High memory usage on {{ $labels.instance }}"

    - alert: InstanceDown
      expr: up == 0
      for: 2m
      labels:
        severity: critical
      annotations:
        summary: "Instance {{ $labels.instance }} is down"

Production Best Practices

  • Retention policy: Set appropriate data retention (default 15 days, adjust based on storage)
  • Security: Never expose Prometheus or Grafana to the public internet without authentication
  • TLS: Enable TLS for all scrape targets and the Prometheus web UI
  • High Availability: Run two Prometheus instances scraping the same targets for redundancy
  • Service Discovery: Use file-based or DNS service discovery instead of static targets for dynamic environments
  • Labels wisely: Avoid high-cardinality labels that can explode your time-series count
  • Backup: Regularly back up Grafana dashboards and Prometheus configuration

Conclusion

A proper monitoring stack is not a luxury — it is a requirement for any production Linux environment. Prometheus and Grafana provide enterprise-grade monitoring capabilities completely free and open source. The setup described in this guide gives you full visibility into your infrastructure, proactive alerting, and beautiful dashboards that make troubleshooting efficient.

Start with a single server, expand to your entire fleet, and never be caught off guard by infrastructure issues again.

Share this article:

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.