I have a influx database with multiple devices reporting data as back end for Grafana. In some of the dashboards I provide the users with a drop down list where they can select multiple serial numbers at once. I the create a common graph with all the selected devices. Currently I use regex, but I suspect it could be faster if I was using something akin to “in”. But I’m not finding how to do that.
This is effectively how I’m doing it today
from(bucket:"devices")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "cellular"
and r._field == "RSRP"
and r.serial =~ /123|456|789/
)
I’m hoping to change that “serial” part to reference directly the serial numbers in a sql way? Something like this?
from(bucket:"devices")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "cellular"
and r._field == "RSRP"
and r.serial in ["123","456","789"]
)
Remember, this is initiated from Grafana picker. So the serials will be dynamic. I cannot use list of r.serial == “123” or r.serial == “456” as the number of serials and how grafana formats them.