Basic PromQL Querying

All Topics

One-to-One Matching

One-to-One Matching

on() — match only on specific labels.

method_code:http_errors:rate5m{code="500"}
  / ignoring(code)
method:http_requests:rate5m

ignoring() — exclude specific labels from matching. Without ignoring(code), the query above would fail because code exists only on the left side.

Example: error rate ratio. Calculate 500-error rate as a fraction of total request rate:

sum without(status)
  (rate(http_requests_total{job="demo",status="500"}[5m]))
/
sum without(status)
  (rate(http_requests_total{job="demo"}[5m]))

By aggregating away status on both sides, the labels match and the division works correctly.