dcu / mongodb_exporter

MongoDB exporter for prometheus.io
MIT License
356 stars 216 forks source link

Unauthorized error of disconnected MongoDB replica set #125

Open itsx opened 4 years ago

itsx commented 4 years ago

We have MongoDB replica set with 3 nodes. When are MongoDB nodes disconnected, because of the network failure, mongodb exporter logs errors and doesn't collect the majority of metrics:

mongodb exporter log output:

time="2020-04-03T06:16:22Z" level=error msg="Failed to get database names, (Unauthorized) command listDatabases requires authentication" source="database_status.go:92"
time="2020-04-03T06:16:22Z" level=error msg="Failed to get replSetGetConfig: (Unauthorized) command replSetGetConfig requires authentication." source="replset_conf.go:115"
time="2020-04-03T06:16:22Z" level=error msg="Failed to get replSet status: (Unauthorized) command replSetGetStatus requires authentication" source="replset_status.go:307"
time="2020-04-03T06:16:22Z" level=error msg="Failed to get oplog collection status: (Unauthorized) command collStats requires authentication" source="oplog_status.go:144"
time="2020-04-03T06:16:22Z" level=error msg="Failed to get oplog timestamps status: (Unauthorized) command find requires authentication" source="oplog_status.go:149"

When the connection between nodes is established again and replica set is recovered, errors disappear and metrics are being collected again without problems.

I found out, there is a similar issue, with same mogndodb exporter errors, although there is a difference, that we haven't got any hidden nodes in our replica set.