How to use query fields in the alarm message

Hi all, I am using grafana 8 with ngalert but I cannot modify the alarm message as I would like. I try to summarize:

I have a query like this:
From influx db:
SELECT “measure_value” FROM “my_table” WHERE $timeFilter GROUP BY “Device”. Format as TimeSeries.

By creating a simple alarm when it goes into firing I read it via API (/api/alertmanager/grafana/api/v2/alerts/?filter=alertname=MyAlert):
In the labels field of the answer I see this:

“labels”: {
alert_rule_uid”: “B8wANWmnk”,
value”: “[ metric=‘my_table.measure_value{ Device: DeviceName }’ labels={Device=DeviceName } value=12.09125 ]”,
“alertname”: “MyAlert”
}

But what I would like to get is to have in the Summary or some other field the value: DeviceName (ie the name of the device that triggered the alarm.)

I am trying in a thousand ways without succeeding. Can anyone help me please?

Have you had a look at the templating doc? Message templating | Grafana Labs

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