Relabeling the legend in Grafana


this is my first question, so please do not stone me to death :smiley: I am running a smarthome stack containing mqtt, telegraf, influxdb2 and grafana8 using bme280 sensors. everything is running smoothly after some problems but i am having some issues renaming the legend in my grafana dashboard.

my flux query

from(bucket: "bme280")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
  |> filter(fn: (r) => r["topic"] == "sensors/bk/temp" or r["topic"] == "sensors/sz/temp" or r["topic"] == "sensors/wz/temp")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

results in a nice graph however i don’t like the legend which is

- value {host="raspi", topic="sensors/bk/temp"}
- value {host="raspi", topic="sensors/sz/temp"}
- value {host="raspi", topic="sensors/wz/temp"}

it should display

- Temperature Balcony
- Temperature Sleeping room
- Temperature living room

i can get around changing the β€œvalue” tag to something else using

|> set(key: "value", value: "temperature")

but the part in β€œ{}” is not covered. Is there any way to remove this part or at least change it? See Picture

Furthermore: Im not that good with querying language. Thus i’m using the influxdb2 visual builder to complete queries and copy them into grafana. Is there a leaner way? (beside diving deeper into flux)

Thank you and BR

Welcome to the forum. First of all, nice setup! (MQTT + Telegraf + Influx2 + Grafana)

What you want is certainly possible (I had / have the same issue with Flux, where I get crazy long legend names). I would suggest you not mess with the Flux value tag and just use an Override in Grafana. In my screenshot below, the original name was Memory (yours would be value {host="raspi", topic="sensors/bk/temp"}) and the new (override) name is Temperature Balcony

1 Like

Hello Grant

thank you for the warm welcome wishes. I tried out your proposed solution and it works like a charm!

Thank you so much for your reply

Best regards