You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The calculated per-process utilization values seem very different from what's described in documentation. Instead of values between [0.0, 1.0], I'm seeing values between [-1500.0, 2000.0].
Steps to Reproduce
Enable collection of process.cpu.utilization using the hostmetrics receiver. After two collections, the value for all processes will be available in whatever exporter's being used.
Expected Result
From the doc:
Percentage of total CPU time used by the process since last scrape, expressed as a value between 0 and 1.
Actual Result
Values way outside that range, including negative numbers. Below is a screenshot of process.cpu.utilization exported to Prometheus over several minutes
Looking at how this value is calculated, I think the issue is that a single CPUUtilizationCalculator is being used to calculate utilization for all processes, not a specific process. Because it resets previousReadTime each time it records a metric, the elapsedTime value is actually the time elapsed since the last call to the calculator, rather than the collection interval. I think this could be addressed by maintaining a map of PIDs to CPUUtilizationCalculators.
Component(s)
receiver/hostmetrics
What happened?
Description
The calculated per-process utilization values seem very different from what's described in documentation. Instead of values between [0.0, 1.0], I'm seeing values between [-1500.0, 2000.0].
Steps to Reproduce
Enable collection of
process.cpu.utilization
using thehostmetrics
receiver. After two collections, the value for all processes will be available in whatever exporter's being used.Expected Result
From the doc:
Actual Result
Values way outside that range, including negative numbers. Below is a screenshot of
process.cpu.utilization
exported to Prometheus over several minutesCollector version
848486f
Environment information
Environment
OS: Ubuntu 20.04
Compiler(if manually compiled): go 1.20.1
OpenTelemetry Collector configuration
Log output
No response
Additional context
Looking at how this value is calculated, I think the issue is that a single
CPUUtilizationCalculator
is being used to calculate utilization for all processes, not a specific process. Because it resetspreviousReadTime
each time it records a metric, theelapsedTime
value is actually the time elapsed since the last call to the calculator, rather than the collection interval. I think this could be addressed by maintaining a map of PIDs toCPUUtilizationCalculator
s.https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/hostmetricsreceiver/internal/scraper/processscraper/ucal/cpu_utilization_calculator.go#L46
The text was updated successfully, but these errors were encountered: