diff --git a/metricbeat/docs/modules/mongodb.asciidoc b/metricbeat/docs/modules/mongodb.asciidoc index d22da1dd170..ff93260545e 100644 --- a/metricbeat/docs/modules/mongodb.asciidoc +++ b/metricbeat/docs/modules/mongodb.asciidoc @@ -47,6 +47,8 @@ over the username and password configuration options. password: test ---- +The default metricsets are `collstats`, `dbstats` and `status`. + [float] === Compatibility @@ -64,21 +66,7 @@ in <>. Here is an example configuration: ---- metricbeat.modules: - module: mongodb - metricsets: ["dbstats", "status"] - period: 10s - - # The hosts must be passed as MongoDB URLs in the format: - # [mongodb://][user:pass@]host[:port]. - # The username and password can also be set using the respective configuration - # options. The credentials in the URL take precedence over the username and - # password configuration options. hosts: ["localhost:27017"] - - # Username to use when connecting to MongoDB. Empty by default. - #username: user - - # Password to use when connecting to MongoDB. Empty by default. - #password: pass ---- [float] diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index b90f3875cf5..e4b6171c1ae 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -366,6 +366,7 @@ metricbeat.modules: - module: mongodb metricsets: ["dbstats", "status"] period: 10s + enabled: true # The hosts must be passed as MongoDB URLs in the format: # [mongodb://][user:pass@]host[:port]. diff --git a/metricbeat/module/mongodb/_meta/config.reference.yml b/metricbeat/module/mongodb/_meta/config.reference.yml new file mode 100644 index 00000000000..8f2386a21f1 --- /dev/null +++ b/metricbeat/module/mongodb/_meta/config.reference.yml @@ -0,0 +1,17 @@ +- module: mongodb + metricsets: ["dbstats", "status"] + period: 10s + enabled: true + + # The hosts must be passed as MongoDB URLs in the format: + # [mongodb://][user:pass@]host[:port]. + # The username and password can also be set using the respective configuration + # options. The credentials in the URL take precedence over the username and + # password configuration options. + hosts: ["localhost:27017"] + + # Username to use when connecting to MongoDB. Empty by default. + #username: user + + # Password to use when connecting to MongoDB. Empty by default. + #password: pass diff --git a/metricbeat/module/mongodb/_meta/config.yml b/metricbeat/module/mongodb/_meta/config.yml index fb6b19e7c68..f22fc37872d 100644 --- a/metricbeat/module/mongodb/_meta/config.yml +++ b/metricbeat/module/mongodb/_meta/config.yml @@ -1,16 +1,2 @@ - module: mongodb - metricsets: ["dbstats", "status"] - period: 10s - - # The hosts must be passed as MongoDB URLs in the format: - # [mongodb://][user:pass@]host[:port]. - # The username and password can also be set using the respective configuration - # options. The credentials in the URL take precedence over the username and - # password configuration options. hosts: ["localhost:27017"] - - # Username to use when connecting to MongoDB. Empty by default. - #username: user - - # Password to use when connecting to MongoDB. Empty by default. - #password: pass diff --git a/metricbeat/module/mongodb/_meta/docs.asciidoc b/metricbeat/module/mongodb/_meta/docs.asciidoc index 258ea6611a9..84091262cbd 100644 --- a/metricbeat/module/mongodb/_meta/docs.asciidoc +++ b/metricbeat/module/mongodb/_meta/docs.asciidoc @@ -40,6 +40,8 @@ over the username and password configuration options. password: test ---- +The default metricsets are `collstats`, `dbstats` and `status`. + [float] === Compatibility diff --git a/metricbeat/module/mongodb/collstats/collstats.go b/metricbeat/module/mongodb/collstats/collstats.go index e51ba471b13..53df280394d 100644 --- a/metricbeat/module/mongodb/collstats/collstats.go +++ b/metricbeat/module/mongodb/collstats/collstats.go @@ -14,9 +14,10 @@ import ( var debugf = logp.MakeDebug("mongodb.collstats") func init() { - if err := mb.Registry.AddMetricSet("mongodb", "collstats", New, mongodb.ParseURL); err != nil { - panic(err) - } + mb.Registry.MustAddMetricSet("mongodb", "collstats", New, + mb.WithHostParser(mongodb.ParseURL), + mb.DefaultMetricSet(), + ) } // MetricSet type defines all fields of the MetricSet diff --git a/metricbeat/module/mongodb/dbstats/dbstats.go b/metricbeat/module/mongodb/dbstats/dbstats.go index d68b4288d02..63d74b56f4b 100644 --- a/metricbeat/module/mongodb/dbstats/dbstats.go +++ b/metricbeat/module/mongodb/dbstats/dbstats.go @@ -16,9 +16,10 @@ var debugf = logp.MakeDebug("mongodb.dbstats") // init registers the MetricSet with the central registry. // The New method will be called after the setup of the module and before starting to fetch data func init() { - if err := mb.Registry.AddMetricSet("mongodb", "dbstats", New, mongodb.ParseURL); err != nil { - panic(err) - } + mb.Registry.MustAddMetricSet("mongodb", "dbstats", New, + mb.WithHostParser(mongodb.ParseURL), + mb.DefaultMetricSet(), + ) } // MetricSet type defines all fields of the MetricSet diff --git a/metricbeat/module/mongodb/status/status.go b/metricbeat/module/mongodb/status/status.go index 84e3f27f346..9dc0510bc99 100644 --- a/metricbeat/module/mongodb/status/status.go +++ b/metricbeat/module/mongodb/status/status.go @@ -19,9 +19,10 @@ TODOs: var debugf = logp.MakeDebug("mongodb.status") func init() { - if err := mb.Registry.AddMetricSet("mongodb", "status", New, mongodb.ParseURL); err != nil { - panic(err) - } + mb.Registry.MustAddMetricSet("mongodb", "status", New, + mb.WithHostParser(mongodb.ParseURL), + mb.DefaultMetricSet(), + ) } // MetricSet type defines all fields of the MetricSet diff --git a/metricbeat/modules.d/mongodb.yml.disabled b/metricbeat/modules.d/mongodb.yml.disabled index fb6b19e7c68..f22fc37872d 100644 --- a/metricbeat/modules.d/mongodb.yml.disabled +++ b/metricbeat/modules.d/mongodb.yml.disabled @@ -1,16 +1,2 @@ - module: mongodb - metricsets: ["dbstats", "status"] - period: 10s - - # The hosts must be passed as MongoDB URLs in the format: - # [mongodb://][user:pass@]host[:port]. - # The username and password can also be set using the respective configuration - # options. The credentials in the URL take precedence over the username and - # password configuration options. hosts: ["localhost:27017"] - - # Username to use when connecting to MongoDB. Empty by default. - #username: user - - # Password to use when connecting to MongoDB. Empty by default. - #password: pass