Grafana Linux Monitoring

Every Linux server hides a story in its numbers: how hard the processor works, how much memory remains, how full the disk grows, and how much data crosses the network. This project builds a complete server dashboard from scratch with Node Exporter, Prometheus, and Grafana. The result gives you a live health check for any Linux machine.

The Car Dashboard Analogy

A car dashboard shows speed, fuel, engine temperature, and warning lights. Drivers glance at it and know whether the trip is safe. A Linux monitoring dashboard does the same for a server. CPU acts as the speedometer, disk space acts as the fuel gauge, and alerts act as the warning lights.

+-------------+   metrics   +------------+   queries   +---------+
| Linux       | ----------> | Prometheus | ----------> | Grafana |
| Node        |   port 9100 | (stores    |             | (draws  |
| Exporter    |             |  history)  |             |  charts)|
+-------------+             +------------+             +---------+

The Three Tools

  • Node Exporter runs on the server and publishes hardware and operating system numbers on port 9100.
  • Prometheus visits the exporter every few seconds and stores the numbers.
  • Grafana asks Prometheus for the history and draws it.

Install Node Exporter

Download the release for your platform from the Prometheus project, unpack it, and start it. Production servers run it as a service, so it restarts after a reboot.

./node_exporter

Open http://SERVER_IP:9100/metrics in a browser. A long text page of metrics confirms success.

node_cpu_seconds_total{cpu="0",mode="idle"} 184523.4
node_memory_MemAvailable_bytes 3.1e+09
node_filesystem_avail_bytes{mountpoint="/"} 4.2e+10

Tell Prometheus Where to Look

Add a scrape job to the Prometheus configuration file.

scrape_configs:
  - job_name: "linux-servers"
    static_configs:
      - targets: ["192.168.1.10:9100", "192.168.1.11:9100"]

Restart Prometheus and open its Targets page. Each server should show the state UP.

Connect Grafana

Add Prometheus as a data source with the address of your Prometheus server, such as http://prometheus:9090. Click Save and test.

Import a Ready-Made Dashboard

The Grafana community shares thousands of dashboards. Open Dashboards, choose New, and select Import. Type the ID 1860, which belongs to the popular Node Exporter Full dashboard, and pick your Prometheus data source. A full server dashboard appears in seconds. Study its panels to learn good design, and build your own simplified version below.

Build Your Own Panels

CPU Usage

100 - (avg by (instance) (
  rate(node_cpu_seconds_total{mode="idle"}[$__rate_interval])
) * 100)

The query measures the idle share of the processor and subtracts it from 100. Use a time series panel with the unit Percent (0-100).

Memory Usage

(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100

Show it in a gauge panel with thresholds at 70 and 90.

Disk Usage

100 - (node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"}
     / node_filesystem_size_bytes{fstype!~"tmpfs|overlay"} * 100)

A bar gauge shows each mount point as a bar, so a nearly full disk jumps out.

Network Traffic

rate(node_network_receive_bytes_total{device!="lo"}[$__rate_interval])

Draw it in a time series panel with the unit bytes/sec. Add a second query with node_network_transmit_bytes_total to show outgoing traffic.

Uptime

time() - node_boot_time_seconds

A stat panel with the unit seconds (duration) shows the time since the last restart.

Add a Server Selector

Create a variable named instance of type Query with the query label_values(node_uname_info, instance). Add {instance="$instance"} to each query. One dashboard now serves every server in the list.

Suggested Layout

+--------+--------+--------+--------+
| Uptime | CPU %  | Memory | Disk % |   <-- stat and gauge row
+--------+--------+--------+--------+
|  CPU over time   | Memory over time|
+------------------+-----------------+
|  Disk by mount   | Network in/out  |
+------------------+-----------------+

Add Alerts

AlertConditionPending Period
High CPUCPU above 90 percent10 minutes
Low memoryMemory above 90 percent10 minutes
Disk almost fullDisk above 85 percent15 minutes
Server downPrometheus metric up equals 02 minutes

Security Notes

  • Allow port 9100 only from the Prometheus server through the firewall.
  • Run Node Exporter under a dedicated low-privilege user.
  • Place Grafana behind HTTPS.