influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.63k stars 5.58k forks source link

Excessive logging for regex processor #15753

Closed llamafilm closed 2 months ago

llamafilm commented 2 months ago

Relevant telegraf.conf

[[inputs.ping]]
  urls = ["127.0.0.1"]
  fieldinclude = ["result_code"]

[[processors.regex]]
  namepass = ["nginx_requests"]
  [[processors.regex.tags]]
    key = "resp_code"
    pattern = "^(\\d)\\d\\d$"
    replacement = "${1}xx"

Logs from Telegraf

% telegraf --config debug.conf --test
2024-08-17T05:44:06Z I! Loading config: debug.conf
2024-08-17T05:44:06Z I! Starting Telegraf 1.31.3 brought to you by InfluxData the makers of InfluxDB
2024-08-17T05:44:06Z I! Available plugins: 234 inputs, 9 aggregators, 32 processors, 26 parsers, 60 outputs, 5 secret-stores
2024-08-17T05:44:06Z I! Loaded inputs: ping
2024-08-17T05:44:06Z I! Loaded aggregators: 
2024-08-17T05:44:06Z I! Loaded processors: regex
2024-08-17T05:44:06Z I! Loaded secretstores: 
2024-08-17T05:44:06Z W! Outputs are not used in testing mode!
2024-08-17T05:44:06Z I! Tags enabled: host=Elliott-M2-4.local
2024-08-17T05:44:06Z I! [processors.regex] tags: Using explicit mode...
2024-08-17T05:44:06Z I! [processors.regex] tags: Using explicit mode...
> ping,host=Elliott-M2-4.local,url=127.0.0.1 result_code=0i 1723873447000000000

System info

Telegraf 1.31.3

Steps to reproduce

Run the telegraf config above

Expected behavior

The log should not say anything about processors.regex since it does not match the namepass line. Or at least this should be debug level.

Actual behavior

I see log messages at info level like this:

I! [processors.regex] tags: Using explicit mode...
powersj commented 2 months ago

The log should not say anything about processors.regex since it does not match the namepass line.

This is an incorrect assumption. Any plugin that you have defined will have its Init function run. That is because this function is run during the initial set up of Telegraf, before metrics are passed and any namepass or other metric filtering is used.

Or at least this should be debug level.

This log message was added as a part of #14084, which I believe was feedback from users as well to better understand what was going on with the plugin. While it could be debug, we have a history of putting init messages that explain a plugin behavior or mode as info instead of debug. This is only printed at the start, which does not make it excessive versus printing at every gather.

llamafilm commented 2 months ago

Ah I see! Ok that's fair, since it only happens once at init. My telegraf config changes quite often via inotify, so that must be what I'm seeing this so often.