Flux Query with MultiValue Variable


i want to setup a dashboard where you dont need to know or change the flux query.
So the user should be able to select some values from a multiValue variable on the dashboard.
Currently I use Grafana version: 10.0.0

Is there a way to do. The problem is at the moment, that the filter can not handle multiple values in the variable. If one value is selected, it works. If I select more then one, the query won’t work.


from(bucket: “${database}”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “${measurement}”)
|> filter(fn: (r) => r[“host”] == “${host}”)
|> filter(fn: (r) => r[“obj_name”] == “${multiValue}”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

I tried already some contain or regex filter, but i could not solve the problem.

Maybe there is someone who could help me with this.
Thank you

Something like this might work.

|> filter(fn: (r) => r["obj_name"] =~ /^${multiValue:regex}$/ )

This thread should help

1 Like

This works, thank you.

1 Like