From 2083a224e43bdebb16a633f8363cccdf4d9d227f Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 10 May 2019 13:31:49 +0200 Subject: [PATCH] Add number of goroutines to reported metrics (#12135) --- CHANGELOG.next.asciidoc | 1 + libbeat/cmd/instance/metrics.go | 8 ++++++++ libbeat/docs/http-endpoint.asciidoc | 3 +++ libbeat/monitoring/report/log/log.go | 1 + 4 files changed, 13 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index aa1ddbc4119e..eaa4a309c6c7 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -148,6 +148,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Add `decode_csv_fields` processor. {pull}11753[11753] - Add `convert` processor for converting data types of fields. {issue}8124[8124] {pull}11686[11686] - New `extract_array` processor. {pull}11761[11761] +- Add number of goroutines to reported metrics. {pull}12135[12135] *Auditbeat* diff --git a/libbeat/cmd/instance/metrics.go b/libbeat/cmd/instance/metrics.go index 35df8092d878..9b0697d1e0bf 100644 --- a/libbeat/cmd/instance/metrics.go +++ b/libbeat/cmd/instance/metrics.go @@ -57,6 +57,7 @@ func setupMetrics(name string) error { monitoring.NewFunc(beatMetrics, "memstats", reportMemStats, monitoring.Report) monitoring.NewFunc(beatMetrics, "cpu", reportBeatCPU, monitoring.Report) + monitoring.NewFunc(beatMetrics, "runtime", reportRuntime, monitoring.Report) setupPlatformSpecificMetrics() @@ -246,3 +247,10 @@ func reportSystemCPUUsage(_ monitoring.Mode, V monitoring.Visitor) { monitoring.ReportInt(V, "cores", int64(process.NumCPU)) } + +func reportRuntime(_ monitoring.Mode, V monitoring.Visitor) { + V.OnRegistryStart() + defer V.OnRegistryFinished() + + monitoring.ReportInt(V, "goroutines", int64(runtime.NumGoroutine())) +} diff --git a/libbeat/docs/http-endpoint.asciidoc b/libbeat/docs/http-endpoint.asciidoc index 1dda3341e0c9..54e0944002ce 100644 --- a/libbeat/docs/http-endpoint.asciidoc +++ b/libbeat/docs/http-endpoint.asciidoc @@ -95,6 +95,9 @@ curl -XGET 'localhost:5066/stats?pretty' "memory_alloc": 9433384, "memory_total": 492478864, "rss": 50405376 + }, + "runtime": { + "goroutines": 22 } }, "libbeat": { diff --git a/libbeat/monitoring/report/log/log.go b/libbeat/monitoring/report/log/log.go index ecd680bc6276..bd6bf9e43cc2 100644 --- a/libbeat/monitoring/report/log/log.go +++ b/libbeat/monitoring/report/log/log.go @@ -55,6 +55,7 @@ var gauges = map[string]bool{ "beat.handles.open": true, "beat.handles.limit.hard": true, "beat.handles.limit.soft": true, + "beat.runtime.goroutines": true, "system.load.1": true, "system.load.5": true, "system.load.15": true,