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

Include metrics from SHOW SLAVE HOSTS #267

Closed
zoonage opened this issue Feb 13, 2018 · 2 comments
Closed

Include metrics from SHOW SLAVE HOSTS #267

zoonage opened this issue Feb 13, 2018 · 2 comments

Comments

@zoonage
Copy link
Contributor

zoonage commented Feb 13, 2018

Description

Create some metrics based off of the output of SHOW SLAVE HOSTS.

Example output (very old mysql):

mysql> SHOW SLAVE HOSTS;
+-----------+----------------------------+------+-------------------+-----------+
| Server_id | Host                       | Port | Rpl_recovery_rank | Master_id |
+-----------+----------------------------+------+-------------------+-----------+
| 380239978 | backup_server_1 |    0 |                 0 |         1 | 
|  11882498 | backup_server_2 |    0 |                 0 |         1 | 
+-----------+----------------------------+------+-------------------+-----------+
3 rows in set (0.00 sec)

Example output (new mysql):

mysql> SHOW SLAVE HOSTS;
+------------+-----------+------+-----------+--------------------------------------+
| Server_id  | Host      | Port | Master_id | Slave_UUID                           |
+------------+-----------+------+-----------+--------------------------------------+
|  192168010 | iconnect2 | 3306 | 192168011 | 14cb6624-7f93-11e0-b2c0-c80aa9429562 |
| 1921680101 | athena    | 3306 | 192168011 | 07af4990-f41f-11df-a566-7ac56fdaf645 |
+------------+-----------+------+-----------+--------------------------------------+

Motivation

In our use case we have a requirement to know the number of slaves that a master is currently replication to. We have a workaround assuming that the master was previously replication by using the mysql_slave_* metrics, however it would be more reliable to check the output of SHOW SLAVE HOSTS from the master.

Proposed metrics

I've left out server_uuid to keep compatability between old MySQL and new MySQL as I don't know how much more it adds compared to the server_id.

# HELP The master ID that the slave uses to identify the master
# TYPE mysql_slave_hosts_master_id gauge
mysql_slave_hosts_master_id{host="backup_server_1", server_id="380239978"} 1

# HELP The port that the slave is connected to the master on (0 means --report-port is not set)
# TYPE mysql_slave_hosts_master_id gauge
mysql_slave_hosts_port{host="backup_server_1", server_id="380239978"} 0
@SuperQ
Copy link
Member

SuperQ commented Feb 15, 2018

Seems like a good idea to me.

I might suggest a simpler metric:

# HELP mysql_slave_hosts_info Information from SHOW SLAVE HOSTS
# TYPE mysql_slave_hosts_info gauge
mysql_slave_hosts_info{server_id="380239978",host="backup_server_1",port="0",master_id="",slave_uuid=""} 1
mysql_slave_hosts_info{server_id="192168010",host="iconnect2",port="3306",master_id="192168011",slave_uuid="14cb6624-7f93-11e0-b2c0-c80aa9429562"} 1

Of course, you wouldn't get metrics exactly like above, as you would only get one style from a server. But keeping consistent labels between the two variations of SHOW SLAVE HOSTS would allow for easier comparisons.

I don't see a large value in having the port as an actual metric.

@zoonage
Copy link
Contributor Author

zoonage commented Feb 19, 2018

That method is much nicer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants