mysqld_exporter icon indicating copy to clipboard operation
mysqld_exporter copied to clipboard

Support for scraping multiple mysqld hosts.

Open samitpal opened this issue 5 years ago • 14 comments

Discussion at https://github.com/prometheus/mysqld_exporter/issues/452#issuecomment-701893399

Short summary: This adds a new flag called export-multi-hosts and allows for passing a yaml file which contains the config related to this mode. Note that this change does not make any changes to the way mysqld_exporter works and as a result it would continue to use the ini format config when working in the non export-multi-hosts mode.

samitpal avatar Oct 14 '20 05:10 samitpal

My only question is, because mysql users are used to the INI style of my.cnf, maybe we should stick to INI parsing. I would prefer to implement one kind of config for the exporter. Having multiple ways to configure gets confusing for users.

I also think port should come from the target URL param, not the config.

I'm thinking a config something along the lines of:

clients:
  default:
    user: foo
    password: foo123
  other_server:
    user: bar
    password: bar123

Or in INI style

[client]
user = foo
password = foo123
[client.other_server]
user = bar
password = bar123

SuperQ avatar Oct 16 '20 11:10 SuperQ

Makes sense. Given that the currently supported format is INI, I will try to modify my change to use INI instead of yaml.

samitpal avatar Oct 17 '20 05:10 samitpal

It looks like some of the commits are missing DCO.

SuperQ avatar Oct 20 '20 18:10 SuperQ

YAML would have the advantage of being well-established in Prometheus-land; the question is if users are more likely to be DBAs exposing data or Prometheus people grabbing data from a lot of different places. I would suspect the latter, but don't have data, of course.

RichiH avatar Oct 21 '20 14:10 RichiH

@RichiH Supporting the MySQL-style INI file was an often, and now implemented, requested feature. I think we want to stick with it.

SuperQ avatar Oct 21 '20 14:10 SuperQ

Here's a proposal on how the final config (one config to rule them all) would look like.

[client]
user = foo
password = foo123
target = hostname:3306
[client.module1]
user = bar
password = bar123

The target key is only allowed in the default case and is ignored/rejected by additional modules.

  • /metrics URL would be a backwards equivalent of /mysql?module=default.
  • /mysql?module=default&target=some-remote:3306 would use the default user/password but override the target.
  • /mysql?module=module1 is invalid, as it doesn't contain a target.
  • /mysql?module=module1&target=some-remote:3306 is a typical scrape of a remote.

I'm also thinking about an option to make /metrics not return mysql data, just exporter data. This would make it easier to separate exporter data from target data. Easier to monitor the health of just the exporter.

SuperQ avatar Oct 22 '20 15:10 SuperQ

Any progress on this? Would be very nice to have this.

piotr1212 avatar Dec 03 '20 09:12 piotr1212

When is this being merged? We are waiting for this too.

yum-dev avatar Dec 17 '20 12:12 yum-dev

Hi, When this will get merge, we are also waiting for this.

rpsadarangani avatar Dec 19 '20 10:12 rpsadarangani

For our internal use case my implementation is sufficient. I won't be able to work on the proposal as outlined at #504 (comment). If any one else wants to take this forward, please feel free to go ahead.

samitpal avatar Dec 19 '20 12:12 samitpal

Alright, if I can find some help to work on this, we could merge it and build on it. But as-is, this needs work before it could be released.

SuperQ avatar Dec 20 '20 11:12 SuperQ

Is it possible to use prometheus exporter when mysql is running on a different port then 3306? When i change the /etc/.mysqld_exporter.cnf file for looking at another port. it still tries to connect with port 3306. changes i have made are.

[client] user=mysqld_exporter password=apassword host=localhost:portnumber

exporter service is running with error level=error msg="Error pinging mysqld: dial tcp: lookup localhost:45654:3306:

Dims-lab avatar May 28 '21 16:05 Dims-lab

I have an improved version here, transformed into a probe, which supports http incoming parameters like blackbox_exporter . https://github.com/ning1875/mysqld_exporter/releases/tag/v0.12.1

ning1875 avatar Aug 06 '21 07:08 ning1875

Is there a plan to finalize this PR?

HerrTamm avatar Apr 29 '22 09:04 HerrTamm

This was completed in #651

SuperQ avatar Mar 05 '23 10:03 SuperQ