Grafana 8 - access alert info in message (ngalert)

I set up an alert rule in Grafana v8.0.1 using the new grafana 8 alerts. When I click preview your alert in the Create alert rule UI I get the following table:

State Info
Alerting [ metric=‘hostxzy’ labels={instance=hostxyz:1234, job=name} value=100 ]

How can I access the values from the Info column in the summary in the Add details for your alert section? I would like to include the instance and value entries in the alert message. (I’ve tried all kinds of combinations of {{}} and $, but didn’t get the values in the alert message)

Thank you for your help!

1 Like

Hi, it is supposed to be {{ $labels.your_label }} as explained here : Create Grafana managed alert rule | Grafana Labs

But I get the same problem than you, the label is empty when I do that…

using reduce and math as suggested here works.

1 Like

Thanks for the solution !
It works for labels, but how can I get the value that triggered the alert ? {{ value }} and {{ labels.value }} doesn’t work for me

1 Like

Did you ever find a way to get the value? I’m looking for the same.

We’ve recently merged a PR that will add this in 8.1 Alerting: Expand the value string in alert annotations and labels by gerobinson · Pull Request #37051 · grafana/grafana · GitHub

I have created a fresh, non-migrated alert rule, i am using reduce and math and can get all the labels in seperate columns in the alert preview. the query labels are automatically added to the custom labels too. I have installed Grafana 8.1.1 and i am able to access the value using {{values.[refid]}} in the custom labels section.

So it’s almost all well and good. However, I cannot use any of the labels and the value in the Summary field of or any of the annotations.

Neither {{$labels.your_label}} nor {{$values.[refid]}} work.They don’t seem to get interpreted at all, they will just get displayed as the literal strings they are.

I have found the issue myself. as soon as one of the self created labels is reference in the summary it breaks the whole parsing. only labels from the query are allowed in the summary

This topic was automatically closed after 365 days. New replies are no longer allowed.