I have a Grafana FLUX query against an InfluxDB data source
from(bucket: "OpenTel")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "http_req_duration_value")
|> filter(fn: (r) => r["_field"] == "gauge")
|> filter(fn: (r) => r["buildNumber"] == "${buildNumber}")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
This uses a template variable {buildNumber}
If I select a single buildNumber value in the variable dropdow then the filter shows results for that specific buildNumber. Which is fine
But I want to be able to also show the results for all buildNumbers if I configure the variable to “Include All Options”. When you do this you get an “All” value in the results.
So how would I use ${buildNumber}" == “All” to effectively remove the filter for buildNumber?
I tried to use conditional filtering but couldn’t get it to work.
tried something like the following which should reapply an existing filter and not apply the buildNumber filter
|> filter(fn: (r) => if "${buildNumber}" == "All" then r["_measurement"] == "http_req_duration_value" else r.buildNumber == "${buildNumber}")
I’m using the latest versions of grafana and InfluxDB.
Any ideas on a simple way to do this?