Metricbeat 8.3.2 and mongo V5

FYI Metricbeat 8.3.1+ now supports mongo V5. So i downloaded 8.3.2 and configured against my 3 server cluster with replica set.

So if i add single server ( i have 3 server cluster with replica set in following template it works.

hosts: ["mymongoserver1:27017"]
username: myuser
password: mypassword

but if add multiple hosts

hosts: ["mymongoserver1:27017",” mymongoserver2:27017”,” mymongoserver3:27017”]
username: myuser
password: mypassword

I get following error.


{"log.level":"error","[@timestamp]:"2022-07-18T08:21:47.507-0500","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.status: could not create mongodb client: could not create mongodb client: a direct connection cannot be made if multiple hosts are specified","service.name":"metricbeat","ecs.version":"1.6.0"}

So then i tried following template

hosts: ["mongodb://myuser:mypass@mymongoserver1:27017", " mongodb://myuser:mypass@mymongoserver2:27017", mongodb://myuser:mypass@mymongoserver3:27017"]

{"log.level":"error","[@timestamp]":"2022-07-18T08:33:34.818-0500","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset mongodb.status: failed to retrieve 'serverStatus': server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: myuser:mypass@mymongoserver1:27017, Type: Unknown, Average RTT: 0, Last error: connection() error occured during connection handshake: dial tcp: address mongodb:// myuser:mypass@mymongoserver1:27017: too many colons in address }, ] }","service.name":"metricbeat","ecs.version":"1.6.0"}

Any one know what am i missing ?

Interesting, could you please share formatted configuration you're using?

Here is my config.

# Module: mongodb
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/8.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: ["mymongoserver1:27017"]
  #hosts: ["mongodb://myuser:mypassword@mymongoserver1:27017"]
  #hosts: ["mongodb://myuser:mypassword@mymongoserver1:27017" ,"mymongoserver2:27017" , "mymongoserver3:27017"]
  #hosts: ["mymongoserver1:27017",”mymongoserver2:27017”,” mymongoserver3:27017”]
  #hosts: ["mongodb://mymongoserver1:27017?authMechanism=SCRAM-SHA-256&authSource=admin"]

  # 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: myuser

  # Password to use when connecting to MongoDB. Empty by default.
  password: mypassword
~

As you can see i have tried quiet a few option but only first one works. Also i found this MongoDB metricsets incorrectly handling multiple hosts · Issue #32188 · elastic/beats · GitHub

I have also opened a case with elastic support for 10 days and no movement on it :frowning:

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