mongodb_exporter
mongodb_exporter copied to clipboard
MongoDB: cannot connect to MongoDB: server selection error: server selection timeout
I am getting socket issue in the new version 0.40.0, I was able to resolve the TLS issue by configuring the --web.config file, but the connection to the MongoDB deployment is showing error in Prometheus logs attached below. However, I can perform the connectivity through the same certificates without any issues locally. Any help would be appreciated. Thanks.
Percona prometheus version used: 0.40.0 MongoDB version: 6.0.6 Community Edition
LOG: ######################### level=info ts=2024-01-22T12:14:54.307Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216 level=info ts=2024-01-22T12:14:54.308Z caller=tls_config.go:310 msg="TLS is enabled." http2=false address=[::]:9216
time="2024-01-22T12:14:59Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: xxx.svc.cluster.local:27017, Type: Unknown, Last error: connection(xxxx..svc.cluster.local:27017[-30]) socket was unexpectedly closed: EOF }, ] }" ##############################
Configurations:
extraArgs:
- --compatible-mode
- --collector.dbstats
- --collector.collstats-limit=0
- --collector.topmetrics
- --web.config=/tmp/webconfig.yaml
- --mongodb.uri=mongodb://user:pass@
/admin?tls=true&tlsCertificateKeyFile=/tmp/tls-combined.pem&tlsCAFile=/tmp/ca.crt - --log.level=debug
- --mongodb.direct-connect=false
web-config:
tls_server_config: cert_file: "/tmp/tls-combined.pem" key_file: "/tmp/tls.key" client_auth_type: "RequireAndVerifyClientCert" client_ca_file: "/tmp/ca.crt" http_server_config: http2: false
Originally posted by @harishkumarrajasekaran in https://github.com/percona/mongodb_exporter/issues/685#issuecomment-1903906999
I have a similar error, could you show me how you configured your mongodb_exporter.service? I am unable to activate TLS.
Thanks!
We ran into the same error with the exporter in version 0.40. Can you please try to run the exporter in version 0.39.0 and see if that works? There is already a PR that addresses the issue with 0.40.0 but unfortunately it's not yet been released. Please see: https://github.com/percona/mongodb_exporter/pull/780
@adnull also provides a container that has the fix already implemented. I'd love to see a new release of this exporter to prevent others from running into this issue, too.
Is there anything that can be done to get a new release? I could not find any timeline or roadmap.
Hi. My docker version contains changes in multiple hosts resolving, i don't think it fixes TLS connection problem, but if it works we can compare what was changed.
Hello @winem, we are going to release 0.41.0 in the middle of june.