Regex value mapping doesn't work on integer value

  • What Grafana version and what operating system are you using?

v10.1.1

  • What are you trying to achieve?
    I am trying to convert the value of the following metric to a version string:
    {pg_settings_server_version_num{container=~"postgres.*", postgres_partition=~"$tenant.*", cluster=~"$cluster"}
    This returns 150012, which corresponds to version 15.12.
    Data source is thanos.

  • How are you trying to achieve it?
    I tried to use a regex value mapping like this:
    ( \d\d)\d\d(\d\d) => $1.$2

  • What happened?
    Nothing, it doesn’t work. I suspect because the value is an integer, not a number.

  • What did you expect to happen?
    I assumed, that grafana would automatically convert a value to string if the user applies a regex mapping. Otherwise the option should not be available.

  • Did you receive any errors in the Grafana UI or in related logs?
    Nope.

I added a transformation: “Convert field type” and set the value type to String. That way it magically converts 150012 to 15.12.