diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 495cf9156532..6738a1339365 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -63,6 +63,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di - Fix the fetching of process information when some data is missing under MacOS X. {issue}5337[5337] - Change `MySQL active connections` visualization title to `MySQL total connections`. {issue}4812[4812] - Fix map overwrite in docker diskio module. {issue}5582[5582] +- Fix connection leak in mongodb module. {issue}5688[5688] *Packetbeat* diff --git a/metricbeat/module/mongodb/dbstats/dbstats.go b/metricbeat/module/mongodb/dbstats/dbstats.go index 9af1a9aadfb4..19beedb75236 100644 --- a/metricbeat/module/mongodb/dbstats/dbstats.go +++ b/metricbeat/module/mongodb/dbstats/dbstats.go @@ -61,6 +61,7 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) { if err != nil { return nil, err } + defer mongoSession.Close() // Get the list of databases names, which we'll use to call db.stats() on each dbNames, err := mongoSession.DatabaseNames() diff --git a/metricbeat/module/mongodb/status/status.go b/metricbeat/module/mongodb/status/status.go index bc522d52ba08..9d3711d52019 100644 --- a/metricbeat/module/mongodb/status/status.go +++ b/metricbeat/module/mongodb/status/status.go @@ -63,6 +63,7 @@ func (m *MetricSet) Fetch() (common.MapStr, error) { if err != nil { return nil, err } + defer mongoSession.Close() result := map[string]interface{}{} if err := mongoSession.DB("admin").Run(bson.D{{Name: "serverStatus", Value: 1}}, &result); err != nil {