Grafana 9.4 metric variable (influxdb) regexp not expanded


  • What Grafana version and what operating system are you using?
    Grafana v9.4.3 (cf0a135595) on Debian11 , installed from packages (upgraded from 9.3)

  • What are you trying to achieve?
    To use variable “$m” in “Alias” field . With Grafana <9.4 this returns series of metric names found in InfluxDB . In 9.4 it always returns just my regex string I use to search metric instead of expected metric names.

  • How are you trying to achieve it?
    This is how my example query made in visual editor is translated to text query:
    SELECT moving_average(mean("value"), $mvavg) FROM "$agg"./netdata.system.load.*/ WHERE ("host" =~ /^$host$/) AND $timeFilter GROUP BY time($__interval), "host" fill(null)

In visual editor I have $m in Alias field.

Expected is to have in variable $m the metric name found in IndluxDB - .e.g. “netdata.system.load.load1” for each metric found .

Currently I just see just 3 occurrences of metric “/netdata.system.load.*/” (there are 3 metrics in InfluxDB: load1, load5 and load15)


P.S. I have just noticed that with Grafana 9.4 , now also character “@” is probably taken as part of variable name, so when I want to continue use Alias field “$m@$tag_host” as I did in 9.3 it won’t work neither - it returns “$m@myhost” instead of “netdata.system.load.load1@myhost” . It’s not much and issue as I can use other separator, but I’m mentioning it as this might be related.

Well I found a solution, now the metric name reside in variables $0 $1 $2 … $n , while it is basically expanded metric name by dot character separator.

Example metric fetched via /^netdata.apps.pwrites.*/ :
netdata.apps.pwrites.sql is expanded as:
$0 - netdata
$1 - apps
$2 - pwrites
$3 - sql

So in my case I can use $3 in Alias field :+1:

1 Like