Format "Alias by" (InfluxDB, multiple selected values from query variable)

Hello,

I use Grafana with InfluxDB and OpenHAB to store temperature and humidity.

In InfluxDB I have the following measurements:

Bathroom_Heating_Humidity
Bathroom_Heating_Temperature
Bedroom_Heating_Humidity
Bedroom_Heating_Temperature
Hallway_Heating_Humidity
Hallway_Heating_Temperature
Kitchen_Heating_Humidity
Kitchen_Heating_Temperature
Livingroom_Heating_Humidity
Livingroom_Heating_Temperature
Office_Heating_Humidity
Office_Heating_Temperature
Outdoor_Heating_Humidity
Outdoor_Heating_Temperature

In Grafana I have created the following custom variable:

Now I want to use two graphs in a dashboard - for temperature and humidity.
However, I will now only deal with the temperature graph, since the humidity graph will be identical in logic.

Now to the actual question:
Basically everything works as it should, but my problem is the label of the individual measurements. Currently they are called for example “Bathroom_Heating_Temperature” and I don’t know how to rename them to “Bathroom Temperature”.
Can someone explain to me how I can do this?

2 Likes

Did you ever solve this? I am having exact the same issue. Most people seem to recommend using tag names for this, but I am using OpenHab which does not seem to support tags for InfluxDB. I tried putting [[rooms]] in the “Alias By” field but this just puts the whole room list as the field name.

Edit: The best I could come up so far is to first apply an “Outer Join” transformation, followed by a “Organize Fields” transformation where you can then rename the fields. Unfortunately, you cannot use regular expressions in this process, so you have to rename each field by hand which seems redundant. It’s okay-ish for my OpenHab needs as the amount of devices will rarely change after a while. Still, having a more flexible option here would be preferable. Maybe it’s time to hack my own transformation.

OP, I have the same question as you; did you ever solve this?

Not sure if this has been answered or resolved and I havent tested this on your example, however the transforms usually help.
Especially in the more recent versions of Grafana.
There is a transform, Rename by Regex.

So in my own examples, I have:

  • Input_IFCount.Access_Ports
  • Input_IFCount.Shut_Ports
  • Input_IFCount.Down_Ports
  • Input_IFCount.Up_Ports
    I use Transform Rename by Regex as follows (I only want the “Access Ports”, “Shut Ports” etc).
    Match: [A-Za-z_]+.([A-Za-z]+)_([A-Za-z]+)
    (the () represents the items that I am interested in).
    Replace: ($1) ($2)
    This results in:
  • Access Ports
  • Shut Ports
  • Down Ports
  • Up Ports
    Again, I haven’t worked through your particular example but it seems similar.