Rename part of legend text matching regex

I have some disk stats getting pulled by my server (Prometheus data source)

The device names are like dm-0,dm-1,dm-2 and so on. My graph renames the legend to, for example: $device - Read IOPS.

Now, these dm-X devices have more meaningful names like (dm0 → snapshot, dm-1 → data, dm2 → temp), would it be possible to rename the graph fields mapping using regex matching or some other means so for every legend that contains “dm-0” it gets automatically translated to “snapshot”?

Current Legend:
dm-0 Read IOPs
dm-0 Write IOPs
dm-1 Read IOPs
dm-1 Write IOPs

Desired Legend:
snapshot Read IOPs
snapshot Write IOPs
data Read IOPs
data Write IOPs

Example Graph:

Hi elfarto, I think you could use overrides with regex to achive that

Tried it, but I’d have to define an override for each of the devices, I don’t think you can use a regex match to rename a field. ie:
I can match the regex as (dm-[0-9)(.*) but i can’t use $1 and $2 to rename the field.

Hi,
Since you’re using Prometheus datasource, maybe label replace function would help? It’s a bit non-elegant to read (and you’d also need to count for every device) but I don’t see many alternatives.

There’s also Rename by regex Transformation if you’d like to try such approach better.