percona / mongodb_exporter

A Prometheus exporter for MongoDB including sharding, replication and storage engines
Apache License 2.0
1.16k stars 425 forks source link

cluster uri configuration #876

Closed Deshke closed 1 month ago

Deshke commented 1 month ago

Describe the bug https://github.com/percona/mongodb_exporter?tab=readme-ov-file#multi-target-support

#### Multi-target support
...

If your URI is prefixed by mongodb:// or mongodb+srv:// schema, any host not prefixed by it after comma is being treated as part of a cluster rather then as a standalone host. Thus clusters and standalone hosts can be combined like this:
--mongodb.uri=mongodb+srv://user:pass@host1:27017,host2:27017,host3:27017/admin,mongodb://user2:pass2@host4:27018/admin

but

  exporter:
    image: percona/mongodb_exporter:0.40.0
    restart: always
    network_mode: "host"
    volumes:
      - /storage/mongodb/secrets:/secrets
    command: "--discovering-mode --log.level=debug"
    environment:
      - MONGODB_URI=mongodb://user:pass@node1:27017,node2:27017,node3:27017/admin?ssl=true&tlsCertificateKeyFile=secrets/node.pem&tlsCAFile=secrets/ca.crt

results in

mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Compatible mode: false"
mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Connection URI: mongodb://user:pass@node1:27017"
mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Prepending mongodb:// to the URI node2:27017"
mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Connection URI: mongodb://node2:27017"
mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Prepending mongodb:// to the URI node3:27017/admin?ssl=true&tlsCertificateKeyFile=secrets/node.pem&tlsCAFile=secrets/ca.crt"
mongodb-exporter-1  | time="2024-07-16T08:41:59Z" level=debug msg="Connection URI: mongodb://node3:27017/admin?ssl=true&tlsCertificateKeyFile=secrets/node.pem&tlsCAFile=secrets/ca.crt"
mongodb-exporter-1  | level=info ts=2024-07-16T08:41:59.736Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216
mongodb-exporter-1  | level=info ts=2024-07-16T08:41:59.736Z caller=tls_config.go:277 msg="TLS is disabled." http2=false address=[::]:9216
mongodb-exporter-1  | time="2024-07-16T08:42:04Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: node1:27017, Type: Unknown, Last error: connection(node1:27017[-29]) socket was unexpectedly closed: EOF }, ] }"
mongodb-exporter-1  | time="2024-07-16T08:42:04Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: node2:27017, Type: Unknown, Last error: connection(node2:27017[-30]) socket was unexpectedly closed: EOF }, ] }"
mongodb-exporter-1  | time="2024-07-16T08:43:18Z" level=error msg="Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: node1:27017, Type: Unknown, Last error: connection(node1:27017[-43]) socket was unexpectedly closed: EOF }, ] }"

Expected behavior cluster connections work

running in single node configuration works just fine

mongodb-exporter-1  | time="2024-07-16T08:48:50Z" level=debug msg="Compatible mode: false"
mongodb-exporter-1  | time="2024-07-16T08:48:50Z" level=debug msg="Connection URI: mongodb://user:pass@node1:27017/admin?ssl=true&tlsCertificateKeyFile=secrets/node.pem&tlsCAFile=secrets/ca.crt"
mongodb-exporter-1  | level=info ts=2024-07-16T08:48:50.302Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216
mongodb-exporter-1  | level=info ts=2024-07-16T08:48:50.302Z caller=tls_config.go:277 msg="TLS is disabled." http2=false address=[::]:9216

Environment

BupycHuk commented 1 month ago

Hi @adnull, could you help here, please?

adnull commented 1 month ago

Hi @adnull, could you help here, please?

Hi! Sure, I'll check it shortly

adnull commented 1 month ago

@Deshke Hi! I've checked and found that the latest release (0.40) doesn't contain mentioned behavior as this bug was fixed after the release. @BupycHuk fyi

Deshke commented 1 month ago

@adnull cool, is there a timetable for a new release?

BupycHuk commented 1 month ago

@adnull thank you, @Deshke, We are going to release 0.41.0 in the second half of August