0

I was trying to write a simple FluxQL Query in Grafana Dashboard that uses a variable m1(of type constant)(which contains the name of the measurement)

I created the variable m1 in grafana dashboard variables m1 = my-measurement

and tried to run the following queries but non of them worked and they either say expression request error or No Data) i.e

SELECT count("fails") FROM "/^${m1:raw}$/"
SELECT count("fails") FROM "/^${m1}$/"
SELECT count("fails") FROM $m1" (expression request error)
SELECT count("fails") FROM "$m1"
SELECT count("fails") FROM "${m1}"

The only query worked was without dashboard variables

SELECT count("fails") FROM "my-measurement"

How can I use the variables to work for that query.

On the similar ground I tried to make a custom variable(myVar) for which we take integer input values from user and on that basis where clause should work, but same error occurs either no data or expression request error What I tried was

SELECT count(*) from "my-measurement-2" WHERE ("value" > $myVar)

How should I solve these issues?Please help

1 Answers1

0

You may have a problem with

1.) syntax

SELECT count("fails") 
FROM "${m1:raw}"

2.) data

You may correct query syntax, but query can be very inefficient. Query execution may need a lot of time - so it's better to have timefilter, which will use selected dashboard time range (make sure you have some data in that time range)

SELECT count("fails") 
FROM "${m1:raw}"
WHERE $timeFilter

3.) Grafana panel configuration

Make sure you are using suitable panel - for query above Stat panel is a good option (that query returns only single value, not timeseries, so time series panel types may have a problem with that).

Generally, use query inspector to see how are variables interpolated - there can be "magic", which is not obvious - e.g. quotes which are added around numeric variables, so then it is string filtering and not numeric filtering on the InfluxDB level.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59