SLO Error Ratio in PromQL

Aggregate event counts before division. Averaging per-instance percentages gives an idle instance the same influence as a busy one.

Observability · PromQL

SLO Error Ratio

An SLI is valid only when errors and totals describe the same event population.

sum(rate(http_requests_total{service="api",code=~"5.."}[5m]))
/
sum(rate(http_requests_total{service="api"}[5m]))
-- Alert with both a fast and slow burn window to control noise.

Invariant: Errors and total requests cover the same population and time window.

Use when: You need a traffic-weighted availability signal rather than an average of percentages.

Why this boundary matters

Averaging percentages weights idle and busy instances equally. Aggregating event rates first preserves the traffic-weighted user outcome.

Failure policy

BoundaryAction
5xx response in the SLI populationCount in both error and total series
Excluded request classExclude it consistently from numerator and denominator
No trafficTreat the ratio as absent, not perfect availability
Labels differ between termsFix the query before alerting
Low traffic windowUse longer windows or event-count safeguards

Trade-offs

A ratio is traffic-weighted and honest at scale, but low-volume services produce noisy percentages. Aggregation can hide one tenant or region, while excessive labels make metrics expensive.

Decision rule: Use an error ratio when the numerator and denominator describe the same user-visible population and enough events exist to support the conclusion.

Further reference

Browse all engineering snippets · Read about error budgets

>