How do I map/rewrite template variable values to human readable values in Grafana Dashboard?

What Grafana version and what operating system are you using?

  • Grafana 9.2.0
  • Running on Ubuntu 20.04 LXC container

Some background:

We are using Shellys to monitor power of our infrastructure. The monitoring pipeline looks like this:

Shelly(s) → Mosquitto MQTT broker → Node Red → InfluxDB → Grafana

I do not have control over what happens until the data is in InfluxDB.

What are you trying to achieve?

As you can see in the screenshots below, each time-series from a Shelly is assigned a custom_id label by with Node Red (e.g. shelly_001, etc.) which we query. I want to map the custom_id of some Shellys (those which are relevant for my group) to human understandable name (e.g. shelly_001freezer, floor 1, shelly_002microscope, floor 1, etc.).
Is this possible in Grafana and how would I do this?

Here are screenshots of the custom_id config in the Dashboard and the selection in the Dashboard:

This is the query in the panel:

SELECT last("apower") FROM "pm_shelly" WHERE ("custom_id" =~ /^$custom_id$/) AND $timeFilter GROUP BY time(10s) fill(previous)