From bbf4156ab09e3782149d43c1fa92d17895bb8d41 Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Thu, 9 May 2019 10:14:29 -0500 Subject: [PATCH] [metricbeat] added CPU usage check to docker memory stats (#12062) --- metricbeat/module/docker/memory/helper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metricbeat/module/docker/memory/helper.go b/metricbeat/module/docker/memory/helper.go index 69f26c370ac..1e5524e75ed 100644 --- a/metricbeat/module/docker/memory/helper.go +++ b/metricbeat/module/docker/memory/helper.go @@ -43,8 +43,9 @@ func (s *MemoryService) getMemoryStatsList(containers []docker.Stat, dedot bool) for _, containerStats := range containers { //There appears to be a race where a container will report with a stat object before it actually starts //during this time, there doesn't appear to be any meaningful data, - // and Limit will never be 0 unless the container is not running & there's no cgroup data - if containerStats.Stats.MemoryStats.Limit == 0 { + // and Limit will never be 0 unless the container is not running + //and there's no cgroup data, and CPU usage should be greater than 0 for any running container. + if containerStats.Stats.MemoryStats.Limit == 0 && containerStats.Stats.PreCPUStats.CPUUsage.TotalUsage == 0 { continue } formattedStats = append(formattedStats, s.getMemoryStats(containerStats, dedot))