prometheus-community / json_exporter

A prometheus exporter which scrapes remote JSON by JSONPath
Apache License 2.0
615 stars 187 forks source link

mongodb_exporter.service TLS is disabled #291

Open l0rdaxel opened 5 months ago

l0rdaxel commented 5 months ago

Hello everyone, I have a problem with the mongodb_exporter.service to export metrics to Grafana.

It is configured as follows:

###############################à [Unit] Description=MongoDB Exporter User=prometheus

[Service] Type=simple Restart=always ExecStart=/usr/local/bin/mongodb_exporter --mongodb.uri=mongodb://mongodb_exporter:collaudo@xxx:27017/admin?ssl=true

[Install] WantedBy=multi-user.target ###############################

But when I start mongodb_exporter.service, I get this output:

############################### ● mongodb_exporter.service - MongoDB Exporter Loaded: loaded (/usr/lib/systemd/system/mongodb_exporter.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2024-02-13 11:46:08 CET; 4s ago Main PID: 17623 (mongodb_exporte) Tasks: 6 (limit: 52426) Memory: 7.0M CGroup: /system.slice/mongodb_exporter.service └─17623 /usr/local/bin/mongodb_exporter --mongodb.uri=mongodb://mongodb_exporter:collaudo@xxx:27017/admin?ssl=true

Feb 13 11:46:08 xxx systemd[1]: Started MongoDB Exporter. Feb 13 11:46:08 xxx mongodb_exporter[17623]: level=info ts=2024-02-13T10:46:08.912Z caller=tls_config.go:274 msg="Listening on" address=0.0.0.0:92> Feb 13 11:46:08 xxx mongodb_exporter[17623]: level=info mongodb://mongodb_exporter:collaudo@xxx:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=truets=2024-02-13T10:46:08.912Z caller=tls_config.go:277 msg="TLS is disabled." http2=false ad ###############################

My MongoDB cluster is configured on 3 nodes (one primary and two secondary) and SSL connection is enabled.

In fact, if I try to connect with a client with the following string, I can connect without problems mongodb://mongodb_exporter:collaudo@xxx:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=true

My prometeus.yml is:

###############################

global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

alerting: alertmanagers:

Could you please help me solve this issue? Thanks!

fsimonjetz commented 1 month ago

Hi there, did you ever figure this out? We seem to have exactly the same problem with a very similar setup. I can connect to the db manually with mongosh, but mongodb exporter fails to do so (socket was unexpectedly closed: EOF), and in the mongodb logs it shows SSLHandshakeFailed and The server is configured to only allow SSL connections. It almost looks like SSL gets disabled somehow even though it's explicitly set to true in the uri? Any hints would be greatly appreciated.

Cheers