I new from Grafana alert. I want to make a alert in grafana OSS
I have try something like this
W_W{location="ABC", device_SN="ABC"}
and it probaly work. But it not is my main idea. I want to make a alert using query have variable like this.
W_W{location="$location", device_SN="$device"}
with
location = "ABC"
device = "ABC"
And in alert template it warning me
Template variables are not supported in alert queries
Is there anyway to make it work ?
Grafana ver: 8.3.3
Currently it is not possible to use template variables in alert queries.
There have been long discussions about this topic. Some users insist that this feature is needed, at least for constants if not for variables. On the other hand is it easy to use regular expressions in the queries itself and each alarm can have several alarm instances depending on the matching conditions.
If you have a close look at template variables, ask yourself: "Where do I set the value of the variable?" You temporarily choose one value that will be used temporarily in a Dashboard. Alerts work different as they should work independent from any user action.
The second use case of template variables is repetition of panels. Often the list is the result of a query. The corresponding use case for an alarm would be alarm instances. So in fact, the variable might be useful, but a variable is not really necessary.
See