I am populating a dashboard variable using this Flux query, but it stopped working in the last week or so.
When the query is run in the query editor in Explore, I get single-column table with the names of devices used in the specified time range.
In Dashboards | Settings | Variables, the same query returns no values. The same thing happens if I use distinct
instead of unique
or include yield
at the end.
Details
Configuration
- Grafana 11.1.0
- InfluxDB 2.7.7 OSS
- Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-116-generic x86_64)
What I was trying to achieve
To populate a dashboard variable named device
using a Flux query.
How I was trying to achieve this
- In Dashboards | Settings | Variables, I created a variable called device.
- I set variable type as Query.
- I applied the query in the code block below.
- No regex was applied. Multi-value was selected.
from(bucket: "myBucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => exists r.deviceName)
|> group()
|> keep(columns: ["deviceName"])
|> unique(column: "deviceName")
What happens
Preview of values shows None.
What did I expect
I expected to see a list of devices.
Configuration
Relevant, anonymised selection of the >1.6k line JSON.
"templating": {
"list": [
{
"current": {
"selected": true,
"text": [
"None"
],
"value": [
""
]
},
"datasource": {
"type": "influxdb",
"uid": "01234567-89ab-cdef-0123-456789abcdef"
},
"definition": "from(bucket: \"MYBUCKET\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => exists r.deviceName)\n |> group()\n |> keep(columns: [\"deviceName\"])\n |> unique(column: \"deviceName\")",
"hide": 0,
"includeAll": false,
"label": "device name",
"multi": true,
"name": "device",
"options": [],
"query": {
"0": "f",
"1": "r",
"2": "o",
"3": "m",
"4": "(",
"5": "b",
"6": "u",
"7": "c",
"8": "k",
"9": "e",
"10": "t",
"11": ":",
"12": " ",
"13": "\"",
...
"28": "\"",
"29": ")",
"30": "\n",
"31": " ",
"32": " ",
"33": " ",
"34": " ",
"35": "|",
"36": ">",
"37": " ",
"38": "r",
"39": "a",
"40": "n",
"41": "g",
"42": "e",
"43": "(",
"44": "s",
"45": "t",
"46": "a",
"47": "r",
"48": "t",
"49": ":",
"50": " ",
"51": "v",
"52": ".",
"53": "t",
"54": "i",
"55": "m",
"56": "e",
"57": "R",
"58": "a",
"59": "n",
"60": "g",
"61": "e",
"62": "S",
"63": "t",
"64": "a",
"65": "r",
"66": "t",
"67": ",",
"68": " ",
"69": "s",
"70": "t",
"71": "o",
"72": "p",
"73": ":",
"74": " ",
"75": "v",
"76": ".",
"77": "t",
"78": "i",
"79": "m",
"80": "e",
"81": "R",
"82": "a",
"83": "n",
"84": "g",
"85": "e",
"86": "S",
"87": "t",
"88": "o",
"89": "p",
"90": ")",
"91": "\n",
"92": " ",
"93": " ",
"94": " ",
"95": " ",
"96": "|",
"97": ">",
"98": " ",
"99": "f",
"100": "i",
"101": "l",
"102": "t",
"103": "e",
"104": "r",
"105": "(",
"106": "f",
"107": "n",
"108": ":",
"109": " ",
"110": "(",
"111": "r",
"112": ")",
"113": " ",
"114": "=",
"115": ">",
"116": " ",
"117": "e",
"118": "x",
"119": "i",
"120": "s",
"121": "t",
"122": "s",
"123": " ",
"124": "r",
"125": ".",
"126": "d",
"127": "e",
"128": "v",
"129": "i",
"130": "c",
"131": "e",
"132": "N",
"133": "a",
"134": "m",
"135": "e",
"136": ")",
"137": "\n",
"138": " ",
"139": " ",
"140": " ",
"141": " ",
"142": "|",
"143": ">",
"144": " ",
"145": "g",
"146": "r",
"147": "o",
"148": "u",
"149": "p",
"150": "(",
"151": ")",
"152": "\n",
"153": " ",
"154": " ",
"155": " ",
"156": " ",
"157": "|",
"158": ">",
"159": " ",
"160": "k",
"161": "e",
"162": "e",
"163": "p",
"164": "(",
"165": "c",
"166": "o",
"167": "l",
"168": "u",
"169": "m",
"170": "n",
"171": "s",
"172": ":",
"173": " ",
"174": "[",
"175": "\"",
"176": "d",
"177": "e",
"178": "v",
"179": "i",
"180": "c",
"181": "e",
"182": "N",
"183": "a",
"184": "m",
"185": "e",
"186": "\"",
"187": "]",
"188": ")",
"189": "\n",
"190": " ",
"191": " ",
"192": " ",
"193": " ",
"194": "|",
"195": ">",
"196": " ",
"197": "u",
"198": "n",
"199": "i",
"200": "q",
"201": "u",
"202": "e",
"203": "(",
"204": "c",
"205": "o",
"206": "l",
"207": "u",
"208": "m",
"209": "n",
"210": ":",
"211": " ",
"212": "\"",
"213": "d",
"214": "e",
"215": "v",
"216": "i",
"217": "c",
"218": "e",
"219": "N",
"220": "a",
"221": "m",
"222": "e",
"223": "\"",
"224": ")",
"query": "from(bucket: \"MYBUCKET\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => exists r.deviceName)\n |> group()\n |> keep(columns: [\"deviceName\"])\n |> unique(column: \"deviceName\")"
},
"refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"type": "query"
}
]
}
Other errors
None
Any online instructions followed
None