How to show field name in Legend?

Hi there,

I’m using InfluxDB for a Sensor named “Office 1” that measures Temp, Hum, CO2.

When using Grafana the measurements are stored in database “events”.
I then select from Office 1 and have all 3 fields as fields available in Grafana.

However, the Legend shows “Office 1” for each line in the Graph, which is not very helpful.
I’d like to show the field name instead (Temp/Hum/CO2) but there doesn’t seem to be a $field placeholder
for the Alias By field.

How can I do this?
And: Am I doing this wrong? Should I save my measurements differently? I think this is the default
Influx way to store data so I’m confused…

try using $col in the alias by field

1 Like

Thanks for the answer, unfortunately
$col does not work, it just displays “mean” - is there any other way?

Does anyone have an idea?

This is most likely because you did not add an “alias” to the field. Adding the alias, will make that value available as $col

3 Likes

In influxDB, use $tag_[tag_name] , ex: $tag_path

https://community.grafana.com/t/influxdb-alias-by-other-column-value/12222/3

If you were accessing the raw field ( without mean, last, etc ) and no groupBy - $col would contain the field name.

Without “Alias” (within grafana ux) or “AS” (in raw query editor) - Influx will return the function name that created the column, not the original field name; in the returned data.

As mentioned; you may need to manually set an ‘alias’ for each field you need in the legend.

1 Like