Influxdb : usage of template variable for field selection

Hello

while I an create a variable to list avaialble field in an influxdb ( show field keys on db.rp.measurement)

I’m unable then to use it in the metrics :

the select :
“SELECT “rssi” FROM “autogen”.“mqtt_consumer” WHERE (“app” =~ /^FS_trak$/ AND “devaddr” =~ /^0024E63E$/) AND time >= now() - 3h”

works

but :
"SELECT “/^{rssi}/" FROM "autogen"."mqtt_consumer" WHERE ("app" =~ /^FS_trak/ AND “devaddr” =~ /^0024E63E$/) AND time >= now() - 3h”

does not work : the “/^{rssi}/" comes from an "Indicator_field” template variable defined as “SHOW FIELD KEYS ON …” , which lists the “rssi” value .

is this template variable fully supported in the SELECT clause ( toward Influxdb ) ?

in fact not sure that regexp are supported in influx db filed selection . ( but the the template variable is )

thanks in advance for help

Philippe

SELECT query is not supported - it is for time series data. Use SHOW TAG VALUES query.

Docs:

Hello

thanks.

this is annoying, as my
need is about using a template for a filed key, not a tag.

We are in the process
of migration dashboard from Chronograf to Grafana, and this
“features” is supported on grafana.

any chance to see it in
the future ( enhancements ) ?

regards

Philippe

I think this issue describes your problem?

Also related: https://github.com/grafana/grafana/issues/5013

Hi

yes indeed.

the work around (
using the $variable_name , with or without regexp marking but
not double quote ) ,work , but as stated , the editor
re-instantiates the double quote each time .

do confusing for novice
.

thank for pointing to the right issue, and I vote “for”.

regards

philippe

Hello

does anyone know if I can use a template variable as part of the query field name?
For example:

SELECT “X1_U1_Speed” -> this is the field name, now i want to replace U1 with a template variable that has the value U1 (and probably some other values like U2) for example.

so to have something like this:
SELECT “X1_$myvar_Speed”

I tried different combinations like /^myvar^/ [[myvar]] etc…

Thanks in advance

[UPDATE]
Solved it with the sintax: /^X1_[[myvariable]]_Speed$/

1 Like