diff --git a/libbeat/cmd/instance/metrics.go b/libbeat/cmd/instance/metrics.go index af8998d42e9..d9de7eb0f03 100644 --- a/libbeat/cmd/instance/metrics.go +++ b/libbeat/cmd/instance/metrics.go @@ -42,12 +42,10 @@ func init() { func setupMetrics(name string) error { monitoring.NewFunc(beatMetrics, "memstats", reportMemStats, monitoring.Report) monitoring.NewFunc(beatMetrics, "cpu", reportBeatCPU, monitoring.Report) - monitoring.NewFunc(beatMetrics, "fd", reportFDUsage, monitoring.Report) monitoring.NewFunc(systemMetrics, "cpu", reportSystemCPUUsage, monitoring.Report) - if runtime.GOOS != "windows" { - monitoring.NewFunc(systemMetrics, "load", reportSystemLoadAverage, monitoring.Report) - } + + setupPlatformSpecificMetrics() beatProcessStats = &process.Stats{ Procs: []string{name}, @@ -61,6 +59,16 @@ func setupMetrics(name string) error { return err } +func setupPlatformSpecificMetrics() { + if runtime.GOOS != "windows" { + monitoring.NewFunc(systemMetrics, "load", reportSystemLoadAverage, monitoring.Report) + } + + if runtime.GOOS == "linux" { + monitoring.NewFunc(beatMetrics, "fd", reportFDUsage, monitoring.Report) + } +} + func reportMemStats(m monitoring.Mode, V monitoring.Visitor) { var stats runtime.MemStats runtime.ReadMemStats(&stats) @@ -226,8 +234,6 @@ func reportFDUsage(_ monitoring.Mode, V monitoring.Visitor) { func getFDUsage() (open, hardLimit, softLimit uint64, err error) { state, err := getBeatProcessState() if err != nil { - // TODO copy - logp.Err("baj van") return 0, 0, 0, err }