Timechart with postgresql query

  • What Grafana version and what operating system are you using?

Grafana version 11.0.0, RHEL 9

  • What are you trying to achieve?

Postgressql table consist of 3 columns time,sensor,value
We want a timeseries that shows all sensors (legend) stacked in time (x-axis) and value (y-axis).

  • How are you trying to achieve it?

SELECT timestamp as time
, sensor as sensor
, total_count as value
FROM table
WHERE sensor in ($sensor)

  • What happened?

value is used in the legend but we want de sensor name in de legend.

  • What did you expect to happen?
    in the legend we want all sensors instead of the value

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

  • Did you follow any online instructions? If so, what is the URL?
    No

try

SELECT timestamp as time
, sensor as metric
, total_count as value
FROM table
WHERE sensor in ($sensor)