Multiple choice variable graph

  • What Grafana version and what operating system are you using?
    Grafana v10.0.3
    Influxdb v2.7.1
    Ubuntu 22.04

  • What are you trying to achieve?
    Have graphs use a multiple choice variable to display data.

  • How are you trying to achieve it?
    Setup a dashboard variable that pulls in unique tags (works)
    Use this variable in the query to filter the data (doesn’t work)

  • What happened?
    No data shown

  • What did you expect to happen?
    Show data

The tags are in the format of “01” or “1”, because of the alphanumeric sorting of legends they need the ‘0’ prefix. Some of the older data doesn’t have this.

If I choose 1 of the variable options the graphing works. Any more than this and it doesn’t.

The query:

from(bucket: v.bucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Thermocouple")
  |> filter(fn: (r) => r["Sensor"] in ("${TCR}"))

$TCR is my list of tag “Sensor” and looks like this:
The variable query:

from(bucket: v.bucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Thermocouple")
  |> keyValues(keyColumns: ["Sensor"])
  |> group()

And the results:
image

I’ve tried the following for the last filter query:
|> filter(fn: (r) => r["Sensor"] == "${TCR}") - No error. No data.

|> filter(fn: (r) => r["Sensor"] in ("${TCR}")) - gives this error:

invalid: compilation failed: error @5:40-5:49: string literal key {01,02} must have a value

|> filter(fn: (r) => r["Sensor"] =~ ("${TCR}"))

Any ideas?

Bumping this to hopefully get some help…