# Metricbeat fails to fetch metrics for mongoDB 6.0.4

**URL:** <https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [December 19, 2023, 2:28pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660 "2023-12-19T14:28:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Usama\_Tariq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/usama_tariq/32/119820_2.png) [@Usama\_Tariq](https://discuss.elastic.co/u/Usama_Tariq)\
**Post date:** [December 19, 2023, 2:28pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660/1 "2023-12-19T14:28:14Z")

</div>

Metricbeat version: 8.3.1  
MongoDB version: 6.0.4

My metricbeat config is as follows:

```auto
################### 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:

```auto
{"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.

---

<div class="post-metadata">

**Author:** ![Muthukumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muthukumar/32/106655_2.png) [@Muthukumar](https://discuss.elastic.co/u/Muthukumar)\
**Post date:** [December 19, 2023, 3:23pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660/2 "2023-12-19T15:23:14Z")

</div>

@Usama_Tariq - Have you tried setting the user privileges mentioned [here](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-mongodb.html#_mongodb_privileges)?

---

<div class="post-metadata">

**Author:** ![Usama\_Tariq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/usama_tariq/32/119820_2.png) [@Usama\_Tariq](https://discuss.elastic.co/u/Usama_Tariq)\
**Post date:** [December 20, 2023, 1:27pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660/3 "2023-12-20T13:27:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aliabbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aliabbas/32/124156_2.png) [@Aliabbas](https://discuss.elastic.co/u/Aliabbas)\
**Post date:** [January 3, 2024, 1:03pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660/4 "2024-01-03T13:03:42Z")

</div>

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

```auto
  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](https://github.com/golang-migrate/migrate/issues/545)

---

<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:** [January 31, 2024, 3:04pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-fetch-metrics-for-mongodb-6-0-4/349660/5 "2024-01-31T15:04:07Z")

</div>

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