Grafana: 'Template variables are not supported in alert queries' using query have variable

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"}


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

@nhatmicls in grafana 8 alerting, the alerts are separate from the dashboards - but even in earlier versions template variables weren’t supported.

Grafana 8 alerts do have a feature called a multi-dimensional rule that will evaluate each series that matches the alert query with a separate alert. You can read more about those here