Flux query to populate variable returns no results

That doesn’t fit with my observations. I can run a similar query, like the one suggested in another community post.

This is the query:

import "influxdata/influxdb/schema"
schema.tagValues(
    bucket: "MYBUCKET",
    tag: "deviceName",
    start: v.timeRangeStart,
    stop: v.timeRangeStop
)

In Explore in Grafana, I get the expected output:

[
  {
    "schema": {
      "refId": "A",
      "meta": {
        "typeVersion": [
          0,
          0
        ],
        "executedQueryString": "import \"influxdata/influxdb/schema\"\nschema.tagValues(\n    bucket: \"MYBUCKET\",\n    tag: \"deviceName\",\n    start: 2024-01-24T16:55:12.611Z,\n    stop: 2024-07-24T15:55:12.611Z\n)"
      },
      "fields": [
        {
          "name": "_value",
          "type": "string",
          "typeInfo": {
            "frame": "string",
            "nullable": true
          },
          "labels": {},
          "config": {}
        }
      ]
    },
    "data": {
      "values": [
        [
          "Castiel",
          "Chris spore",
          "Colt",
          "Fergus",
          "Impala",
          "Rowena",
          "Rufus",
          "Singer"
        ]
      ]
    }
  }
]

But when setting the query in the variable query options, I get nothing, unless I remove the time range, in which case I get matches from the default -30d.

My interpretation is that variable queries in Grafana are not parsing the time limits correctly.

I’m trying to pin down when the original query stopped working so I could look through what change might have broken the function.

1 Like