# Getting error for mongodb module in metricbeat

**URL:** <https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 21, 2019, 5:05pm UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538 "2019-09-21T17:05:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GRV](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GRV](https://discuss.elastic.co/u/GRV)\
**Post date:** [September 21, 2019, 5:05pm UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538/1 "2019-09-21T17:05:52Z")

</div>

My mongodb server running on local (127.0.0.1:27017). I have 2 user in mongodb database. 1 for application and 2nd user with read only permission. (Eg. user/password). I configure the 2nd user in mondodb.yml module, which present in "module.d" folder . But when i start my metric beat, it throw this error for mongodb.

ERROR -\>  
Errorfetchingdataformetricsetmongodb.metrics: failedtoapplyschema: 6errors: key`metrics.repl.executor.counters`notfound;key`metrics.repl.executor.queues.dbWorkInProgress`notfound;key`metrics.repl.executor.queues.exclusiveInProgress`notfound;key`metrics.repl.executor.queues.ready`notfound;key`metrics.repl.executor.queues.free`notfound;key`metrics.repl.executor.eventWaiters`notfound

XXXXXXXXXXXXXXXXXXXX my Mongodb.yml module configuration XXXXXXXXXXXXXXXXXXXXXX

# Module: mongodb

# Docs: [https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-mongodb.html](https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-mongodb.html)

- module: mongodb  
#metricsets:

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [September 23, 2019, 11:44pm UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538/2 "2019-09-23T23:44:11Z")

</div>

Hello, I see in `mongodb.yml`, you have `metricsets` commented. Please try your config with the second line `#metricsets` uncommented:

```auto
- module: mongodb
  metricsets:
    - dbstats
    - status
    - collstats
    - metrics
    - replstatus
  period: 10s
  hosts: ["localhost:27017"]
  username: securaauser
  password: password

```

---

<div class="post-metadata">

**Author:** ![GRV](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GRV](https://discuss.elastic.co/u/GRV)\
**Post date:** [September 24, 2019, 10:23am UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538/3 "2019-09-24T10:23:32Z")

</div>

Thanks for the reply.

I commented the lines, which you mentioned above.  
but after commenting getting this error

ERROR  
2019-09-24T06:21:28.464-0400 INFO module/wrapper.go:247 Error fetching data for metricset mongodb.metrics: failed to retrieve serverStatus: not authorized on admin to execute command { serverStatus: 1, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }  
2019-09-24T06:21:28.486-0400 INFO module/wrapper.go:247 Error fetching data for metricset mongodb.dbstats: Error retrieving database names from Mongo instance: not authorized on admin to execute command { listDatabases: 1, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }  
2019-09-24T06:21:28.487-0400 INFO module/wrapper.go:247 Error fetching data for metricset mongodb.collstats: Error retrieving collection totals from Mongo instance: not authorized on admin to execute command { top: 1, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [October 20, 2019, 6:41pm UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538/4 "2019-10-20T18:41:34Z")

</div>

Sorry for the late response, I think the new error is caused by some settings in MongoDB for permissions. I have a PR open for fixing the original error message: [https://github.com/elastic/beats/pull/14143](https://github.com/elastic/beats/pull/14143)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 17, 2019, 6:41pm UTC](https://discuss.elastic.co/t/getting-error-for-mongodb-module-in-metricbeat/200538/5 "2019-11-17T18:41:37Z")

</div>

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