What does metric_rename mean?

I’m looking at the “Regex Processor Plugin”: telegraf/README.md at release-1.22 · influxdata/telegraf · GitHub

The example there is not showing anything at all. Other plugins have a diff there, but this is just one single line of Line Protocol.

I know what measurement, tag and field mean for influxdb, but I have never heard of “metric”. What is this, where is the string supposed to be that is being replaced by “metric_rename”

I have tried this to figure out what is going on, but “z”, “y” and “x” are nowhere to be found.

[[processors.converter]]
  [processors.converter.tags]
    measurement = ["topic"]

[[processors.regex]]
    [[processors.regex.tags]]
        pattern = ".+"
        replacement = "x"

    [[processors.regex.fields]]
        pattern = ".+"
        replacement = "y"

    [[processors.regex.field_rename]]
        pattern = ".+"
        replacement = "v"

    [[processors.regex.tag_rename]]
        pattern = ".+"
        replacement = "w"

    [[processors.regex.metric_rename]]
        pattern = ".+"
        replacement = "z"
                   _start:time                      _stop:time           _field:string                             _measurement:string             host:string           foo_id:string                w:string                  _value:float                      _time:time
------------------------------  ------------------------------  ----------------------  ----------------------------------------------  ----------------------  ----------------------  ----------------------  ----------------------------  ------------------------------
1970-01-01T00:00:00.000000000Z  2022-05-17T13:20:29.175069303Z                       v  foo/1/bar/2/report/telemetry/temperatures/tank            9b391feabbe8                       2                       1                 9314857891347  2022-05-17T13:20:09.929803454Z

In context of telegraf “metric” is what you call “measurement”. So it is a way to rename the measurement (metric name).

      [[processors.regex.metric_rename]]
        pattern = "(\w\B)"
        replacement = "$1_"
-cpu,cpu=1 usage=12.3
+c_p_u,cpu=1 usage=12.3
1 Like

Then this is exactly what I was looking for, thanks. But it is not doing anything at all for me

Caused by another plugin I had in use that overwrote the measurement name again. I added that config to the original question for reference.

By adding an ordering it worked: Telegraf: Add examples of running processors in order · Issue #2323 · influxdata/docs-v2 · GitHub

1 Like