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 ?