Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document socket-based access #657

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 24,15 @@ GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

NOTE: It is recommended to set a max connection limit for the user to avoid overloading the server with monitoring scrapes under heavy load. This is not supported on all MySQL/MariaDB versions; for example, MariaDB 10.1 (provided with Ubuntu 18.04) [does _not_ support this feature](https://mariadb.com/kb/en/library/create-user/#resource-limit-options).

If mysqld_exporter runs on the same system as mysql, you can use passwordless socket access instead:


```sql
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO `mysqld_exporter`@`localhost` IDENTIFIED VIA unix_socket WITH MAX_USER_CONNECTIONS 3;
```

The username must then match the system user `mysqld_exporter` is running at.

### Build

make
Expand Down Expand Up @@ -72,6 81,18 @@ On the prometheus side you can set a scrape config as follows
- target_label: __address__
# The mysqld_exporter host:port
replacement: localhost:9104

##### Socket authentication

To use passwordless socket authentication, give socket based grants as documented above, then use:

```shell
## run as user mysqld_exporter:
export DATA_SOURCE_NAME="mysqld_exporter:@unix(/var/run/mysqld/mysqld.sock)/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but we need to update this to use the new config file format or command line flag (--mysqld.address=).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would the new format look like?

i tried both, but it doesn't seem to work:

--mysqld.address="unix(/var/run/mariadb/mysql.sock)"

2023-07-05T16:16:30.833935 02:00 db mariadb_exporter[3181430]: ts=2023-07-05T14:16:30.832Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="failed to parse address: address unix(/var/run/mariadb/mysql.sock): missing port in address"
--mysqld.address="unix:///var/run/mariadb/mysql.sock"

2023-07-05T16:17:31.077223 02:00 db mariadb_exporter[3181808]: ts=2023-07-05T14:17:31.075Z caller=config.go:146 level=error msg="failed to parse config" section=client err="set field \"port\": strconv.ParseInt: parsing \"///var/run/mariadb/mysql.sock\": invalid syntax"

./mysqld_exporter <flags>
```

The username must match the user ```mysqld_exporter``` is running at. The socket path depends on the mysql/mariadb package used.

##### Flag format
Example format for flags for version > 0.10.0:
Expand Down