pdl86
March 26, 2018, 11:08am
1
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:
pdl86
March 26, 2018, 5:49pm
3
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?
opened 10:37AM - 30 Nov 16 UTC
closed 02:41PM - 10 Nov 20 UTC
type/bug
datasource/InfluxDB
area/datasource
Please prefix your title with [Bug] or [Feature request]
For question please ch… eck [Support Options](http://grafana.org/support/). **Do not** open a github issue
Please include this information:
- version 3.1 and also just verified it still exists in 4.0 released on Nov. 29th
- influxdb
- Tested in Windows 7 desktop and Redhat 7 ?
- Add a graph panel, create template variable that select the OS from data in influx and uses this to get a list of field keys back to display in another drop down. The user can then select a field key that is applicable to the selected OS (ie, Windows cpu has "percentUtilisation", Linux uses "%processorTime". I then use the variable name assigned to this in the field selection criteria in the query, ie;
select field (/^$cpuVarName$/)
- No data is returned, I also tried hard typing the value of the template as a custom type, this didn't work either.
- No data displayed. Using the explicit field name in the select field clause works as expected.
Current query;
Fails to return data:
SELECT mean("/^$varName$/") FROM "g_cpu" WHERE "host" =~ /^$serverName$/ AND $timeFilter GROUP BY time($interval), "host"
Works as expected:
SELECT mean("percentUtilisation") FROM "g_cpu" WHERE "managedEntity" =~ /^$serverName$/ AND $timeFilter GROUP BY time($interval), "managedEntity"
This is not related to alerting, just querying / displaying of simple data.
Also related: [Feature Req]: Support SELECT queries in templating query · Issue #5013 · grafana/grafana · GitHub
pdl86
March 27, 2018, 2:07pm
5
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