diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 6ae5e34c11c..bf2afb99408 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -134,6 +134,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - The `monitoring.elasticsearch.api_key` value is correctly base64-encoded before being sent to the monitoring Elasticsearch cluster. {issue}18939[18939] {pull}18945[18945] - Fix kafka topic setting not allowing upper case characters. {pull}18854[18854] {issue}18640[18640] - Fix redis key setting not allowing upper case characters. {pull}18854[18854] {issue}18640[18640] +- Fix config reload metrics (`libbeat.config.module.start/stops/running`). {pull}19168[19168] - Fix metrics hints builder to avoid wrong container metadata usage when port is not exposed {pull}18979[18979] *Auditbeat* diff --git a/libbeat/cfgfile/list.go b/libbeat/cfgfile/list.go index c38689d65b4..fc50baa3345 100644 --- a/libbeat/cfgfile/list.go +++ b/libbeat/cfgfile/list.go @@ -85,6 +85,7 @@ func (r *RunnerList) Reload(configs []*reload.ConfigWithMeta) error { r.logger.Debugf("Stopping runner: %s", runner) delete(r.runners, hash) go runner.Stop() + moduleStops.Add(1) } // Start new runners @@ -99,8 +100,15 @@ func (r *RunnerList) Reload(configs []*reload.ConfigWithMeta) error { r.logger.Debugf("Starting runner: %s", runner) r.runners[hash] = runner runner.Start() + moduleStarts.Add(1) } + // NOTE: This metric tracks the number of modules in the list. The true + // number of modules in the running state may differ because modules can + // stop on their own (i.e. on errors) and also when this stops a module + // above it is done asynchronously. + moduleRunning.Set(int64(len(r.runners))) + return errs.Err() } diff --git a/libbeat/cfgfile/reload.go b/libbeat/cfgfile/reload.go index a4ae1e6733b..d1fccab9d61 100644 --- a/libbeat/cfgfile/reload.go +++ b/libbeat/cfgfile/reload.go @@ -52,7 +52,7 @@ var ( configReloads = monitoring.NewInt(nil, "libbeat.config.reloads") moduleStarts = monitoring.NewInt(nil, "libbeat.config.module.starts") moduleStops = monitoring.NewInt(nil, "libbeat.config.module.stops") - moduleRunning = monitoring.NewInt(nil, "libbeat.config.module.running") + moduleRunning = monitoring.NewInt(nil, "libbeat.config.module.running") // Number of modules in the runner list (not necessarily in the running state). ) // DynamicConfig loads config files from a given path, allowing to reload new changes