-
Notifications
You must be signed in to change notification settings - Fork 526
[elastic_agent] Fix Agent Metrics "[Elastic Agent] CPU Usage" chart #16948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
e63bdf1 to
796267f
Compare
|
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
Fix the "[Elastic Agent] CPU Usage" dashboard panel to correctly calculate
CPU percentage regardless of the selected time window.
## Problem
The CPU usage formula used `interval()` to determine the time divisor when
calculating CPU percentage from cumulative CPU time:
differences(max(system.process.cpu.total.time.ms)) / interval()
`interval()` returns the Kibana bucket interval (time window ÷ number of buckets),
not the actual time between consecutive data points. Since metrics are collected
at fixed intervals (e.g., every 60 seconds), but bucket intervals vary with the
selected time window, this caused:
- Correct values at small time windows (when bucket interval ≈ collection interval)
- Artificially low values at large time windows (when bucket interval > collection interval)
## Solution
Replace `interval()` with `counter_rate(max(@timestamp))` to calculate the actual
elapsed time between consecutive data points:
counter_rate(max(system.process.cpu.total.time.ms)) / counter_rate(max(@timestamp))
`counter_rate()` instead of `differences()` as it automatically handles counter resets.
5f13eb7 to
9de7d47
Compare
🚀 Benchmarks reportTo see the full report comment with |
💚 Build Succeeded
History
cc @AndersonQ |
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
belimawr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, however when testing on an existing cluster (I installed the integration using Elastic-Package), the "Agent hostname" filter stopped working
Clicking on "View more" shows nothing.
I also managed to reproduce it with Elastic-Package and a 9.2.3 stack:
- Start Elastic-Package
- Create a policy and add an Elastic Agent
- Update the Elastic Agent integration
- Go to the dashboard
Could you take a look at it @AndersonQ? Maybe there was some small change in the filter that is incompatible with 9.2?
Interesting, I'll investigate. Thanks for catching that! |


Proposed commit message
Checklist
[ ] I have reviewed tips for building integrations and this pull request is aligned with them.[ ] I have verified that all data streams collect metrics or logs.changelog.ymlfile.[ ] I have verified that Kibana version constraints are current according to guidelines.[ ] I have verified that any added dashboard complies with Kibana's Dashboard good practicesAuthor's Checklist
How to test this PR locally
scripts.tar.gz. It's a script to load mock data to ES
ELASTIC_PACKAGE_ELASTICSEARCH_HOSTELASTIC_PACKAGE_ELASTICSEARCH_USERNAMEELASTIC_PACKAGE_ELASTICSEARCH_PASSWORDimport_index.shnavigate to the "[Elastic Agent] Agent metrics" dashboard
set the time to
Jan 11, 2026 @ 23:00:00.000->Jan 13, 2026 @ 06:00:00.000select the
mokona-elastic-mockagentplay with the time range
regardless of the chosen time range the CPU usage should stay constant
the data on
Jan 12is a constant: All 4 components run at constant 10% CPU usage. Total: 40%the data for
Jan 13is variable:elastic-agentandfilebeat-default: 5% baseline, spike to 35% for 5 minutes every 30 minutesmetricbeat-defaultandfleet-server-default: 10% constantRelated issues
Screenshots