Quantcast
Viewing all articles
Browse latest Browse all 200

Time range values not passed to variable queries

  • What Grafana version and what operating system are you using?

Grafana Cloud: Grafana v11.1.0-71516 (0ba54152dc)

  • What are you trying to achieve?

Load variable values from influxdb based on the selected time range

  • How are you trying to achieve it?

I have a query variable which selects all unique influxdb tag values in the selected time range:

import "influxdata/influxdb/schema"

schema.tagValues(bucket: "my_bucket", tag: "my_tag", start: v.timeRangeStart, stop: v.timeRangeStop)
  • What happened?

When the dashboard executes the query to load the variable values, it sends the query request without “from” and “to” values. This results in a status 400 response with the message “error”: “invalid: error in building plan while starting program: cannot query an empty range”, because v.timeRangeStart and v.timeRangeStop are both interpreted as 1970-01-01 (timestamp 0)

  • What did you expect to happen?

Load the tag values from the provided tag in the provided time range. This same query worked fine before in the same dashboard. The query still works fine in the data source explorer.

  • Can you copy/paste the configuration(s) that you are having problems with?

The HTTP request sent in the data source explorer:

{"queries":[{"refId":"A","datasource":{"type":"influxdb","uid":"redacted"},"query":"import \"influxdata/influxdb/schema\"\n\nschema.tagValues(bucket: \"my_bucket\", tag: \"my_tag\", start: v.timeRangeStart, stop: v.timeRangeStop)","datasourceId":12,"intervalMs":60000,"maxDataPoints":1572}],"from":"1717575257774","to":"1717578857774"}

The HTTP request sent from the dashboard upon reloading the variables:

{"queries":[{"refId":"metricFindQuery","query":"import \"influxdata/influxdb/schema\"\n\nschema.tagValues(bucket: \"my_bucket\", tag: \"my_tag\", start: v.timeRangeStart, stop: v.timeRangeStop)","rawQuery":true,"datasource":{"type":"influxdb","uid":"redacted"},"datasourceId":12,"maxDataPoints":1000}]}

As you see, the “from” and “to” keys in the request are missing.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

The query requests for the variables give status code 400. This results in the variable list being empty, and just showing the “all” value. This results in my dashboard query filtering on no tag value and showing “no data”. The dashboard query executes fine, as it seems to replace v.timeRangeStart/Stop in-line in the query.

  • Did you follow any online instructions? If so, what is the URL?

No

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 200

Trending Articles