I have repeating Single Stat panels based on a $devicename variable.
Grafana 9.2.5
Data Source InfluxDB (InfluxQL) 1.8.10
SELECT last(“POWER”) FROM “mqtt_consumer” WHERE device = ‘$devicename’ fill(null)
This currently produces two panels as I have two vales for $devicename - plug1_DDBA43 and Plug2_DDBA89.
I would like to have each panel clickable (Data Link) to send an API call to the respective device to toggle its status. I need to be able to populate the url using the device IP. Each device IP is also present as a row in my table, which has a field “t” that matches each $devicename above.
> SELECT t,ip FROM "mqtt_consumer" GROUP BY t
name: mqtt_consumer
tags: t=
time t ip
---- - --
1672749862698812219 plug1_DDBA43 192.168.9.22
1672749862699487765 Plug2_DDBA89 192.168.9.21
> SELECT last("POWER") as Status, device FROM "mqtt_consumer" GROUP BY device;
name: mqtt_consumer
tags: device=Plug2_DDBA89
time Status device
---- ------ ------
1673002244278239429 1 Plug2_DDBA89
name: mqtt_consumer
tags: device=plug1_DDBA43
time Status device
---- ------ ------
1673002238307254204 1 plug1_DDBA43
“device” in this last query is a tag
I’ve attempted using transforms to join (this can only be done on time field), regex, variables to replace the value of $devicename with it’s associated IP Address returned by the first query but have not found a way to do so. Is there something simple I’m missing or is there no way to do this currently (without say, converting to flux and using a JOIN on something other than the time field)?