Passing template variable to Grafana data source - live measurement streaming

Hello, I am using Grafana enterprise 8.3.6 version. I am able to live stream IOT sensor data into Grafana by using data source as Grafana and live measurement. The dashboard is showing all the sensor data in near real time. I have taken following approach .
MQTT=>Telegraf (HTTP endpoints)=> Grafana.
Everything is working fine. But one thing i found missing is that i cannot pass template variables to live streaming panel by any means. I want to create a single dashboard for all the different kind of devices. For an example , lets say if i select a item(device id) from the drop down list which is created through template variables , i should be able to see live streaming of selected device and all its parameters like motor temperature , vehicle speed etc. etc. As of now all the devices are listed below the panel and lets say if there is a 1000 devices then there is too much dense data which is not easy to filter . My question is that is there any way to pass template variable to live streaming panel? It is possible to pass template variable in Grafana in case data source is influx dB which i have already tested , but if data source is Grafana live stream , can i pass template variable to live streaming data source ? if yes how can i achieve this. Please suggest.

1 Like

Hi, did you solve this/find a workaround? I want to do the same, but face the problem you described

Edit: Hard coding a device value in a Transform works, but we can not use variables there:

Hi @abhiroyme,

Welcome to the :grafana: community forum !!

So, I think I get the idea what you are trying to achieve here is that for 1000 devices you simply want to use a variable device-id and then pick the status for a query e.g.

select * from measurements where id=1
select * from measurements where id=2
....
.......

To make this happen inside Grafana, once you define the query for the dashboard, create an alias for it (here it will be something like $device_id)

Once that’s done,

Goto Dashboard → Settings → Variables and then define your query there which you are using to pull the values and then define WHERE clause e.g.

WHERE device-id=''=~"$device_id"

Then in the “Selection options” enable the toggle button for multi-values and then test it out.

If the query is correctly defined, then it should list all the devices connected to it and then if it does then simply go back to your dashboard and refresh it.

You will see the dropdown list there with the device_id.

I hope this helps.