Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mongo exporter auth in secondary mongod #29

Merged
merged 1 commit into from
Oct 25, 2021
Merged

fix mongo exporter auth in secondary mongod #29

merged 1 commit into from
Oct 25, 2021

Conversation

hzhao-wish
Copy link

@hzhao-wish hzhao-wish commented Oct 25, 2021

The current mongoexporter cannot log in the secondary mongod as it does not have permission.

The default mode is that reads and writes will always be made to the primary mongod. As we force mongoexporter to directly connect to the local mongod, when the local mongod is secondary, it does not have permission to login.

In order to fix this, we need to set mode before log in. Mgo requries that the consistency requirements set to be Monotonic or Eventual for direct connection. Set session mode to be eventual before login can fix the problem.

Test in a tools secondary mongod (4cfe1d6c.sjc4.w.wish.com):

hzhao@4cfe1d6c:~$ ./mongodb_exporter --mongodb.maxtimems=1000ms --mongodb.collect.database=True --mongodb.collect.collection=True --mongodb.uri=mongodb://localhost:27017 --mongodb.tls-disable-hostname-validation=True --mongodb.mechanism=MONGODB-X509 --mongodb.collect.top=True --mongodb.tls-auth=True --mongodb.collect.oplog_tail=True --mongodb.tls-cert=/etc/mongo_secrets/mongoexporter_cert.conf --mongodb.socket-timeout=1000ms --mongodb.tls-ca=/etc/mongo_secrets/mongoexporter_ca_chain.conf --logtostderr
Listening on :9001 (scheme=HTTP, secured=no, clientValidation=no)
I1022 11:50:57.050271   37161 mongodb_collector.go:104] Collecting CurrentOp Info
I1022 11:50:57.050780   37161 mongodb_collector.go:163] exporting CurrentOp Metrics
I1022 11:50:57.050798   37161 mongodb_collector.go:106] Collecting Server Status
I1022 11:50:57.052066   37161 mongodb_collector.go:172] exporting ServerStatus Metrics
I1022 11:50:57.052273   37161 mongodb_collector.go:109] Collecting ReplSet Status
I1022 11:50:57.052556   37161 mongodb_collector.go:193] exporting ReplSetStatus Metrics
I1022 11:50:57.052859   37161 mongodb_collector.go:204] exporting ReplSetConf Metrics
...

Screen Shot 2021-10-22 at 12 28 03 PM

@hzhao-wish hzhao-wish merged commit 65d9e0b into master Oct 25, 2021
@hzhao-wish hzhao-wish deleted the fix_auth branch October 25, 2021 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants