Open
Description
Describe the bug
Usually when using the parameter --mongodb.global-conn-pool
the exporter establishes some permanent connections with appname=mongodb_exporter
, except for the pbm collector, this one is using appname=sdk
and open/close connection are made each time the exporter is scraped.
To Reproduce
Steps to reproduce the behavior:
- what parameters are being passed to
mongodb_exporter
:
mongodb_exporter --compatible-mode --discovering-mode --mongodb.global-conn-pool --log.level=info --collect-all
MONGODB_URI=mongodb://monitor:[email protected]:27017/admin?serverSelectionTimeoutMS=5000 - describe steps to reproduce the issue:
start the exporter and scrap the metrics, you should see in the mongodb logs somesdk
connections ^^ that's all
Expected behavior
We should only have connections with the same appname: mongo_exporter
We should also have only one connection during the startup of the exporter... we should not have some connection/disconnection while scraping metrics with --mongodb.global-conn-pool
.
Logs
good mongodb_exporter logs:
{"t":{"$date":"2025-05-15T09:12:00.122+02:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn152","msg":"client metadata","attr":{"remote":"127.0.0.1:64484","client":"conn152","doc":{"application":{"name":"mongodb_exporter"},"driver":{"name":"mongo-go-driver","version":"1.17.3"},"os":{"type":"linux","architecture":"amd64"},"platform":"go1.23.7"}}}
bad mongodb_exporter logs:
{"t":{"$date":"2025-05-15T09:13:56.571+02:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn155","msg":"client metadata","attr":{"remote":"10.192.132.46:57340","client":"conn155","doc":{"application":{"name":"sdk"},"driver":{"name":"mongo-go-driver","version":"1.17
.3"},"os":{"type":"linux","architecture":"amd64"},"platform":"go1.23.7"}}}
Environment
- MongoDB exporter 0.44.0