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

Fix docker.cpu.system.pct calculation #13691

Merged
merged 4 commits into from
Sep 17, 2019
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 @@ -192,6 +192,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426]
- Fix module-level fields in Kubernetes metricsets. {pull}13433[13433] {pull}13544[13544]
- Fix reporting empty events in cloudwatch metricset. {pull}13458[13458]
- Fix `docker.cpu.system.pct` calculation by using the reported number online cpus instead of the number of metrics per cpu. {pull}13691[13691]

*Packetbeat*

Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/docker/cpu/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestCPUService_PerCpuUsage(t *testing.T) {
for index := range statsList {
statsList[index].PreCPUStats.CPUUsage.PercpuUsage = oldPerCpuValuesTest[index]
statsList[index].CPUStats.CPUUsage.PercpuUsage = newPerCpuValuesTest[index]
statsList[index].CPUStats.OnlineCPUs = 4
}
testCase := []struct {
given types.StatsJSON
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/docker/cpu/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func (c *CPUService) getCPUStats(myRawStat *docker.Stat, dedot bool) CPUStats {
type cpuUsage struct {
*docker.Stat

cpus int
cpus uint32
systemDelta uint64
}

func (u *cpuUsage) CPUs() int {
func (u *cpuUsage) CPUs() uint32 {
if u.cpus == 0 {
u.cpus = len(u.Stats.CPUStats.CPUUsage.PercpuUsage)
u.cpus = u.Stats.CPUStats.OnlineCPUs
}
return u.cpus
}
Expand Down