Every team I have worked with has had the same two monitoring problems: either nobody knows the server is dying until a user complains, or everyone gets paged so often that nobody reads the alerts anymore. Both are the same failure — monitoring that was set up once and never designed.
Prometheus and Grafana are the default answer for a reason: Prometheus is boring, predictable, and free, and Grafana turns its numbers into something a human can read at 3 AM. But the default quickstart is not a production setup. This is the setup I run in production, and the one I would defend in a DevOps interview.
How Prometheus Actually Works
Prometheus does not wait for your servers to send it data. It scrapes them: every 15 seconds (by default) it makes an HTTP request to each target's /metrics endpoint and stores whatever comes back in its time-series database. That pull model is the whole design philosophy — if a target stops answering, Prometheus knows immediately, because the scrape itself fails. You never have to wonder whether silence means "healthy" or "dead".
Three concepts carry the whole system:
-
Metrics are named time series with labels:
node_cpu_seconds_total{mode="idle", instance="web-01"}. The name says what it is, the labels say which thing it belongs to. Labels are how you slice — by host, by service, by disk. -
Scrape configs in
prometheus.ymlsay what to scrape, how often, and with what timeout. A scrape interval of 15s is fine for servers; 5s is for people who enjoy paying for storage. -
Retention is a real decision, not a default. The default 15 days of local storage is fine for a lab. In production I set
--storage.tsdb.retention.time=90dand watch disk usage, because the day you need a metric from two months ago is the day you learn retention was 15 days.
# Is Prometheus actually scraping your targets?
curl -s http://localhost:9090/api/v1/targets | python3 -m json.tool | grep -E '"health"|"lastError"'
If a target shows health: down, fix the scrape before you write a single alert. An alert on a metric that was never collected is a lie you told yourself.
Exporters: What to Measure, and What to Ignore
Prometheus cannot see inside your server by itself. Exporters do that — small programs that expose metrics on an HTTP endpoint.
Start with two, and only two:
- node_exporter on every Linux host. It gives you CPU, memory, disk, network, and filesystem metrics. Install it as a systemd service, not in a container you might accidentally stop, and scrape it from a fixed port (9100).
- blackbox_exporter for probing from the outside: is the website actually up, does the TLS certificate expire soon, does DNS resolve? A server can report itself healthy while its service is down — blackbox is how you catch that.
The metrics that actually matter on a server, in order:
- CPU steal time on virtual machines — if steal is high, your neighbour is eating your CPU, and no amount of tuning your app will fix it.
-
Memory available, not memory free. Linux uses free memory for cache. Alert on
node_memory_MemAvailable_bytes, never on free. -
Disk space and disk IO latency. A disk at 95% is an incident in slow motion; a disk with high
iopswait is why your app feels slow. -
Network errors and dropped packets.
node_network_receive_drop_totalclimbing means the kernel is throwing traffic away.
Do not scrape everything because it exists. Every metric costs storage and attention. If nobody can say what action a metric triggers, do not collect it.
PromQL That Matters in Production
PromQL looks intimidating and is mostly three patterns:
# CPU usage across all cores, as a percentage
100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
# Memory available, in GB
node_memory_MemAvailable_bytes / 1024 / 1024 / 1024
# 95th percentile request latency, from a histogram
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))
Three rules that save you from the classic mistakes:
-
Always use
rate()on counters, never the raw value. A counter only ever goes up; the raw number tells you nothing.rate()over 5 minutes tells you what is happening now. -
Use
irate()only for fast-moving counters you are watching live. For alerts,rate()over 5m is steadier and pages you less. - Write recording rules for expensive queries. If a dashboard panel runs a heavy query every 30 seconds for every viewer, precompute it once with a recording rule and query the result. Your Prometheus will thank you at 2 AM.
Alerting: Alert on Symptoms, Not Causes
This is where most setups fail. A good alert answers three questions: what is broken for the user, how bad is it, and what do I do about it. "CPU is at 90%" answers none of those.
Alert on symptoms:
groups:
- name: server-alerts
rules:
- alert: ServerDown
expr: up == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Server {{ $labels.instance }} is down"
runbook: "Check power, network, and the node_exporter service. SSH first, then the hypervisor."
- alert: DiskFillingUp
expr: (node_filesystem_avail_bytes / node_filesystem_size_bytes) < 0.15
for: 30m
labels:
severity: warning
annotations:
summary: "Disk on {{ $labels.instance }} below 15%"
runbook: "Find the largest directories, rotate logs, extend the volume."
The for: clause is the difference between an alert and noise: 2 minutes of downtime is real, 10 seconds of it is a blip. And every alert needs a runbook link in its annotations — the person paged at 3 AM is not the person who wrote the rule, and they should not have to guess.
Alertmanager is where alerts become notifications: it groups them, silences duplicates, and routes by severity. Route critical to the on-call phone, warning to a chat channel, and nothing at all to email — email is where alerts go to be ignored. Set up inhibition rules so a ServerDown alert suppresses the twenty other alerts that server would have fired.
Grafana: Dashboards That Do Not Lie
Grafana is the part everyone sees, so it is the part everyone gets wrong. A dashboard with forty panels is not monitoring, it is wallpaper.
Build dashboards around the RED method for services (Rate, Errors, Duration) and the USE method for resources (Utilization, Saturation, Errors). One row per service, four panels per row, and nothing that nobody looks at during an incident:
- Rate: requests per second, right now.
- Errors: error rate as a percentage, with a threshold line at the SLO.
- Duration: p50, p95, p99 latency — never the average alone, because averages hide the users who are suffering.
- Saturation: CPU, memory, disk, and queue depth for the underlying host.
Two habits that separate a good dashboard from a pretty one: use template variables ($instance, $job) so one dashboard serves every server instead of one dashboard per server, and set the time range default to the last 1 hour — a dashboard that defaults to 30 days is a dashboard nobody uses in an incident.
Grafana alerting and Alertmanager are not the same thing. Use Alertmanager for infrastructure alerts that page people, and Grafana alerts for business thresholds on dashboards. Mixing them is how you get paged twice for the same incident.
Production Pitfalls Checklist
The failures I actually see, in order of frequency:
- Alerting on CPU percentage. A busy server is not a broken server. Alert on what users feel: errors, latency, downtime.
-
No
for:clause on alerts. Every restart, every deploy, every blip pages someone. They stop reading alerts within a week. - Scraping with no retention plan. Disk fills up, Prometheus stops, and you lose monitoring exactly when you need it. Set retention and a disk alert on Prometheus itself.
- Monitoring the monitoring, never. If Prometheus dies, who tells you? A second, tiny Prometheus — or a dead-man's-switch alert — is not optional.
- Labels with unbounded cardinality. A label with a user ID or a request path creates a new time series per value. Your TSDB grows until it falls over. Keep labels to a small, fixed set.
- Dashboards nobody owns. A dashboard written once and never updated lies quietly for months. Review dashboards monthly, delete the ones nobody opens.
-
Alerting on metrics that were never collected. A scrape target down for a week, an exporter that stopped after an upgrade — verify
up == 1before trusting any alert. - No runbook on the alert. The 3 AM version of you is not clever. Write down the first three commands to run.
What Hiring Managers Actually Ask
If you are targeting remote DevOps or sysadmin roles, this topic comes up because it reveals how you think about operations:
- "How do you know a server is down before users tell you?" (Answer: blackbox probing from outside,
up == 0alerts, and a dead-man's switch on the monitoring itself.) - "Your alert fires at 3 AM — what do you check first?" (Answer: the runbook, then whether the symptom is real, then the most likely cause in order.)
- "How do you stop alert fatigue?" (Answer: alert on symptoms, use
for:clauses, severity routing, inhibition, and delete alerts nobody acts on.)
The answer they want is never "I installed Prometheus". It is the design underneath: what you measure, what you alert on, and what you deliberately chose not to page anyone about.
The Monthly Monitoring Routine
My monthly routine takes twenty minutes:
- Check Prometheus disk usage and retention — is it on track to fill up?
- Review every alert that fired this month — which ones were real, which ones were noise, and delete or retune the noise.
- Open each dashboard and check the panels still show what they claim — dead queries lie silently.
- Verify the dead-man's switch: stop a test target and confirm the page arrives.
- Check exporter versions — an old node_exporter after a kernel upgrade stops reporting new metrics.
Do that, and monitoring stops being a dashboard you set up once and becomes a system you can trust at 3 AM. Monitoring is infrastructure: boring, named, tested, and never a surprise.
Your turn: What is the alert that pages you most often — and is it a real problem, or noise you have learned to ignore? Tell me in the comments.

Top comments (0)