Set field value as query label / alias for a PostgreSQL data source

Hi, I’m trying desperately to properly configure a panel using PostgreSQL as a data source. This panel has two queries from the same table with different conditions. Data is visualized via a time series.

The example output data looks like this:

date value meter
2023-11-12 10:11:12 0.444 Meter 1
2023-11-11 10:11:12 0.333 Meter 1
2023-11-10 10:11:12 0.222 Meter 1
2023-11-09 10:11:12 0.111 Meter 1

and similar for the second query:

date value meter
2023-11-12 10:11:12 3 Meter 2
2023-11-11 10:11:12 2.5 Meter 2
2023-11-10 10:11:12 2.0 Meter 2
2023-11-09 10:11:12 1.5 Meter 2

The problem: the chart shows the two graphs, but both have value as the label. Unfortunately, the PostgreSQL provides no option to set a label directly on the query.


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

    • Grafana in Docker, v10.1.1 (0cfa76b22d)
  • What are you trying to achieve?

    • I would like to set the label of a query from a field, in this case it would be the value of meter.
  • How are you trying to achieve it?

    • I have no idea. I tried so many things I found on the internet, but none worked. Neither using data links in the Display Name config, nor using transforms to change the outputs. Closest I could get is with the Config from field transform, but it removes all but one query results.

Related but without working answer:

What kind of visualization?

Also what are the two where conditions?

It’s a time series, conditions select individual meters in my case.

Thank you very much! Using metric as the name for the field worked.
May I ask how you know that it is supposed to be like that? I don’t know where in the documentation this could be found.

1 Like

sorry I don’t remember where in the doc that is