Prometheus and PromQL 3 cheatsheet

Prometheus and PromQL 3: Selecting data

5 common Prometheus and PromQL 3 tasks.

Select a metric

Return the current value of every series with this metric name.

http_requests_total

Filter by labels

Match labels exactly with = and !=, or by regular expression with =~ and !~.

http_requests_total{job="api", status=~"5..", method!="OPTIONS"}

Select a range of samples

Return the samples from the last five minutes. Range vectors are the input to functions such as rate.

http_requests_total{job="api"}[5m]

Look back in time

Compare with the value from an hour ago.

http_requests_total offset 1h

Find targets that are down

The up metric is 1 when the last scrape worked and 0 when it failed.

up == 0

Was this page helpful?