Processor rename plugin not working as expected


I’m collecting metrics from windows machine and there is an exec plugin, emitting certain metrics which contain some measurements I need to handle differently (rename). Exec plugin looks like this:

  commands = [
    'powershell -ExecutionPolicy Bypass -File "C:\metrics.ps1"'
  timeout = "10s"
  data_format = "prometheus"

and it yields following:

# HELP prometheus_processes_total Telegraf collected metric
# TYPE prometheus_processes_total untyped
prometheus_processes_total{host="WIN-5O9RBMT2QOC"} 100
# HELP prometheus_processes_total_threads Telegraf collected metric
# TYPE prometheus_processes_total_threads untyped
prometheus_processes_total_threads{host="WIN-5O9RBMT2QOC"} 808

Now, I would like to strip prefix prometheus_ from the measurement name using this config for rename processor :

  # tried with and without namepass, doesn't change anything
  namepass = ["prometheus_*"]
    measurement = "prometheus_processes_total_threads"
    dest = "processes_total_threads"

    measurement = "prometheus_processes_total"
    dest = "processes_total"

but it’s not working at all. Can anyone tell me what I am doing wrong here?


That might be what prints out when you run the script, however internally to telegraf I believe if you enabled the outputs.file you would see these two metrics:

prometheus,host=WIN-5O9RBMT2QOC prometheus_processes_total=100 1668102863000000000
prometheus,host=WIN-5O9RBMT2QOC prometheus_processes_total_threads=808 1668102863000000000

The prometheus file format will use the metric name “prometheus”. Give the outputs.file a try and then update your rename as necessary.