Monitoring
Solutions
Resources
Free Tools
Pricing
Free Tools / On-call & alerting / PromQL Builder & Cheat Sheet

PromQL Builder & Cheat Sheet

Pick what you want to know about a metric and the builder writes the PromQL, with a plain-English explanation. Below it: a cheat sheet of the queries people look up most.


Runs entirely in your browser — nothing you enter here is sent to a server.

PromQL cheat sheet

The patterns below cover most dashboards and alerts. Replace the metric and label names with your own.

GoalQuery
Requests per secondsum(rate(http_requests_total[5m]))
Requests per second, per servicesum by (service) (rate(http_requests_total[5m]))
Error percentage100 * sum(rate(http_requests_total{code=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))
p95 latencyhistogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))
CPU usage, %100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100
Memory used, %100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)
Disk full in 4 hourspredict_linear(node_filesystem_avail_bytes[1h], 4 * 3600) < 0
Target is downup == 0
Top 5 by request ratetopk(5, sum by (handler) (rate(http_requests_total[5m])))
Restarts in the last hourincrease(kube_pod_container_status_restarts_total[1h]) > 0
Series count per metrictopk(10, count by (__name__) ({__name__=~".+"}))

Rules that prevent most PromQL mistakes

rate() first, then sum()

sum(rate(x[5m])) is right. rate(sum(x)[5m]) breaks on counter resets and is not valid without a subquery.

Counters need rate, gauges do not

A raw counter only goes up and tells you nothing. A gauge is already a current value; use the *_over_time functions on it.

Range ≥ 4× scrape interval

rate() needs at least two samples in the window. With a 30-second scrape, use [2m] or more; [5m] is a safe default.

Keep "le" for histograms

histogram_quantile() needs the bucket boundary label. Aggregate with sum by (le, …), never plain sum.

Frequently asked questions

What is the difference between rate() and irate()?

rate() averages over the whole range and is stable, which makes it right for alerts and most graphs. irate() uses only the last two samples, so it reacts instantly but is noisy; use it for zoomed-in graphs.

What is the difference between rate() and increase()?

They are the same calculation in different units. rate() gives the per-second average; increase() gives the total growth over the range, which is rate multiplied by the range in seconds.

How do I calculate a percentile in PromQL?

Use histogram_quantile() on the rate of the metric's _bucket series, keeping the le label in the aggregation: histogram_quantile(0.95, sum by (le) (rate(metric_bucket[5m]))).

Why does my query return no data?

Check the label matchers first — a mistyped label value matches nothing without an error. Then check that the range is at least twice the scrape interval and that the target is still being scraped (up == 1).

Related free tools

A calculator answers once. Monitoring answers every minute.

Upzilla checks your sites, servers and APIs around the clock and alerts you the moment something breaks. 10 monitors free, no card required.

Start monitoring free →