Cannot connect to MongoDB with password with special characters

Description

  1. Create MongoDb user with password, for example 123$

  2. Add mongodb to monitoring with this user:

    [nailya.kutlubaeva@bm-qanqa05 ~]$ sudo pmm-admin add mongodb --uri 'mongodb://tester:123$@localhost:27017/test' [linux:metrics] OK, already monitoring this system. [mongodb:metrics] OK, now monitoring MongoDB metrics using URI tester:***@localhost:27017/test [mongodb:queries] OK, now monitoring MongoDB queries using URI tester:***@localhost:27017/test

Result: errors in pmm-mongodb-metrics logs:

[nailya.kutlubaeva@bm-qanqa05 ~]$ sudo tail -50 /var/log/pmm-mongodb-metrics-42003.log time="2017-09-14T08:52:02Z" level=info msg="### Warning: the exporter is in beta/experimental state and field names are very" source="mongodb_exporter.go:239" time="2017-09-14T08:52:02Z" level=info msg="### likely to change in the future and features may change or get removed!" source="mongodb_exporter.go:240" time="2017-09-14T08:52:02Z" level=info msg="### See: https://github.com/percona/mongodb_exporter for updates" source="mongodb_exporter.go:241" time="2017-09-14T08:52:05Z" level=error msg="Cannot connect to server using url mongodb://tester:123startlocalhost:27017/test: no reachable servers" source="connection.go:75" time="2017-09-14T08:52:05Z" level=info msg="HTTPS/TLS is enabled" source="mongodb_exporter.go:172" time="2017-09-14T08:52:05Z" level=info msg="Starting HTTPS server on https://10.10.11.54:42003/metrics ..." source="mongodb_exporter.go:200" time="2017-09-14T08:52:09Z" level=error msg="Cannot connect to server using url mongodb://tester:123startlocalhost:27017/test: no reachable servers" source="connection.go:75"
[nailya.kutlubaeva@bm-qanqa05 ~]$ mongo -u admin -p pass123$%.10 --authenticationDatabase admin MongoDB shell version v3.4.7 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.7

How to test

None

How to document

None

Smart Checklist

Activity

Lalit Choudhary April 11, 2019 at 12:25 PM
Edited

Adding single quotes around the password will solve the problem.

 

root@lalit-ThinkPad-T480:~# pmm-admin add mongodb --uri mongodb://mongodb_exporter:s3cR#tpa$$worD@127.0.0.1:27017 [linux:metrics] OK, already monitoring this system. [mongodb:metrics] Error adding MongoDB metrics: cannot verify MongoDB connection with `/usr/local/percona/pmm-client/mongodb_exporter --test`: exit status 1: time="2019-04-11T17:43:50+05:30" level=error msg="Cannot connect to server using url mongodb://****:****@127.0.0.1:27017: server returned error on SASL authentication step: Authentication failed." source="connection.go:84" time="2019-04-11T17:43:50+05:30" level=error msg="Can't connect to MongoDB: Cannot connect using uri: mongodb://mongodb_exporter:s3cR#tpa28309worD@127.0.0.1:27017" source="mongodb_exporter.go:104"

 

  1.  

    1. pmm-admin add mongodb --uri mongodb://mongodb_exporter:'s3cR#tpa$$worD'@127.0.0.1:27017*

      [linux:metrics] OK, already monitoring this system. [mongodb:metrics] OK, now monitoring MongoDB metrics using URI mongodb_exporter:***@127.0.0.1:27017 [mongodb:queries] OK, now monitoring MongoDB queries using URI mongodb_exporter:***@127.0.0.1:27017 [mongodb:queries] It is required for correct operation that profiling of monitored MongoDB databases be enabled. [mongodb:queries] Note that profiling is not enabled by default because it may reduce the performance of your MongoDB server. [mongodb:queries] For more information read PMM documentation (https://www.percona.com/doc/percona-monitoring-and-management/conf-mongodb.html).
  1. cat /var/log/pmm-mongodb-metrics-42010.log time="2019-04-11T17:44:06+05:30" level=info msg="Starting HTTPS server for https://172.17.0.1:42010/metrics ..." source="server.go:106" 2019/04/11 17:44:47 http: TLS handshake error from 172.17.0.1:33272: tls: first record does not look like a TLS handshake 

 

 

Cannot Reproduce

Details

Assignee

Reporter

Priority

Story Points

Affects versions

Smart Checklist

Created September 14, 2017 at 9:30 AM
Updated March 6, 2024 at 8:17 AM
Resolved April 11, 2019 at 12:28 PM

Flag notifications