Grafana alerting with variables : It's possible with grafana 8 or 9?

Hello all,

I try to configure alerting in Grafana .
I noticed that the template variables are not supported in alerting queries.

Currently I am using version v7.5.13 of Grafana.
I eventually read that version 8 or 9 could manage this. Maybe with multi dimensional alerting or unified alerting.

Do you have any advice ?
My query where I would like to have alerting is :

SELECT value FROM “rx_port” WHERE (“switch” =~ /^$SanSW$/) AND $timeFilter GROUP BY “port”, “switch”

Thanks & regards,

hi @speedblack :wave:

since there are different ways we can use variables in unified alerting, can you please elaborate on what you expect to see if you used variables? Do you want to use them in annotations, or perhaps in notifications,…?

also, what is your datasource?

btw @speedblack , you can always sign up for the free Grafana Cloud instance and finally add your datasource there and test out the Grafana 9 alerts without setting up a new instance locally.

Hello @antonio.merello ,

Thank you for your reply & my apologies for the late reply !

The purpose of using variables is that I have many SanSwitches and without the filter “WHERE (“switch” =~ /^$SanSW$/)” all the ports are mixed as they have identical numbers (several 1, 2, 3…). The goal is to filter in order to receive an alert for each port in the case of a threshold being exceeded.

The query “SELECT “value” FROM “rx_port_sansw” GROUP BY “port”, “ip_switch”” without the filter allows alerting to work but I can’t know which SanSwitch port is linked to.

The datasource is InfluxDB.
I can’t use Grafana Cloud instance unfortunately.

Do you think that multi dimensional alerting or unified alerting can manage this?

Thansk & regards,

Hi @speedblack

Sorry for the late reply too

Unified alerting was introduced in grafana 8, and it is the tool itself, whereas “multi dimensional alerting” is not a separate alerting tool but a way to generate a separate alert for each series returned by a database.

You could alternatively run Grafana 8 or 9 on a docker container and have a look how multi dimensional alert rules work.

@speedblack

You can also sign up for free InfluxDB cloud to run the latest (currently v2.6) with Flux. Then (along with Grafana Cloud v9.3) you can play around with the multidimensional alerts using Flux. I wrote a tutorial here.

1 Like