2

Unable to change the legend name in Grafana using InfluxDB[flux as query language]. Previously I was using InfluxQL as query language and at that time, grafana provided an option to set the legend name. But after switching to flux, that option seems to be missing. Now it's always showing the legend name as _value, I need to change it to some custom text. Please find below the query I'm using. Thanks for your time in advance.

bucket1 = from(bucket: "NOAA_water_database/autogen")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "ak_api_time" and (r._field == "device_id"))
  
bucket2 = from(bucket: "NOAA_water_database/autogen")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "ak_app_launch" and (r._field == "device_id"))
  
union(tables: [bucket1, bucket2])
 |> filter(fn: (r) => (r.browser == "chrome"))
 |> group(columns: ["device_id"])
  |> unique(column: "_value")
    |> count(column: "_value")

enter image description here

Akhil
  • 333
  • 3
  • 13
  • As per my understanding it's still an open issue and Grafana developer team may consider it in the next release. – Akhil May 19 '21 at 11:47

2 Answers2

3

|> set(key: "_wanted_field", value: "Hi, Mom!")

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

Mike Julier
  • 141
  • 1
  • 4
0

In Grafana, it is possible to add field overrides for the display name (called 'Standard Options > Display Name'). As override value, you can reference values from your query through data links:

Field variables

Field-specific variables are available under __field namespace:

  • __field.name - the name of the field
  • __field.labels.<LABEL> - label’s value to the URL. If your label contains dots, then use __field.labels["<LABEL>"] syntax.

For example, in my InfluxDB-setup, sensor readings have a tag 'item'. I can reference that with $__field.labels.item:

enter image description here

If you want to modify the value of a tag in your time-series, you can do that with the map-function.