Repository navigation
Closed
Labels
bugunexpected problem or unintended behavior
Description
Relevant telegraf.conf
[[inputs.win_perf_counters.object]]
# Processor usage, alternative to native, reports on a per core.
ObjectName = "Processor"
Instances = ["*"]
Counters = ["% Idle Time", "% Interrupt Time", "% Privileged Time", "% User Time", "% Processor Time"]
Measurement = "win_cpu"
IncludeTotal=true
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = falseLogs from Telegraf
2025-12-17T14:42:52Z I! Starting Telegraf 1.37.0 brought to you by InfluxData the makers of InfluxDB
2025-12-17T14:42:52Z I! Available plugins: 242 inputs, 9 aggregators, 35 processors, 26 parsers, 67 outputs, 7 secret-stores
2025-12-17T14:42:52Z I! Loaded inputs: cpu disk diskio internal mem net netstat procstat system win_perf_counters
2025-12-17T14:42:52Z I! Loaded aggregators:
2025-12-17T14:42:52Z I! Loaded processors:
2025-12-17T14:42:52Z I! Loaded secretstores:
2025-12-17T14:42:52Z I! Loaded outputs: influxdb (2x)
2025-12-17T14:42:52Z I! Tags enabled: IP=0.0.0.0 environment=VAL host=hostname.example.com machine_type=physical os_type=Win32NT os_version=Microsoft Windows Server 2022 Standard 10.0.20348.0 region=N/A
2025-12-17T14:42:52Z W! Deprecated inputs: 0 and 1 options
2025-12-17T14:42:52Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"hostname.example.com", Flush Interval:10s
2025-12-17T14:42:52Z W! [agent] The default value of 'skip_processors_after_aggregators' will change to 'true' with Telegraf v1.40.0! If you need the current default behavior, please explicitly set the option to 'false'!
2025-12-17T14:43:10Z E! [inputs.cpu] Error in plugin: current total CPU time is less than previous total CPU time
2025-12-17T14:43:30Z E! [inputs.cpu] Error in plugin: current total CPU time is less than previous total CPU time
2025-12-17T14:46:20Z E! [inputs.cpu] Error in plugin: current total CPU time is less than previous total CPU time
2025-12-17T14:47:10Z E! [inputs.cpu] Error in plugin: current total CPU time is less than previous total CPU time
2025-12-17T14:49:59Z I! [agent] Hang on, flushing any cached metrics before shutdown
2025-12-17T14:49:59Z I! [agent] Stopping running outputs
2025-12-17T14:50:00Z W! Strict environment variable handling will be the new default starting with v1.38.0! If your configuration works with strict handling or you don't use environment variables it is safe to ignore this warning. Otherwise please explicitly add the --non-strict-env-handling flag!
2025-12-17T14:50:00Z I! Loading config: C:\\Program Files\\InfluxData\\telegraf-1.37.0\\telegraf.conf
2025-12-17T14:50:00Z W! DeprecationWarning: Option "ignore_protocol_stats" of plugin "inputs.net" deprecated since version 1.37.0 and will be removed in 1.45.0: option is ignored
2025-12-17T14:50:00Z I! Starting Telegraf 1.37.0 brought to you by InfluxData the makers of InfluxDB
2025-12-17T14:50:00Z I! Available plugins: 242 inputs, 9 aggregators, 35 processors, 26 parsers, 67 outputs, 7 secret-stores
2025-12-17T14:50:00Z I! Loaded inputs: cpu disk diskio internal mem net netstat procstat system win_perf_counters
2025-12-17T14:50:00Z I! Loaded aggregators:
2025-12-17T14:50:00Z I! Loaded processors:
2025-12-17T14:50:00Z I! Loaded secretstores:
2025-12-17T14:50:00Z I! Loaded outputs: influxdb (2x)
2025-12-17T14:50:00Z I! Tags enabled: IP=0.0.0.0 environment=VAL host=hostname.example.com machine_type=physical os_type=Win32NT os_version=Microsoft Windows Server 2022 Standard 10.0.20348.0 region=N/A
2025-12-17T14:50:00Z W! Deprecated inputs: 0 and 1 options
2025-12-17T14:50:00Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"hostname.example.com", Flush Interval:10s
2025-12-17T14:50:00Z W! [agent] The default value of 'skip_processors_after_aggregators' will change to 'true' with Telegraf v1.40.0! If you need the current default behavior, please explicitly set the option to 'false'!
2025-12-17T14:58:21Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Idle Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T14:58:21Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Processor Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T15:04:30Z I! [agent] Hang on, flushing any cached metrics before shutdown
2025-12-17T15:04:30Z I! [agent] Stopping running outputs
2025-12-17T15:04:31Z W! Strict environment variable handling will be the new default starting with v1.38.0! If your configuration works with strict handling or you don't use environment variables it is safe to ignore this warning. Otherwise please explicitly add the --non-strict-env-handling flag!
2025-12-17T15:04:31Z I! Loading config: C:\\Program Files\\InfluxData\\telegraf-1.37.0\\telegraf.conf
2025-12-17T15:04:31Z W! DeprecationWarning: Option "ignore_protocol_stats" of plugin "inputs.net" deprecated since version 1.37.0 and will be removed in 1.45.0: option is ignored
2025-12-17T15:04:31Z I! Starting Telegraf 1.37.0 brought to you by InfluxData the makers of InfluxDB
2025-12-17T15:04:31Z I! Available plugins: 242 inputs, 9 aggregators, 35 processors, 26 parsers, 67 outputs, 7 secret-stores
2025-12-17T15:04:31Z I! Loaded inputs: cpu disk diskio internal mem net netstat procstat system win_perf_counters
2025-12-17T15:04:31Z I! Loaded aggregators:
2025-12-17T15:04:31Z I! Loaded processors:
2025-12-17T15:04:31Z I! Loaded secretstores:
2025-12-17T15:04:31Z I! Loaded outputs: influxdb (2x)
2025-12-17T15:04:31Z I! Tags enabled: IP=0.0.0.0 environment=VAL host=hostname.example.com machine_type=physical os_type=Win32NT os_version=Microsoft Windows Server 2022 Standard 10.0.20348.0 region=N/A
2025-12-17T15:04:31Z W! Deprecated inputs: 0 and 1 options
2025-12-17T15:04:31Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"hostname.example.com", Flush Interval:10s
2025-12-17T15:04:31Z W! [agent] The default value of 'skip_processors_after_aggregators' will change to 'true' with Telegraf v1.40.0! If you need the current default behavior, please explicitly set the option to 'false'!
2025-12-17T16:43:10Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Idle Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T16:52:10Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Interrupt Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T16:52:10Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Privileged Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T16:52:10Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% User Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T16:52:10Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Processor Time", instance: *, will skip metric: A counter with a negative denominator value was detected.
2025-12-17T16:52:20Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Processor Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T16:59:01Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Idle Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T17:07:40Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Interrupt Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T17:07:40Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Privileged Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T17:07:40Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% User Time", instance: *, will skip metric: A counter with a negative value was detected.
2025-12-17T17:07:40Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Processor Time", instance: *, will skip metric: A counter with a negative denominator value was detected.
2025-12-17T17:07:50Z W! [inputs.win_perf_counters] Error while getting value for counter "\\Processor(*)\\% Processor Time", instance: *, will skip metric: A counter with a negative value was detected.
System info
Telegraf 1.37.0 Windows Server 2022 Standard 21H2 20348.4529 Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz 2.19 GHz (2 processors)
Docker
No response
Steps to reproduce
- Install Telegraf latest version on a windows system with 20 cores and 40 logical processors
- Configure either inputs.cpu or inputs.win_perf_counters plugin to capture cpu percentage usage
Expected behavior
Correct CPU usage values are reported by telegraf
Actual behavior
telegraf reports more than 100% usage and also report negative values
Additional info
I noticed that the issue only happens on a host with more than 20 logical processors , it has 20 cores and 40 logical processors.
I have another machine with 20 cores and 20 logical processors and it doesn't show this behavior.
Activity
srebhan commentedon Jun 8, 2026
@jihed-bengharbia-qiminfo is this behavior reproducible?
I assume this happens because some cores are at sleep when Telegraf queries the data and/or the Windows performance counters overflow (which would produce a negative value)... To verify this I would need some debug information.
Are you willing to test a debug-version of Telegraf and send the output?
jihed-bengharbia-qiminfo commentedon Jun 17, 2026
Hello @srebhan ,
yes it's reproducible , and yes I can test a debug version of telegraf .
srebhan commentedon Jun 22, 2026
@jihed-bengharbia-qiminfo let's first concentrate on the
inputs.cpuplugin as the performance counters might have additional issues (such as the overflows you see in the logs)...Can you please post your
inputs.cpuconfig that leads to the issues mentioned?!? Furthermore, is it possible for you to log the actual raw metrics on the machine e.g. by adding an output withand post the created file here?
Important
Replace the
filessetting above with a path that works for you!srebhan commentedon Jul 7, 2026
@jihed-bengharbia-qiminfo the issue might be caused by in issue in the underlying library (shirou/gopsutil#887). The fixed version of the library is used in Telegraf v1.38.4 and later so can you please repeat your test with a newer version of Telegraf!?
skartikey commentedon Jul 7, 2026
We dug into this further and there are actually two separate problems mixed together in this issue.
The first one explains the per-CPU garbage and the "current total CPU time is less than previous total CPU time" errors. Before Telegraf 1.38.4 the underlying library was not processor-group aware on machines like this one (2 sockets, 40 logical processors), so between two gathers the same cpuN label could refer to a different physical core and the deltas went wild. That is the gopsutil bug @srebhan linked above (shirou/gopsutil#887) and it is fixed in Telegraf 1.38.4 and later.
The second one survives the upgrade: tiny negative values on cpu-total only, in the order of -5e-10. Those come from precision loss inside gopsutil. For cpu-total it converts the Windows counters to float64 too early and then computes kernel - idle, so after a few days of uptime the rounding error is large enough to make the counter look like it went backwards. The per-CPU path subtracts the raw integers first, which is why individual cores are not affected. I filed this upstream with a full analysis and a proposed fix: shirou/gopsutil#2110. Once that lands and Telegraf picks up the new gopsutil release, this part goes away too.
The win_perf_counters warnings in the log are a separate PDH counter story and are not covered by either fix, so I would keep this issue scoped to inputs.cpu.
srebhan commentedon Jul 9, 2026
@jihed-bengharbia-qiminfo please run the debugging binary in PR #19249 with the following config
and provide the resulting log file.
Important
Please adapt the
logfilesetting to a location convenient for you and set theintervalto match your usual config!You can check if an incident occurred by searching for the following text in the log-file
Background: @skartikey and myself checked the plugin code as well as the gopsutil code and (besides of the PR above) cannot see any issue. I also double-checked the (sparse) Windows API documentation and can confirm that processing matches the description. So either there is some reordering of the CPUs (that should not happen according to the Windows documentation) or a misinterpretation of the values returned. Therefore, I added some trace output to provide the raw numbers returned by gopsutil.
skartikey commentedon Jul 20, 2026
Follow-up on the second problem I described above, the "current total CPU time is less than previous total CPU time" errors on cpu-total.
The cause was in gopsutil:
Times(percpu=false)did thekernel - idlesubtraction in floating point, and on a machine with some uptime the rounding error varies between calls, so the values are not monotonic even though the Windows counters are. The fix subtracts the 64-bit tick counts as integers instead. Simulated over 100000 intervals it goes from 27674 phantom decreases to 0.Merged upstream as shirou/gopsutil#2111, but not released yet and we are on v4.26.6. I will open the bump here once it lands in a release.
This does not cover the win_perf_counters negative-counter warnings, which are separate, and the large over-100% readings should already be fixed by the processor-group change in v1.38.4. @jihed-bengharbia-qiminfo, the trace log @srebhan asked for is still worth having to confirm nothing else remains.
srebhan commentedon Aug 3, 2026
@jihed-bengharbia-qiminfo please test the binary in PR #19372, available for 72h once CI finished all tests, and let me know if this fixes the issue!