2

I am using Grafana v8.3.4 with influxDB & I want to pass dynamic value to my notification for the query/alert condition. I couldn’t find any documentation for this. Can anyone suggest? enter image description here

This is what I have used: enter image description here

It alerts if the last() value is greater than threshold value. I want to dynamically pass the last() & Threshold value to the notification whose format is:

enter image description here Please suggest how it can be achieved.

Markus Meyer
  • 3,327
  • 10
  • 22
  • 35

1 Answers1

3

I'm not sure if I got your question but if you want to access the value in notifications/annotations you can use {{ $values.B0.Value }} where B is your query and 0 is the condition number. (In this case, that is 0 because you only have one condition.)

Annotations and labels for alerting rules

See example:

See example

Akshay's example:

Akshay's example

Alarm definition in grafana:

Alarm definition in grafana

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Luis Almeida
  • 101
  • 7
  • I have tried using above in template as well as in labels but I am not getting desired result. Could you suggest formatting for this. – JustAnotherNoob Jun 13 '22 at 09:25
  • @AkshayChavan See the image that I put in my comment, is this what you tried to do? – Luis Almeida Jun 13 '22 at 09:57
  • Yes I tried the same, but instead of getting the value I am getting {{ $values.B0.Value }} printed in notification. I am triggering notifications to MS teams, Could that be the cause of this? – JustAnotherNoob Jun 13 '22 at 12:00
  • Also, as you can see in the preview section I am getting Last() value as 610.4 . Can you suggest how to inject this value as well in my notification? – JustAnotherNoob Jun 13 '22 at 12:28
  • Well I am using v8.5.2, I am not sure if this feature is available in v8.3.4. If you are confortable with docker then it should be easy to install v8.5.2 and test if it's the version. Btw it shows as well {{ $values.B0.Value }} in my alarm section (see alarm definition img). In email notification shows the real number – Luis Almeida Jun 13 '22 at 14:18
  • 1
    Thanks , upgrading version helped with the issue. Appreciate the help!! – JustAnotherNoob Jun 14 '22 at 06:21
  • Can you suggest me on how to get the threshold value (which is 10 in condition B of my screenshot). – JustAnotherNoob Jun 14 '22 at 06:47
  • @AkshayChavan well since that value is a constant you can just type it in the notification. If you want a dynamic threshold you can redo your query and get the real value and subtract the dynamic threshold, then compare if it's above zero – Luis Almeida Jun 14 '22 at 09:26