How to use a InfluxDB-tag value in a grafana legend?
Asked Answered
T

3

23

I have a InfluxDB dataseries. It stores one information about mulitple machines. I distingsh between these machines with a tag. I can display the information for all three machines at once using a "Group by tag(machine)" clause. the name of the legends is "table.derivative {machine: 1}", "table.derivative {machine: 2}" and so on. How can I change it to "machine 1", "machine 2" and so on?

So far I came across this suggesting to use $groupby (or $g ?), but both are just added a literally.

Trajan answered 22/2, 2017 at 17:4 Comment(0)
I
45

In Grafana, you can use alias patterns. There is a description of alias patterns at the bottom of the metrics tab:

enter image description here

In your case, in the Alias By field you would write $tag_machine.

Here is an InfluxDb example on the Grafana demo site that uses the Alias By field:

https://play.grafana.org/d/000000002/influxdb-templated?editPanel=1&orgId=1

Ivanaivanah answered 22/2, 2017 at 21:53 Comment(4)
is it possible to use the Field name ?Ericaericaceous
@Ericaericaceous did you try $col? You could it use with the alias function (or using AS if writing a raw query: SELECT mean("myfield") AS "myfield") to get what you want.Ivanaivanah
the link is not valid anymoreGarlan
@user_x try play.grafana.org/d/000000002/influxdb-templated?orgId=1 insteadIvanaivanah
A
9

If you are using InfluxDB with Flux query language, use the following in the Display Name

  • ${__field.labels}
  • ${__field.labels.<tag_name>}

or in some cases this might work

  • ${__field.labels.name}
Analcite answered 29/3, 2022 at 7:37 Comment(2)
This helped me big time :) thanks! You can also chain the fields, so Display Name can contains something like: ${__field.labels.host}: ${__field.labels.path} (${__field.labels.device}) - example for disk usageVerrocchio
${__field.labels.<tag_name>} works for graphite DB as well.Marimaria
I
1

For me $_tag_TAGNAME worked ... none of the above worked for me ( even though I saw it in the help section of my instance of Grafana ...)

Is answered 2/6, 2020 at 12:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.