Introduction
Something is wrong in production, and nobody can say what changed or how bad it is. Monitoring turns that moment from a panic into a routine. Prometheus and Grafana are the default open-source stack for the job: Prometheus collects the numbers, Grafana turns them into dashboards you can read at 3 a.m. This tutorial builds the whole stack on one Linux machine. You should be comfortable on the command line — see our Linux Commands for DevOps Engineers.
Version note (27 Nov 2026): Prometheus 3.16.0 (4 Nov 2026); LTS 3.13.5 (21 Oct 2026, supported to 31 Jul 2027). Node Exporter 1.13.1 (19 Nov 2026, superseding 1.12.1). Grafana latest stable 13.3.2 (24 Nov 2026) — the 13.4.0 builds on Grafana’s download page are nightly builds, not stable releases. Alertmanager 0.35.1 (24 Nov 2026).
What Prometheus and Grafana Actually Do (and What Each One Does NOT Do)
Prometheus is a metrics system that works by pulling: every 15 seconds by default, it requests the current numbers from each target at a /metrics endpoint and stores them in its own time-series database. You query that data in PromQL.
An exporter exposes metrics Prometheus cannot scrape directly: Node Exporter reads CPU, memory, disk and network numbers from the Linux kernel and serves them on port 9100.
Grafana is the visualisation layer: it stores no metrics, queries Prometheus, and draws graphs and gauges.
Prometheus is not a log store (that is Loki or Elasticsearch), not a tracing system (that is OpenTelemetry), and not long-term storage — by default it keeps 15 days of data on one machine. Grafana does not collect anything — if a panel shows “No data”, the problem is almost always Prometheus or the target. And neither tool fixes anything.
Installing the Stack (Prometheus + Node Exporter + Grafana)
Everything here runs on one Ubuntu or Debian machine: Prometheus 9090, Node Exporter 9100, Grafana 3000, Alertmanager 9093. Create a system user for each service, then download the releases and verify the checksums:
sudo useradd --system --no-create-home --shell /usr/sbin/nologin prometheus sudo useradd --system --no-create-home --shell /usr/sbin/nologin node_exporter sudo mkdir -p /etc/prometheus /var/lib/prometheus sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus cd /tmp PROM=3.16.0 NODE=1.13.1 curl -LO https://github.com/prometheus/prometheus/releases/download/v$PROM/prometheus-$PROM.linux-amd64.tar.gz curl -LO https://github.com/prometheus/node_exporter/releases/download/v$NODE/node_exporter-$NODE.linux-amd64.tar.gz sha256sum prometheus-$PROM.linux-amd64.tar.gz # expect 68727009472a2c02e1ff7f062fd5b3e637285bffc8fc2d340c76fb449d6e0f34 sha256sum node_exporter-$NODE.linux-amd64.tar.gz # expect 5c00c5234f1ee45900b25539a5a0ab82146a098c15c16a4ec3bc855b597a6477
If a checksum does not match, download it again:
tar xzf prometheus-$PROM.linux-amd64.tar.gz tar xzf node_exporter-$NODE.linux-amd64.tar.gz sudo install -m 0755 prometheus-$PROM.linux-amd64/prometheus prometheus-$PROM.linux-amd64/promtool /usr/local/bin/ sudo install -m 0755 node_exporter-$NODE.linux-amd64/node_exporter /usr/local/bin/
Now write /etc/prometheus/prometheus.yml — the one file the whole stack revolves around:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node"
static_configs:
- targets: ["localhost:9100"]
scrape_interval is how often Prometheus pulls metrics; evaluation_interval is how often it re-evaluates rules. static_configs lists targets by hand; production uses service discovery instead. Validate it with promtool:
sudo -u prometheus promtool check config /etc/prometheus/prometheus.yml
Create the systemd unit /etc/systemd/system/prometheus.service:
[Unit]
Description=Prometheus
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus/ \
--storage.tsdb.retention.time=30d
[Install]
WantedBy=multi-user.target
--storage.tsdb.retention.time=30d keeps 30 days instead of the 15-day default. Retention is a start-up flag — the Prometheus storage documentation recommends a size cap (--storage.tsdb.retention.size=50GB) too. The Node Exporter unit is the same shape:
sudo systemctl daemon-reload sudo systemctl enable --now prometheus node_exporter curl -s http://localhost:9100/metrics | head -5
Install Grafana from its official APT repository (Grafana installation documentation):
sudo apt-get install -y apt-transport-https wget gnupg sudo mkdir -p /etc/apt/keyrings sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key sudo chmod 644 /etc/apt/keyrings/grafana.asc echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list sudo apt-get update sudo apt-get install grafana sudo systemctl enable --now grafana-server
Open http://localhost:3000, log in with admin / admin, and change the password when Grafana asks — the default login is public knowledge. Finally, check http://localhost:9090/targets: both jobs should show UP.
Your First Metrics and PromQL Queries
Open http://localhost:9090 and click Graph. The simplest query you can run is:
up
up is a metric Prometheus generates itself for every target: 1 if the last scrape succeeded, 0 if it failed.
One idea explains most PromQL confusion: counters only ever go up. node_cpu_seconds_total counts total CPU seconds since Node Exporter started, resetting only on restart. The raw number is meaningless; the *rate of change* is the metric. That is what rate() computes:
rate(node_cpu_seconds_total[5m])
The [5m] is a range vector selector. Two rules: always use rate() on counters, never the raw value, and keep the window at least four times your scrape interval.
CPU usage as a percentage:
100 * (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m])))
Memory usage:
100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes))
Disk usage:
100 * (1 - (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"}))
Network traffic:
sum by (instance) (rate(node_network_receive_bytes_total[5m]))
Curly braces filter by label: {mode="idle"} keeps idle-mode CPU series, {mountpoint="/"} keeps the root filesystem. avg and sum by (instance) are aggregation operators. And node_load1 — the one-minute load average — is a gauge, so query it directly with no rate().
Building a Grafana Dashboard
Go to Connections → Data sources → Add data source, choose Prometheus, set the URL to http://localhost:9090, and click Save & test.
Build a dashboard: Dashboards → New → New dashboard → Add visualization, select Prometheus, and add a panel per query — CPU, memory, disk, network. Set the refresh to 30 seconds or 1 minute.
Three habits save real time. First, template variables: add an instance variable (label_values(up, instance)), use $instance in your queries, and the same dashboard works for every server. Second, thresholds: a memory panel that turns red above 90%. Third, import before you build: the community Node Exporter Full dashboard (ID 1860) — Dashboards → New → Import, enter 1860, select your data source, click Import. Keep your own dashboard too.
Alerts That Wake You Up
A dashboard nobody watches is a screensaver. Alerts act while you are asleep — and they are where beginners cause the most damage, by alerting on everything and training themselves to ignore all of it. Alert on symptoms users feel, not on every number that moves.
Alerting has three pieces: rules in Prometheus, which decide when something is wrong; Alertmanager, which routes firing alerts; and a receiver — email, Slack, PagerDuty — which reaches a human.
In /etc/prometheus/rules.yml, a recording rule precomputes an expensive query as a new metric, and an alerting rule fires when an expression stays true for a set time:
groups:
- name: node
rules:
- record: instance:node_cpu_utilisation:ratio5m
expr: 1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))
- alert: InstanceDown
expr: up == 0
for: 5m
labels:
severity: page
annotations:
summary: "Instance {{ $labels.instance }} is down"
- alert: HighCpuUsage
expr: instance:node_cpu_utilisation:ratio5m > 0.85
for: 10m
labels:
severity: warning
annotations:
summary: "High CPU on {{ $labels.instance }}"
- alert: DiskFillingUp
expr: predict_linear(node_filesystem_avail_bytes{mountpoint="/"}[1h], 4 * 3600) < 0
for: 30m
labels:
severity: page
annotations:
summary: "Disk on {{ $labels.instance }} will fill within 4 hours"
Three details matter. for: 5m means the condition must hold for five minutes before firing — without it, one missed scrape pages you for a 15-second blip. HighCpuUsage reuses the recording rule: compute once, use everywhere. DiskFillingUp uses predict_linear to warn days before the disk fills. severity: page wakes someone up; severity: warning waits.
Validate the rules, then add them to prometheus.yml:
sudo -u prometheus promtool check rules /etc/prometheus/rules.yml
rule_files:
- /etc/prometheus/rules.yml
alerting:
alertmanagers:
- static_configs:
- targets: ["localhost:9093"]
Then write /etc/prometheus/alertmanager.yml (use a real mail server):
global:
resolve_timeout: 5m
route:
group_by: ["alertname", "job"]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receiver: "team-email"
receivers:
- name: "team-email"
email_configs:
- to: "oncall@example.com"
from: "alertmanager@example.com"
smarthost: "smtp.example.com:587"
The timing settings are the whole art of Alertmanager: group_wait: 30s groups related alerts, group_interval: 5m batches follow-ups, and repeat_interval: 4h re-sends a still-firing alert every four hours.
Restart Prometheus, start Alertmanager, then test it: stop Node Exporter, wait five minutes, and watch the Alerts page move from inactive to pending to firing, then resolve when you start Node Exporter again.
What to Monitor in Production
Monitor the four golden signals — latency, traffic, errors and saturation. Node Exporter answers saturation for a host; for an application, the same four come from its own metrics.
Use the right exporter for each layer. Hosts get Node Exporter; databases and queues get their own. Kubernetes gets kube-state-metrics and cAdvisor; our Kubernetes Tutorial for Beginners covers the cluster side, and the Prometheus Operator is the standard way to run this stack on Kubernetes. One Prometheus with static_configs stops working at about a dozen machines; service discovery replaces it there.
Plan retention before the disk fills. The 15-day default is a lab setting; thirty days on local disk covers most investigations, and anything longer belongs in remote storage via remote write — Thanos, Mimir and Cortex. At roughly 1–2 bytes per sample, retention in seconds × samples per second × 2 bytes is your disk budget.
Run Prometheus like production software: a pair of Prometheus servers scraping the same targets, an Alertmanager cluster, and monitoring the monitoring — alert on up{job="prometheus"} == 0, because a silent monitoring outage is worse than none. Secure the stack behind a reverse proxy with HTTPS and authentication.
Common Beginner Mistakes
- Alerting on CPU percentage alone. High CPU is usually a symptom of load, not a failure.
- No
forclause on alerts. A rule withoutforfires on a single bad scrape. - Scraping too often. A 5-second interval quadruples the data of a 15-second one. Start at 15 seconds.
- Cardinality explosions. A label with unbounded values — user IDs, request paths — creates a new series per value, and Prometheus memory grows with series count.
- Leaving Grafana on
admin/admin. Change the default password on first login, and do not expose port 3000 to the internet without authentication in front of it. - Forgetting retention. The 15-day default deletes data silently. If you need a month, set it — with a size cap.
FAQ
Do I need both Prometheus and Grafana, or is one enough? You need Prometheus to collect and store metrics; Grafana alone has nothing to show. Prometheus alone works for debugging one query, but it is a poor team dashboard.
Is Prometheus a replacement for log management? No. Prometheus stores numbers over time; logs are text events. Metrics tell you *when* something went wrong and *how bad* it was; logs tell you *why*. Teams commonly pair Prometheus with Grafana Loki for log search.
How much disk will Prometheus use? Roughly 1–2 bytes per stored sample, so one target uses tens of megabytes a day. It grows with targets and series per target.
Can I monitor Windows servers or Docker containers with this stack? Yes. Windows Exporter is the Windows equivalent of Node Exporter, and container metrics come from cAdvisor, built into the kubelet and the Docker daemon.
How do I keep metrics longer than 15 days? Raise --storage.tsdb.retention.time for local history up to a few months, and add remote write to Thanos, Mimir or Cortex for longer — and set --storage.tsdb.retention.size too.
Conclusion
You now have a complete monitoring stack: Prometheus 3.16.0 scraping host metrics from Node Exporter 1.13.1, PromQL queries for every host dashboard, a Grafana 13.3.2 dashboard, and alerting rules wired through Alertmanager 0.35.1.
Next, point this stack at something real — your own server, or a Kubernetes cluster from our Kubernetes Tutorial for Beginners. Let it run for a week, and tune the alerts until every notification is one you would act on. And if you are building these skills towards a job, our DevOps Engineer Roadmap 2026 lays out the order, with monitoring in the middle: after Linux and containers, before on-call.
Sources checked 27 Nov 2026: Prometheus download page at prometheus.io/download (3.16.0, 4 Nov 2026; LTS 3.13.5, 21 Oct 2026; Node Exporter 1.13.1, 19 Nov 2026; Alertmanager 0.35.1, 24 Nov 2026); Prometheus LTS page (3.13 supported to 31 Jul 2027); Prometheus storage documentation; Prometheus alerting tutorial; Grafana installation documentation; Grafana release trackers (13.3.2 stable; 13.4.0 nightly only). Re-check versions before publishing.
—
