percona / mongodb_exporter

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

Username Variable Overwrites part of connection string #826

Closed yoUn3qcdi5dk6QiY6fpoQhttKvcC86jxSgedJek closed 6 months ago

yoUn3qcdi5dk6QiY6fpoQhttKvcC86jxSgedJek commented 6 months ago

Describe the bug When trying to setup MongoDB exporter using variables for username and password as mentioned in the documentation, to not expose the password: https://github.com/percona/mongodb_exporter?tab=readme-ov-file#mongodb-authentication MONGODB_USER overwrites the mongodb:// part of the connection-uri. Using a connection-uri containing the username und password works without any issue.

To Reproduce Steps to reproduce the behavior:

  1. Either export both variables in bash directly and run the exporter in bahs or set them via Environment in systemd-file.
  2. Exporter will not scrape any data, because it cannot access mongoDB because it has an invalid connection-uri.
  3. Changing the variable "MONGODB_USER=username" to "MONGODB_USER=mongodb://username" makes the exporter work as expected with bash directly and Systemd

Expected behavior MONGODB_USER should be able to be defined without "mongodb://"

Environment

BupycHuk commented 6 months ago

seems like this problem already fixed in #800

BupycHuk commented 6 months ago

seems like in your case username had mongodb prefix.

yoUn3qcdi5dk6QiY6fpoQhttKvcC86jxSgedJek commented 6 months ago

You are right, I did not see/associate this report with my problem. In my case the username was "mongodb_exporter" and fits this previous bug report. Close as this problem is already handled in https://github.com/percona/mongodb_exporter/pull/800