Error retrieving collection totals from Mongo instance

Hello,
I'm using metricbeat v6.3 & kibana v6.7.1, recently I'm trying to add my mongoDB stats to metricbeat dashboard and enabled module on mongodb under /etc/metricbeat/module.d/mongodb.yaml using following command.

sudo metricbeat modules enable mongodb

But when I restart the metricbeat service, I do see that metricbeat logs are showing some errors . getting mongodb stats.

|2019-05-28T07:10:42.802Z|ERROR|collstats/collstats.go:66|Error retrieving collection totals from Mongo instance|
|---|---|---|---|
|2019-05-28T07:10:42.820Z|ERROR|schema/schema.go:41|Error on field 'mb': Missing field: mb, Error: Key mapped not found|
|2019-05-28T07:10:42.820Z|ERROR|schema/schema.go:41|Error on field 'mb': Missing field: mb, Error: Key mappedWithJournal not found|
|2019-05-28T07:10:42.820Z|ERROR|mapstriface/mapstriface.go:80|Error accessing sub-dictionary `opcountersRepl`|
|2019-05-28T07:10:42.820Z|ERROR|mapstriface/mapstriface.go:80|Error accessing sub-dictionary `storageEngine`|
|2019-05-28T07:10:42.966Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-28T07:10:42.966Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-28T07:10:42.968Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-28T07:10:42.968Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-28T07:10:42.970Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-28T07:10:42.970Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-28T07:10:42.971Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-28T07:10:42.971Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-28T07:10:42.976Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-28T07:10:42.976Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-28T07:10:42.978Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|

My mongodb instance can be directly accessed through localhost and port is 27017. Following is my metricbeat configuration file.

- module: mongodb
  hosts: ["localhost:27017"]
  period: 10s
  enabled: true 

Any help would be greatly appreciated.

Thanks.

Hello @madurad, thanks for all the detailed information. By looking at your metricbeat mongodb configuration, it appears to be you are missing the part that enables metricsets in mongodb module, for example metricsets: ["dbstats", "status", "collstats", "metrics", "replstatus"]. This might help https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-mongodb.html#_example_configuration_23. Can you please add the missing metricsets line into your config and restart metricbeat?

Hi @Kaiyan_Sheng Thanks for replying, I'll change those configurations and update you.

Thanks.

1 Like

@Kaiyan_Sheng I added the metrics and now my .yaml file looks like below.

- module: mongodb
  hosts: ["localhost:27017"]
  metricsets: ["dbstats", "status", "collstats"]
  period: 10s
  enabled: true

But still getting the same error, could you please look more in to this.

|2019-05-29T04:00:31.439Z|ERROR|collstats/collstats.go:66|Error retrieving collection totals from Mongo instance|
|---|---|---|---|
|2019-05-29T04:00:31.445Z|ERROR|mapstriface/mapstriface.go:80|Error accessing sub-dictionary `opcountersRepl`|
|2019-05-29T04:00:31.445Z|ERROR|mapstriface/mapstriface.go:80|Error accessing sub-dictionary `storageEngine`|
|2019-05-29T04:00:31.445Z|ERROR|schema/schema.go:41|Error on field 'mb': Missing field: mb, Error: Key mapped not found|
|2019-05-29T04:00:31.445Z|ERROR|schema/schema.go:41|Error on field 'mb': Missing field: mb, Error: Key mappedWithJournal not found|
|2019-05-29T04:00:31.511Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-29T04:00:31.511Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-29T04:00:31.513Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-29T04:00:31.514Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-29T04:00:31.515Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|
|2019-05-29T04:00:31.515Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-29T04:00:31.517Z|ERROR|schema/schema.go:41|Error on field 'db': Missing field: db, Error: Key db not found: key not found|
|2019-05-29T04:00:31.517Z|ERROR|schema/schema.go:41|Error on field 'collections': Missing field: collections, Error: Key collections not found|

Thanks

It seems the output from your mongodb instance misses some keys. What version of mongodb are you using?

@ruflin MongoDB version : v3.4

By looking at the MongoDB 3.4 documentation, seems like these keys are supported for 3.4:
https://docs.mongodb.com/v3.4/reference/command/serverStatus/#opcountersrepl
https://docs.mongodb.com/v3.4/reference/command/serverStatus/#storageEngine

Besides that, we also did some changes in mapstriface.go in newer version of Metricbeat. I see you are using metricbeat v6.3 for now, is is possible to upgrade metricbeat to a newer version?

@Kaiyan_Sheng which version do you recommend ?

Based on the code https://github.com/elastic/beats/blob/6.4/libbeat/common/schema/mapstriface/mapstriface.go#L98, 6.4 version or above should have this fix. If you want to give it a try, that would be great!

@Kaiyan_Sheng I'll try upgrade it to 6.4 or above and get back to you.

@madurad Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.