Attempting to rename by regex over __name__ with no success

  • What Grafana version and what operating system are you using?
    I am using Grafana v9.0.6 installed via docker on amazon linux

  • What are you trying to achieve?
    I would like to convert the name of my metric to to remove the redundant portion for display in the legend.

  • How are you trying to achieve it?
    using “rename by regex” transform

  • What happened?
    specifying the redundant string as “Match” and replacing with some other string has no effect. In fact, no label value at all seems to be changed. It seems the feature is not working, or, more likely, I’m grossly misunderstanding something. I am specifically using the debug mechanism to observe the transformation, but nothing changes.

  • What did you expect to happen?
    I expect if I give string “this_long_thing_should_disappear” as Match and “foo” as Replace, the former should change to the latter for all labels (including __name__) in the debug panel.

  • Can you copy/paste the configuration(s) that you are having problems with?

I have also attempted to demonstrate that rename by regex works at all by using a string (“Join”) as match and “foo” as replace, as this string occurs in other label values, but I still see no effect.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?
    Transformation functions | Grafana documentation
    I would note that this documentation is unclear (to my newb understanding) on what is subject to transformation – “parts of the query results” is vague.

p.s. one could argue that I should transform my metric name with relabelling in prometheus, and in fact I probably will do this, but I’d really like to understand how to use this feature in grafana.

Welcome to the :grafana: forum @nparrish42!

If you want to change the display value, you can also try value mapping. I worked on a similar problem for a user in this post.