We’ve set up a Grafana cloud + InfluxDB 2.0 (Flux language) cloud instance. As part of this, we’ve created a custom variable list with “device IDs”, called devices .
In a panel, we wish to display parameter data where the user can select one or more device IDs from the devices list to have them displayed in the panel. This works fine for single device ID selection, but not for multiple devices.
How should the query be modified to display data from a variable number of devices based on a multi-select entry in the dropdown in Grafana?
If I look in the Query inspector it looks as below. I guess maybe the issue is that the variable returns an object rather than a list. Not sure how to get around that part if that’s what causing the problem.
Basically the query runs but it is very slow, even for a 5 minute timespan. If I choose a longer timespan (for example 1 day) the query aborts due to a timeout.
Is there something I can do to speed up the query?
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?
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.
Hi @pgg
Looks like your pointName filter has an extra closing bracket and is missing regex delimiters /.
You can also add start/end of line matchers (^ and $) to ensure the filter will only match full pointName values.