Managing servers without health metrics is like driving in the dark. Without monitoring CPU, disk, and memory usage, you will only discover infrastructure problems when your services are already down.
Below, we detail how to set up an observability solution using Prometheus and Grafana running on a VPS server. The Ubuntu install commands are in Grafana on a VPS.
1. What are Prometheus and Node Exporter?
Prometheus is a time-series database focused on metrics monitoring. To collect metrics from the server's operating system (such as RAM usage, CPU, and free disk space), we use a lightweight agent called Node Exporter.
The install with systemd, a service user, and the firewall is in Grafana on a VPS, pinned to Node Exporter 1.8.2. The agent listens on port 9100. Prometheus scrapes that port and keeps the history.
2. Configuring Grafana for Data Visualization
Grafana is the ideal tool to build graphical dashboards from the consolidated information in Prometheus.
The Configuration Workflow:
- Access the Grafana panel (default port
3000). - Add Prometheus as your Data Source.
- Import the official dashboard for Node Exporter (ID:
1860).
This template will visually display CPU usage, disk read/write rates, RAM consumption, and active network traffic volume in real time.
3. Queries worth an alert
In Grafana, open Explore with Prometheus selected. These three queries show CPU, free memory, and free disk on the root filesystem:
100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes
node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
/ node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
The first returns CPU percent. The other two return a fraction from 0 to 1. Disk under 0.15 is the alert that keeps the database from stopping on a full volume.
Prometheus rule, in /etc/prometheus/rules/disk.yml:
groups:
- name: disk
rules:
- alert: RootDiskLow
expr: |
node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
/ node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"} < 0.15
for: 10m
labels:
severity: warning
annotations:
summary: "Less than 15% free on {{ $labels.instance }}"
prometheus.yml has to load the rules folder:
rule_files:
- /etc/prometheus/rules/*.yml
Reload without dropping the scrape:
curl -sS -X POST http://127.0.0.1:9090/-/reload
--web.enable-lifecycle has to be on the Prometheus service, as in the install guide. An empty body with HTTP 200 means the reload was accepted.
When the dashboard has no series
- A target
DOWNathttp://127.0.0.1:9090/targetsmeans the exporter is stopped or the scrape uses the wrong port. An empty Grafana panel is the consequence. - A query that works in Prometheus and not in Grafana is a datasource on another URL, or a graph range outside the time of the samples.
up == 0for more than one scrape in a row is an incident. A single gap while the exporter boots is not. Reload the configuration withPOSTtohttp://127.0.0.1:9090/-/reload.
Conclusion
Having a Prometheus and Grafana dashboard configured is the first step toward achieving professional systems observability. With alerts configured from these metrics, you can predict hardware failures and act preventatively before any application suffers from downtime.