Multiple lines in one graph with only one query

Hi,

we use Grafana v7.5.4 (615c153b3a) for data visualization.

Our data is stored in a MS SQL database in long format, like (only an example):

Id | timestamp | value | unit | channel_id
0 | 2021-02-01 | 0.5 | Voltage | 1
1 | 2021-02-01 | 22 | Celsius | 1
2 | 2021-02-02 | 0.6 | Voltage | 2
3 | 2021-02-02 | 22 | Celsius | 2
4 | 2021-02-03 | 0.7 | Voltage | 1
5 | 2021-02-03 | 23 | Celsius | 1

For example, I can easily plot the temperatures (y-axis) and the Timestamps (x-axis) in one graph separated by the “channel_id” by defining 2 queries (one for channel 1 and one for channel 2). But what I need is a dynamic solution. In some cases we will have 2 channels, in other 3 channels and maybe more. I do not want to write new queries, if the values in the column “channel_id” will change.

How can I solve the problem? Is it possible to define only one query to get a graph with “channel-separated” lines?

Thank you!
Best regards
Patrick

I already found a solution for it.

Just define 3 columns - one time column, one value column, one metric column.

Patrick

1 Like