From 1a2af5cb8649e2b3106ee20341fc30a90e9e3bde Mon Sep 17 00:00:00 2001 From: Adrian Serrano Date: Mon, 28 Sep 2020 20:33:47 +0200 Subject: [PATCH] Fix panic in cgroups monitoring Gosigar's cgroups GetStatsForProcesses can return a nil Stats pointer and no error when the ["blkio", "cpu", "cpuacct", "memory"] subsystems are on the root cgroup. Related #21113 --- libbeat/cmd/instance/metrics.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libbeat/cmd/instance/metrics.go b/libbeat/cmd/instance/metrics.go index fa0d42bbeafd..24d3d12e3e19 100644 --- a/libbeat/cmd/instance/metrics.go +++ b/libbeat/cmd/instance/metrics.go @@ -285,6 +285,10 @@ func reportBeatCgroups(_ monitoring.Mode, V monitoring.Visitor) { logp.Err("error getting group status: %v", err) return } + // GetStatsForProcess returns a nil selfStats and no error when there's no stats + if selfStats == nil { + return + } if cpu := selfStats.CPU; cpu != nil { monitoring.ReportNamespace(V, "cpu", func() {