prometheus / mysqld_exporter

Exporter for MySQL server metrics
http://prometheus.io/
Apache License 2.0
2.11k stars 745 forks source link

Exporter not picking up SSL config #455

Open Lucas-H-NE opened 4 years ago

Lucas-H-NE commented 4 years ago

Host operating system: output of uname -a

Linux ip-xxx-xx-xxx-xx.eu-west-2.compute.internal 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

mysqld_exporter version: output of mysqld_exporter --version

mysqld_exporter, version 0.12.1 (branch: HEAD, revision: 48667bf7c3b438b5e93b259f3d17b70a7c9aff96) build user: root@0b3e56a7bc0a build date: 20190729-12:35:58 go version: go1.12.7

MySQL server version

Server version: 5.7.25-google (Google)

mysqld_exporter command line flags

/usr/local/bin/mysqld_exporter --config.my-cnf /etc/.mysqld_exporter3.cnf --collect.global_status --collect.info_schema.innodb_metrics --collect.auto_increment.columns --collect.info_schema.processlist --collect.binlog_size --collect.info_schema.tablestats --collect.global_variables --collect.info_schema.query_response_time --collect.info_schema.userstats --collect.info_schema.tables --collect.perf_schema.tablelocks --collect.perf_schema.file_events --collect.perf_schema.eventswaits --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.slave_status --log.level=debug --web.listen-address=0.0.0.0:9106

What did you do that produced an error?

No mysqld_exporter error produced, error received is from DB.

my.cnf file:

[client] user = mysqld_exporter password = "xxxxxxxx" host=xx.xxx.xxx.xx

[mysqld] ssl-ca=/dir/client-ssl/server-ca.pem ssl-key=/dir/client-ssl/client-key.pem ssl-cert=/dir/client-ssl/client-cert.pem

What did you expect to see?

A successful connection to the DB / Metrics collected

What did you see instead?

mysqld_exporter[13941]: time="2020-03-12T10:24:31Z" level=error msg="Error pinging mysqld: Error 1045: Access denied for user 'mysqld_exporter'@'xx.xx.xx.xx' (using password: YES)" source="exporter.go:146"

Lucas-H-NE commented 4 years ago

I believe its worth mentioning that when I use the command line to connect, it is successful:

mysql -u mysqld_exporter -p -h xx.xxx.xx.xxx --ssl-ca=/dir/client-ssl/server-ca.pem --ssl-cert=/dir/client-ssl/client-cert.pem --ssl-key=/dir/client-ssl/client-key.pem

MySQL [(none)]>

yuecong commented 4 years ago

I believe your setting should be

[client]
user = mysqld_exporter
password = "xxxxxxxx"
host=xx.xxx.xxx.xx
ssl-ca=/dir/client-ssl/server-ca.pem
ssl-key=/dir/client-ssl/client-key.pem
ssl-cert=/dir/client-ssl/client-cert.pem

it is parsing the ini file as https://github.com/prometheus/mysqld_exporter/blob/5667073df941d157758479df44cbaafddf76fef1/mysqld_exporter.go#L126. so it needs to be in [client] session.