Prometheus & Grafana cheatsheet
A one-page reference for metrics-based observability. For the full stack โ Alertmanager routing, Thanos/Mimir, logs, and APM tradeoffs โ see the complete guide.
๐ Full guide: Prometheus & Grafana โ IntermediateLearn this in 5 minutes5 min
- Begin with the Instant vs. range vector card
- Then the rate() vs irate() and Aggregation cards
- Treat the other 5 cards as lookups โ scan by card title when you need one
- Open the full guide when a card isn't enough
Instant vs. range vectorโ
http_requests_total # instant vector: one value per series, now
http_requests_total[5m] # range vector: samples over the last 5m
Range vectors feed into functions like rate() โ you can't graph one directly.
rate() vs irate()โ
rate(http_requests_total[5m]) # per-second avg โ use for alerts/dashboards
irate(http_requests_total[5m]) # last-two-points only โ noisy, ad-hoc only
Rule of thumb: window โฅ 4x the scrape interval, or you get NaN/wild swings.
Aggregationโ
sum(rate(http_requests_total[5m])) by (route)
sum(rate(http_requests_total{status=~"5.."}[5m]))
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
Golden signals / RED / USEโ
| Framework | Signals |
|---|---|
| Golden Signals | latency, traffic, errors, saturation |
| RED (services) | rate, errors, duration |
| USE (resources) | utilization, saturation, errors |
SLIs, SLOs, error budgetsโ
SLI: the measured indicator (e.g. % requests < 300ms)
SLO: the target (e.g. 99.9% over 30 days)
Error budget: 100% - SLO โ how much unreliability you can spend
Burn-rate alerts (fast + slow window) catch budget-draining incidents without paging on every blip.
Alertingโ
- alert: HighErrorRate
expr: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.05
for: 10m
labels: { severity: page }
Alertmanager handles routing, grouping, dedup, and silences on top of Prometheus's raw alert rules.
Grafana basicsโ
- Dashboards = panels, each backed by a PromQL (or other datasource) query.
- Variables (
$env,$instance) make one dashboard reusable across scopes. - Alerting can live in Grafana itself or be delegated to Alertmanager.
Long-term storage & logsโ
Thanos/Mimir/Cortex extend Prometheus retention beyond local disk with object-storage backends. Logs (ELK/EFK) and metrics are complementary โ metrics tell you something is wrong, logs tell you what.
See: Common Pitfalls