Using contains()
seems to have quite severe performance implications. You might be better off utilizing regex in filter()
and formatting your variable accordingly, i.e., ${devices:regex}
(Advanced variable format options | Grafana Labs). Perhaps something like this could work for you?
from(bucket: "test-bucket-new")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_field"] =~ /${devices:regex}/)
Depending on how your dashboard variables are created (queried or manually), you might end up with unwanted regex matches. In that case, you could go with something like /\b${devices:regex}\b/
in your query.
Worked for me and was way faster than contains()
.
Good luck!
Kaspar