Skip to content
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

[metricbeat] Fallback to different CPU calculation if we have no online_cpu count #15070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Closing handler after verifying the registry key in diskio metricset. {issue}14683[14683] {pull}14759[14759]
- Fix docker network stats when multiple interfaces are configured. {issue}14586[14586] {pull}14825[14825]
- Fix ListMetrics pagination in aws module. {issue}14926[14926] {pull}14942[14942]
- Fix CPU count in docker/cpu in cases where no `online_cpus` are reported {pull}15070[15070]
- Fix mixed modules loading standard and light metricsets {pull}15011[15011]

*Packetbeat*
Expand Down
15 changes: 14 additions & 1 deletion metricbeat/module/docker/cpu/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,20 @@ type cpuUsage struct {
// be updated/initialized with the corresponding value retrieved from Docker API.
func (u *cpuUsage) CPUs() uint32 {
if u.cpus == 0 {
u.cpus = u.Stats.CPUStats.OnlineCPUs
if u.Stats.CPUStats.OnlineCPUs != 0 {
u.cpus = u.Stats.CPUStats.OnlineCPUs
} else {
//Certain versions of docker don't have `online_cpus`
//In addition to this, certain kernel versions will report spurious zeros from the cgroups usage_percpu
var realCPUCount uint32
for _, rCPUUsage := range u.Stats.CPUStats.CPUUsage.PercpuUsage {
if rCPUUsage != 0 {
realCPUCount++
}
}
u.cpus = realCPUCount
}

}
return u.cpus
}
Expand Down