Intermediate By Samson Tanimawo, PhD Published Sep 30, 2026 5 min read

PromQL Essentials Cheat Sheet

Twenty patterns cover 90% of dashboards. Memorise these and you'll write better queries than most teams' grafana folders.

Rates and counters

Counters only go up. You almost always want a per-second rate, not the raw value. Pick the function that matches your scrape interval.

Aggregation

by keeps the listed labels and drops everything else. without drops the listed labels and keeps everything else. Always be explicit, the default of dropping all labels is rarely what you want.

Histograms and quantiles

Histograms are pre-bucketed. histogram_quantile turns buckets into percentiles. Forgetting le in the by clause is the most common PromQL bug.

Label tricks

The label functions feel obscure until the day you need them, and then they're the only thing that works.

Time shifts

Compare now to a week ago without writing two queries.

Alert-shaped queries

Patterns that translate cleanly into Alertmanager rules.