How to not evaluate alert expression(Expr) when there is no data in Prometheus metric

15 views
Skip to first unread message

akshay sharma

unread,
Jan 22, 2021, 2:45:44 PM1/22/21
to Prometheus Users
Hi,

I'm trying to raise an alert on metric(metric_test). Evaluation interval is every 5mints.

Issue:

Suppose, At time(T1) alert is fired and prometheus scrapes metric at time(t3) but there is no metric with name metric_test at target during that time, prometheus will update as no data as shown below. In Prometheus GUI -> Graph, when you query for metric like below , it is showing no data.

Metric_test

no data

at time(t5) evaluation of alerts happens, due to "no data" it is marking alerts as resolved. I don't want evaluation of alert expressions to happen when there is no data .

How can we avoid that?


Bjoern Rabenstein

unread,
Feb 5, 2021, 8:09:13 AM2/5/21
to akshay sharma, Prometheus Users
You kind of have to evaluate the expression to find out that the
evaluation results in "no data".

Would the `absent` function perhaps help in your case?
https://prometheus.io/docs/prometheus/latest/querying/functions/#absent

--
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] bjo...@rabenste.in
Reply all
Reply to author
Forward
0 new messages