diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index f3535ce1398f..5f65b5f5222c 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -105,6 +105,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 364080519526..7a5be48fefeb 100644 --- a/libbeat/autodiscover/autodiscover.go +++ b/libbeat/autodiscover/autodiscover.go @@ -283,6 +283,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 @@ -300,7 +305,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