Use a variable in Grafana live measurements fields

Hi, I’m using Grafana 9.1.6 with dashboard using the Grafana Live Measurements data source (with data pushed to the live api websocket via Telegraf). It is working well when I select the desired fields in the panel configuration. I now want to use variables instead of the direct name of the metrics in the fields, so I can make my users to select which data to display in real time.

To try it I have created a “text box” variable:
2025-04-23 09_38_32-Live - Dashboards - Grafana
And I call that variable in the “Fields”:


However this is not working.
I don’t know if it because variables are not supported in the fields with Grafana Live Measurements? Or I that syntax I use is not correct?
If it is not supported, is there something in the roadmap to be able to use it?
With my team we really lie the live measurement functionality, but we really would like to have something flexible like with a standard data source where we can configure the queries dynamically.
Any help would be appreciated. Thanks.

you can follow the step to fix your issue :

Step: 1 create a table in postgres

CREATE TABLE live_measurements (
    id SERIAL PRIMARY KEY,
    timestamp TIMESTAMPTZ DEFAULT NOW(),
    metric_name TEXT NOT NULL,
    value DOUBLE PRECISION,
    unit TEXT
);

Step: 2 query in postgres that insert data after 5 sec interval that help to insert data like Live data

DO $$
DECLARE
    i INT := 1;
BEGIN
    WHILE i <= 100 LOOP 
        INSERT INTO live_measurements (timestamp, metric_name, value, unit)
        VALUES (
            NOW(),
            CASE WHEN i % 2 = 0 THEN '(M)LADLE_WEIGHT[Ton]' ELSE '(M)MOLD_STEEL_LEVEL[mm]' END,
            ROUND(
                (CASE WHEN i % 2 = 0 
                    THEN 40 + RANDOM() * 5
                    ELSE 75 + RANDOM() * 5
                END)::numeric, 2),  
            CASE WHEN i % 2 = 0 THEN 'Ton' ELSE 'mm' END
        );
        PERFORM pg_sleep(5);  -- 5 second delay
        i := i + 1;
		commit;
    END LOOP;
END $$;

Step: 3 Setup the Variable with input box that help to filter the data based on type metrix

Step: 4 Visualization → Bar Gauge

Step :5 Query for grafana panel

SELECT
  timestamp AS "time",
  metric_name,
  value,
  unit
FROM
  live_measurements
WHERE
  metric_name = '${metrics}'
  AND timestamp > now() - interval '6 hours'
ORDER BY
  timestamp ASC;

Final output Based on type Metrix:

Hello @corentinpicard ,

Just checking in—did this solution resolve your issue, or are you still experiencing the same problem?