diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 59fc36164a76..c79119b955c7 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -127,6 +127,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fix a bug where log files are rotated on startup when interval is configured and rotateonstartup is disabled {issue}41894[41894] {pull}41895[41895] - Fix setting unique registry for non beat receivers {issue}42288[42288] {pull}42292[42292] - The Kafka output now drops events when there is an authorisation error {issue}42343[42343] {pull}42401[42401] +- Fix autodiscovery memory leak related to metadata of start events {pull}41748[41748] *Auditbeat* diff --git a/libbeat/autodiscover/autodiscover.go b/libbeat/autodiscover/autodiscover.go index 27739c2e5610..400727c68d17 100644 --- a/libbeat/autodiscover/autodiscover.go +++ b/libbeat/autodiscover/autodiscover.go @@ -287,6 +287,11 @@ func (a *Autodiscover) handleStop(event bus.Event) bool { updated = true } + // Cleanup meta references for this eventID + for configHash := range a.configs[eventID] { + a.meta.Remove(configHash) + } + delete(a.configs, eventID) return updated @@ -304,7 +309,7 @@ func (a *Autodiscover) getMeta(event bus.Event) mapstr.M { a.logger.Errorf("Got a wrong meta field for event %v", event) return nil } - return meta + return meta.Clone() } // getID returns the event "id" field string if present