Substitution of variables is not working

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

Grafana v8.1.2 (103f8fa094) on Debian GNU/Linux 10 (buster)

  • What are you trying to achieve?

Using Variables for substitution of window sizes in my flux queries.

  • How are you trying to achieve it?

I’ve set up two Variables in the Dashboard with different names and a standard value of “15s” on both of them

  • What happened?

I’m getting an “expression request error” for the panel I configured.

  • What did you expect to happen?

The data should be downscaled in the way, that each point represents an interval of 15 seconds (the value of the variables)

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

I’m using a flux query that looks like this:

from(bucket: "test_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["datacenter"] == "5")
  |> filter(fn: (r) => r["name"] == "exampleDevice")
  |> window(every: ${windowSize}, period: ${windowPeriod})
  |> mean()
  |> duplicate(column: "_stop", as: "_time")
  |> window(every: inf)
  |> map(fn: (r) => ({  r with _measurement: }))

If I hardcode the interval times, the query can be resolved by the influx Server, so the flux syntax is correct.
I have another dashboard, where this way of variable substitution is working without problems, but somehow it’s not working on this particular dashboard.
I looked into the request and I can see, that the substitution of the variables is not taking place (while the substitution in the other Dashboard I mentioned is present in the request body). Auto-Completion is correctly suggesting the variables btw, but they are simply not getting substituted by their values. Am I missing some sort of configuration I have to enable to use variables?

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

This is a screencap of the request which was sent.

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

I tried various things; I compared the configurations of my two dashboards, I tried to rename my variables since the same variable names are used in my first dashboard, I tried to specify the type of my variables (${windowSize:text}), but nothing worked.

This topic was automatically closed after 365 days. New replies are no longer allowed.