Grafana alerting: Looking for exact value

Hi,

I have created a Grafana alert using Prometheus DB for HTTP response time when the value is greater than 0.05ms.
I am able to create the alert. But I also want it to display the exact value in the alert message. for ex; Response time is 0.06 which which exceeds the threshold of 0.05ms.

I have tried using this:
Response time for {{ index $labels “instance” }} is currently {{index $values “A” }} seconds, which exceeds the threshold of 0.05ms.

This doesn’t help. Can anyone fix this for me please?

Regards

Hi,

What do you mean by this doesn’t help? Where did you write the expression with templates? What is being sent in the message. Can you also screenshot the alert definition (in case of sensitive data you can cross it out).

This kind of templates (I think at least) should found its way in alert description or summary (the annotation and labels setting section).

Also… are you sure about the threshold? 0.05 ms sounds harsh for the person receiving the alert :smile:

Hey @dawiddebowski, Thank you so much for the response. By “this”, I meant the annotation that I tried. But it did not give me the expected result.

About the threshold, please suggest me if I can do better.:slight_smile:

Ok, the threshold is fine, the message might be a bit off - metric unit is second, not ms, so the threshold is 50ms, not 0.05ms :smile:
As for the annotation itself, it should work. After saving the alert, could you show the screenshot of the alert instance (wait for the first check, view alert and toggle one specific instance - the annotation should be templated into specific values)

In the screenshot, I can see B= some value. This is the value that I should be able to see in teh Alert message. where it says [no value]

The issue might (I’m not sure) be connected to the use of Classic Condition. What Grafana version are you using? In newer versions (8+), I’d suggest using Reduce and Threshold expression, since Classic Conditions get rid of the labels (hence the $labels.instance also returns no value). The $values.A.Value might be returning no value because it’s time series, not a single number. Since you’re using last function, you can change the query type from Range to Instant - you’d also query less data and Prometheus will thank you for that :smile:

To reiterate - Classic Condition (probably) makes it impossible to access instance label, while use of time series (probably) makes it impossible to access A value. In this case (if you don’t want to change anything) maybe using $values.B.Value would help (but instance label is still out of question imo)?