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

No mongodb_ metrics exported with local instance (no auth required) #877

Closed ivan-zinchenko closed 1 week ago

ivan-zinchenko commented 1 month ago

Describe the bug

Having local (compose stack) mongodb instance and exporter configured with no auth, db is accessible without credentials and diagnostic commands can be executed via mongo console. However no mongodb specific metrics are collected/exposed on /metrics endpoint.

To Reproduce compose yaml:

services:
  mongodb:
    image: mongo:4.4.9
    ports:
      - "27017:27017"

  mongodb-exporter:
    image: percona/mongodb_exporter:0.40.0
    depends_on:
        - mongodb
    ports:
      - "9216:9216"
    command: --mongodb.uri=mongodb://mongodb:27017 --log.level=debug  

Expected behavior :9216/metrics should expose all collected "mongodb*" metrics but only "go*" metrics and "mongodb_up" are shown

Logs

time="2024-07-18T14:18:22Z" level=debug msg="Compatible mode: false"
2024-07-18T14:18:22.424162382Z time="2024-07-18T14:18:22Z" level=debug msg="Connection URI: mongodb://mongodb:27017"
2024-07-18T14:18:22.425686423Z level=info ts=2024-07-18T14:18:22.424Z caller=tls_config.go:274 msg="Listening on" address=[::]:9216
2024-07-18T14:18:22.425694173Z level=info ts=2024-07-18T14:18:22.424Z caller=tls_config.go:277 msg="TLS is disabled." http2=false address=[::]:9216

Environment

Additional context Test with auth enabled (admin root user) with the same result - no mongodb metrics even though user has superuser permissions on the db.

giovanni-orciuolo commented 1 month ago

+1 I'm having the same issue here. Maybe it's dependant on MongoDB version? I'm using 5.0

zaziki23 commented 1 month ago

same issue for me with MongoDB 6.0.7

BupycHuk commented 3 weeks ago

Hi, all collectors are disabled by default, you need to enable them using --collector.* flags or enable all of them using --collect-all flag. list of flags can be found https://github.com/percona/mongodb_exporter/blob/main/main.go#L52-L62. Meanwhile we will work on improving documentation and default behavior in https://perconadev.atlassian.net/browse/PMM-13318.

ivan-zinchenko commented 1 week ago

thx @BupycHuk, --collect-all flag solved the issue for me