How do you write a PromQL query for an SLO multi-window burn-rate alert?
AdvancedConceptPromQL & Recording Rules
Answer
For a 99.9% SLO (error budget 0.001), a fast-burn page at 14.4x on 1h and 5m windows:
(
job:slo_errors_per_request:ratio_rate1h{job="api"} > (14.4 * 0.001)
and
job:slo_errors_per_request:ratio_rate5m{job="api"} > (14.4 * 0.001)
)
The long window gives significance, the short window makes the alert resolve quickly once the issue stops. Pair with a slow-burn ticket (6x on 6h and 30m). Tools like Sloth or Pyrra generate these rules from an SLO spec.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate