Metricbeat fails to fetch metrics for mongoDB 6.0.4

Metricbeat version: 8.3.1
MongoDB version: 6.0.4

My metricbeat config is as follows:

################### metricbeat Configuration #########################

############################# metricbeat ######################################
setup.ilm.enabled: false
setup.template.enabled: false
tags: ["gateway"]
metricbeat:
  processors:
  - add_fields:
      fields:
        customer_code: test-customer
  - add_host_metadata: null
  - add_cloud_metadata: null
  - add_docker_metadata: null
metricbeat.modules:
- enabled: true
  hosts:
  - localhost:8810
  metricsets:
  - dbstats
  - status
  - collstats
  - metrics
  module: mongodb
  password: JApTdzkN7CXsGKmA
  period: 10s
  username: admin
setup.ilm.check_exists: false

###############################################################################
############################# Libbeat Config ##################################
# Base config file used by all other beats for using libbeat features

############################# Output ##########################################

output:
  elasticsearch:
    enabled: true
    hosts:
    - https://my-url:443
    password: mypass
    protocol: https
    username: myuser


############################# Logging #########################################

logging:
  files:
    rotateeverybytes: 10485760

I am getting following errors in metricbeat logs:

{"log.level":"error","@timestamp":"2023-12-19T14:25:08.456Z","log.origin":{"file.name":"module
/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.metrics: failed to retrieve data from 'serverStatus' command: conn
ection() error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (Aut
henticationFailed) Authentication failed.","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"error","@timestamp":"2023-12-19T14:25:10.444Z","log.origin":{"file.name":"module
/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.status: failed to retrieve 'serverStatus': connection() error occu
red during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (AuthenticationFailed)
Authentication failed.","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"error","@timestamp":"2023-12-19T14:25:11.274Z","log.origin":{"file.name":"module
/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.collstats: 'top' command failed: connection() error occured during
 connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (AuthenticationFailed) Authentica
tion failed.","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"error","@timestamp":"2023-12-19T14:25:16.097Z","log.origin":{"file.name":"module
/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.dbstats: could not retrieve database names from Mongo instance: co
nnection() error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (A
uthenticationFailed) Authentication failed.","service.name":"metricbeat","ecs.version":"1.6.0"}

Can someone please here? TIA.

@Usama_Tariq - Have you tried setting the user privileges mentioned here?

@Muthukumar we are using root/admin user in metricbeat config.

@Usama_Tariq Can you try something like this in the host config

  hosts:
  - localhost:8810/?authSource=admin

Found this from a related thread that addresses the same issue Migrations for mongo db not run. auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed. · Issue #545 · golang-migrate/migrate · GitHub

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