dcu / mongodb_exporter

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

server returned error on SASL authentication step: Authentication failed. #112

Open LzxUser opened 5 years ago

LzxUser commented 5 years ago

I tried to use mongo to connect, it is correct, I do not know what happened

Willsms commented 5 years ago

User rights are not enough,create a dbOwner in mongo. db.createUser({user: "exporterdb", pwd: "*********", roles: [{role: "dbOwner", db: "user_data"}]})

jsedy7 commented 5 years ago

I have the same problem 🤔

User in mongo:

Successfully added user: {
    "user" : "exporterdb",
    "roles" : [
        {
            "role" : "dbOwner",
            "db" : "proxy"
        }
    ]
}

Logs from exporter:

{"level":"error","msg":"Could not get MongoDB BuildInfo: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": Authentication failed.!","source":"connection.go:192","time":"2019-09-16T17:48:11+02:00"}
{"level":"error","msg":"Problem gathering the mongo server version: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": Authentication failed.","source":"mongodb_collector.go:213","time":"2019-09-16T17:48:11+02:00"}

What's wrong?

st-h commented 4 years ago

I would advice to use the role clusterMonitor instead the much more permission dbOwner. In case you are still having trouble after creating a user with appropriate permissions, the issue often seems that the @ character in the connection stream causes issues in cause no escaping is used. Easiest fix seems to be to just quote the whole connection string with single quotes.

Ah, sorry. The exporter was returning some metrics, but I noticed later that it is still printing the error message on each request it serves. I was about to check if the percona fork would fix this issue, however it looks like they do not provide any binaries, and I have no experience with go. So, no good idea how to quickly fix this right now :/