When a PromQL availability query uses a ratio where the numerator filters for 5xx errors, it returns no data instead of 100% when services are healthy — because PromQL produces an empty vector when no matching series exist. The fix is the `* 0` fallback pattern: use `or metric{...} * 0` in the numerator so a zero-valued series with correct labels is always present. This avoids the pitfalls of `vector(0)` (which loses labels), `clamp_min` (which only floors existing series), and `absent()` (which doesn't preserve labels in grouped queries). The pattern generalizes to any PromQL ratio where the numerator can legitimately be empty.

5m read timeFrom last9.io
Post cover image
Table of contents
The SetupThe ProblemWhy PromQL Works This WayThe Fix: The * 0 Fallback PatternOther ApproachesThe General PatternBuild SLIs That Hold Up in Production

Sort: