Skip to content

[elastic_agent] add system.cpu.cores to CPU utilization calculation in dashboards#19511

Merged
leehinman merged 3 commits into
elastic:mainfrom
leehinman:14862_add_system.cpu.cores
Jun 15, 2026
Merged

[elastic_agent] add system.cpu.cores to CPU utilization calculation in dashboards#19511
leehinman merged 3 commits into
elastic:mainfrom
leehinman:14862_add_system.cpu.cores

Conversation

@leehinman

@leehinman leehinman commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Proposed commit message

Add system.cpu.cores field and normalize CPU usage metrics

  • Adds system.cpu.cores as a new gauge field to the elastic_agent_metrics data stream, capturing the number of CPUs on the system.
  • Updates the Agent Metrics dashboard CPU usage formula to normalize by core count when available: if system.cpu.cores is present, CPU time is divided by the core count before computing the rate, falling back to the raw system.process.cpu.total.pct value. This gives a more accurate per-core CPU utilization view on multi-core hosts.

Formula for calculating CPU went from

pick_max(
  pick_max(
    counter_rate(
      defaults(max(system.process.cpu.total.time.ms),0)
      )/counter_rate(max(@timestamp)),
    0
  ),
  defaults(max(system.process.cpu.total.pct),0)
)

to

pick_max(
  pick_max(
    counter_rate(
      defaults(
        divide(
          max(system.process.cpu.total.time.ms),
          ifelse(
            count(kql='system.cpu.cores : *') > 0,
            max(system.cpu.cores),
            1
          )
        )
        ,0)
      )/counter_rate(max(@timestamp)),
    0
  ),
  defaults(max(system.process.cpu.total.pct),0)
)

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.
  • I have added an entry to my package's changelog.yml file.
  • 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 practices

Author's Checklist

  • [ ]

How to test this PR locally

  • Install elastic-agent on host with single CPU and multiple CPU.
  • Install version 2.9.4 of elastic_agent package
  • Use version of elastic-agent with and without add system.cpu.cores field to monitoring elastic-agent#14885
  • Verify Agent Metrics dashboard still works and CPU utilization is normalized per CPU
  • Verify that agents that don't have the system.cpu.cores field continue to display as they do today

Related issues

Screenshots

Agent one CPU

Screenshot 2026-06-11 at 18 15 09 Screenshot 2026-06-11 at 18 16 19

Agent 4 CPUs

Screenshot 2026-06-11 at 18 15 43 Screenshot 2026-06-11 at 18 16 05

Agent before elastic/elastic-agent#14885

Screenshot 2026-06-11 at 18 28 32 Screenshot 2026-06-11 at 18 29 29

normalize cpu usage by number of cores if present
@github-actions

Copy link
Copy Markdown
Contributor

✅ Elastic Docs Style Checker (Vale)

No issues found on modified lines!


The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown

✅ All changelog entries have the correct PR link.

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

@leehinman leehinman marked this pull request as ready for review June 12, 2026 15:59
@leehinman leehinman requested review from a team as code owners June 12, 2026 15:59
@andrewkroh andrewkroh added dashboard Relates to a Kibana dashboard bug, enhancement, or modification. Integration:elastic_agent Elastic Agent labels Jun 12, 2026
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Agent Data Plane team [elastic/elastic-agent-data-plane] label Jun 14, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@leehinman leehinman merged commit 03845d3 into elastic:main Jun 15, 2026
10 checks passed
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown

Package elastic_agent - 2.9.4 containing this change is available at https://epr.elastic.co/package/elastic_agent/2.9.4/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Relates to a Kibana dashboard bug, enhancement, or modification. Integration:elastic_agent Elastic Agent Team:Elastic-Agent-Data-Plane Agent Data Plane team [elastic/elastic-agent-data-plane]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants