Getting error for mongodb module in metricbeat

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: keymetrics.repl.executor.countersnotfound;keymetrics.repl.executor.queues.dbWorkInProgressnotfound;keymetrics.repl.executor.queues.exclusiveInProgressnotfound;keymetrics.repl.executor.queues.readynotfound;keymetrics.repl.executor.queues.freenotfound;keymetrics.repl.executor.eventWaitersnotfound

XXXXXXXXXXXXXXXXXXXX my Mongodb.yml module configuration XXXXXXXXXXXXXXXXXXXXXX

Module: mongodb

Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-mongodb.html

  • module: mongodb
    #metricsets:

    - dbstats

    - status

    - collstats

    - metrics

    - replstatus

    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"]

    Optional SSL. By default is off.

    #ssl.enabled: true

    Mode of verification of server certificate ('none' or 'full')

    #ssl.verification_mode: 'full'

    List of root certificates for TLS server verifications

    #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

    Certificate for SSL client authentication

    #ssl.certificate: "/etc/pki/client/cert.pem"

    Client Certificate Key

    #ssl.key: "/etc/pki/client/cert.key"

    Username to use when connecting to MongoDB. Empty by default.

    username: securaauser

    Password to use when connecting to MongoDB. Empty by default.

    password: password

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

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

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" }

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

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