prometheus / mysqld_exporter

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

cannot use `config.my-cnf` flag with alternative login path for mysqld_exporter user #451

Open tsembhi opened 4 years ago

tsembhi commented 4 years ago

We cannot use config.my-cnf flag with alternative login path for mysqld_exporter user. The default is client (and seems to be hard-coded) However when using client, this causes issues when logging as other users using the credentials file:

$ mysql --login-path=sqladmin
...
...
mysql> select current_user();
+---------------------------+
| current_user()            |
+---------------------------+
| mysqld_exporter@localhost |
+---------------------------+
1 row in set (0.00 sec)
mysql> exit

Although the login-path has been specified as sqladmin, it has logged in using the client login-path. Now this maybe a bug in mysql, however I would expect there to be way to set the login-path for the mysqld_exporter.

Host operating system: output of uname -a

Linux test5.sys.awsiesb1.linsys.tmcs 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019 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.6.37-log MySQL Community Server (GPL)
CharlesJUDITH commented 4 years ago

I'm using this config: mysql Ver 15.1 Distrib 10.4.11-MariaDB, for osx10.14 (x86_64) using readline 5.1 mysql Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1

Sorry, I don't have a MySQL setup to test right now. Tested on OSX and Linux (CentOS 7).

My client config looks like this:

[client]
user=user-monitor-ro
passord=MymagIcpasswOrd

I can run the exporter with these commands: ./mysqld_exporter --config.my-cnf /tmp/my.cnf ./mysqld_exporter --config.my-cnf ~/my.cnf ./mysqld_exporter

Note: I moved the client config to test multiple solutions. By default, MySQL client is looking for ~/.my.cnf, so you can move your client config somewhere else if that is bothering you.

Even with my client config ~/.my.cnf I'm able to login with another user with the following command: mysql -u myotheruser -h mysupermysqlserver -p

Did you try those solutions:

gnufree commented 4 years ago

My configuration is OK. My configuration is as follows: /usr/local/mysqld_exporter mysqld_exporter --config.my-cnf =/usr/local/mysqld_exporter/. my.cnf

In addition, the password in.my.cnf can be set as a simple point, or avoid the use of.