Telegraf unable to remove 'ms' from the measurements

Viewed 138

My response looks like this and I am trying to remove 'ms' with no luck.

> snmp,displayName=AWS,responseTime="004ms" 1643646155000000000

I have a tried a few different variations on the 'pattern' line, but the output is either an error "invalid TOML syntax" or it just returns the data normally. I presume all it is, is my 'pattern'. Regex has gotten the best of me. Any ideas on what I am doing wrong? Thanks for the help!

Edit: I would probably need the "" around it to be removed as well, so it acts as a number and not a string when inserting into InfluxDB

[[processors.regex]]
  namepass = ["snmp"]
  [[processors.regex.tags]]
    key = "responseTime"
    pattern = "\|*ms|\*"
    replacement = "${1}"
    result_key = "responseTime"

Another edit, this removes 'ms' but not the quotes, influx still sees it as a string. I tried converting to integer with processor.converter, but no luck.

[[processors.regex]]
  namepass = ["snmp"]
  [[processors.regex.fields]]
    key = "responseTime"
    pattern = "(ms.*)"
    replacement = "${2}"
    result_key = "responseTime"
1 Answers

I resolved this myself, here was the solution:

[[processors.regex]]
  order = 1
  namepass = ["snmp"]
  [[processors.regex.fields]]
    key = "responseTime"
    pattern = "[^0-9]+"
    replacement = "${1}"
    result_key = "responseTime"

  [[processors.converter]]
    order = 2
    [processors.converter.fields]
     float = ["responseTime"]
Related