From 75b1ff790f32716c4598a161ce7414bab69920e8 Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Thu, 2 Sep 2021 10:10:31 -0700 Subject: [PATCH] add LIBBEAT_MONITORING_CGROUPS_HIERARCHY_OVERRIDE to system/process (#27700) --- metricbeat/module/system/process/process.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/metricbeat/module/system/process/process.go b/metricbeat/module/system/process/process.go index 6d435f5e3fc0..9928f34bdf5b 100644 --- a/metricbeat/module/system/process/process.go +++ b/metricbeat/module/system/process/process.go @@ -21,6 +21,7 @@ package process import ( "fmt" + "os" "runtime" "github.com/pkg/errors" @@ -90,6 +91,15 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { perCPU: config.IncludePerCPU, IsAgent: systemModule.IsAgent, } + + // If hostfs is set, we may not want to force the hierarchy override, as the user could be expecting a custom path. + if len(paths.Paths.Hostfs) < 2 { + override, isset := os.LookupEnv("LIBBEAT_MONITORING_CGROUPS_HIERARCHY_OVERRIDE") + if isset { + m.stats.CgroupOpts.CgroupsHierarchyOverride = override + } + } + err := m.stats.Init() if err != nil { return nil, err