Template variables are not supported in alert queries

While setting alarm for CPU usage in grafana, facing below error


Please help me

The error is saying that template variables (the dropdowns that are used to dynamically change the query - maybe a list of servers in your case?) are not supported in queries that are used for alerting. To get alerting to work you will have to remove any template variables from your query.

This means you will either have to have multiple panels - one per template variable value per panel or use regex instead of the template variable.

There is a feature request for this but no-one has come up with a good solution so far (template variables based on a query can be very dynamic which makes it difficult to implement for alerting):

1 Like

Hi guys ,

Would it be possible to give an example on how to avoild template variables in Grafana queries

You can have two queries, one with template variables and one whitout them.
Then, hide the results from the metric without template variables (it is not showed in the graph but the results are still there)

And in the alert, use the query without template variable

So, you can filter the results from th graph with that variable, but the alert only works with the metric without variables
(Sorry for bad english)