Skip to content

Commit 33b05cd

Browse files
added CPU usage check to memory stats list
1 parent 683f4f7 commit 33b05cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

metricbeat/module/docker/memory/helper.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func (s *MemoryService) getMemoryStatsList(containers []docker.Stat, dedot bool)
4343
for _, containerStats := range containers {
4444
//There appears to be a race where a container will report with a stat object before it actually starts
4545
//during this time, there doesn't appear to be any meaningful data,
46-
// and Limit will never be 0 unless the container is not running & there's no cgroup data
47-
if containerStats.Stats.MemoryStats.Limit == 0 {
46+
// and Limit will never be 0 unless the container is not running
47+
//and there's no cgroup data, and CPU usage should be greater than 0 for any running container.
48+
if containerStats.Stats.MemoryStats.Limit == 0 && containerStats.Stats.PreCPUStats.CPUUsage.TotalUsage == 0 {
4849
continue
4950
}
5051
formattedStats = append(formattedStats, s.getMemoryStats(containerStats, dedot))

0 commit comments

Comments
 (0)