What does `absent()` do and why is it important for alerting?
IntermediateConceptPromQL & Recording Rules
Answer
absent(v) returns a single series with value 1 when the selector matches nothing, and nothing otherwise. Normal alerts cannot fire on missing data, because x > 0 on no data is simply no result.
absent(up{job="payments-api"})
absent_over_time(backup_last_success_timestamp_seconds[2h])
Use it to catch "the exporter vanished" or "the job was renamed and all alerts went silent".
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