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

Add metrics for the output of "SHOW SLAVE HOSTS" #279

Merged
merged 4 commits into from
Jun 1, 2018
Merged

Add metrics for the output of "SHOW SLAVE HOSTS" #279

merged 4 commits into from
Jun 1, 2018

Conversation

zoonage
Copy link
Contributor

@zoonage zoonage commented Apr 30, 2018

Closes: #267

Adds a new sub system to show data about the output of SHOW SLAVE HOSTS. This command shows currently running slaves from the master, however it can be presented in two seperate formats;

This is from an old version of 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)

This is from a new version of 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 |
+------------+-----------+------+-----------+--------------------------------------+

This PR is designed to work with both. However the old version does not contain a slave UUID field, so it is left as an empty string.

This exposes one new metric called mysql_slave_hosts_info. As described in #267 the output is like;

# 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

@zoonage
Copy link
Contributor Author

zoonage commented May 3, 2018

CI breaking is due to an extra dependency that is not vendored

@zoonage
Copy link
Contributor Author

zoonage commented May 3, 2018

How do I get the DCO sign off? Do I have to sign the initial commit somehow? (presumably by a squash or history rewrite of some kind?)

Also how do I do the vendoring? govendor just complains saying Error: Package "/home/aaron/Programming/mysqld_exporter" not a go package or not in GOPATH.. Has anyone got any familiarity with the tool?

@SuperQ
Copy link
Member

SuperQ commented May 11, 2018

All commits must contain the Signed-off-by signature. Normally I do this by runninggit rebase -i origin/master and using the "reword" mode to update the commit. But it looks like you're pushing to your fork master, rather than using a branch-based fork workflow.

…utput of "SHOW SLAVE HOSTS"

Add uuid dependency to vendoring

Signed-off-by: Aaron George <aarongeorge@me.com>

Add metrics for the output of "SHOW SLAVE HOSTS"

Add uuid dependency to vendoring

Signed-off-by: Aaron George <aarongeorge@me.com>
@zoonage
Copy link
Contributor Author

zoonage commented May 14, 2018

Thanks @SuperQ just need to work out this vendoring issue now


import (
"database/sql"
"github.com/satori/go.uuid"
Copy link
Member

Choose a reason for hiding this comment

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

We normally put an empty line between Go standard libraries and external libraries.

@SuperQ
Copy link
Member

SuperQ commented May 14, 2018

It looks like there are a couple of go fmt problems that need to be fixed.

@SuperQ
Copy link
Member

SuperQ commented May 14, 2018

It looks like you've included the vendor package as a git submodule. For this project we're using govendor. You will want to do something like this:

go get -u -v github.com/kardianos/govendor
go get -u -v github.com/satori/go.uuid
govendor add github.com/satori/go.uuid@v1.2.0

Fix formatting

Signed-off-by: Aaron George <aarongeorge@me.com>
@SuperQ
Copy link
Member

SuperQ commented May 14, 2018

It looks like you need to delete that submodule stuff first before doing the govendor, as govendor isn't able to write out the vendor files.

Signed-off-by: Aaron George <aarongeorge@me.com>
@zoonage
Copy link
Contributor Author

zoonage commented May 14, 2018

Thanks @SuperQ, those builds are succeeding now!

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks!

@SuperQ
Copy link
Member

SuperQ commented May 14, 2018

Oh, sorry, I forgot one more thing. Can you document the new collector in the top level README.md?

Signed-off-by: Aaron George <aarongeorge@me.com>
@zoonage
Copy link
Contributor Author

zoonage commented May 14, 2018

@SuperQ Added to the arguments table

@zoonage
Copy link
Contributor Author

zoonage commented Jun 1, 2018

@SuperQ is this OK to go or are there some additional changes required?

@SuperQ
Copy link
Member

SuperQ commented Jun 1, 2018

Oh, sorry! This looks great.

@SuperQ SuperQ merged commit d560e62 into prometheus:master Jun 1, 2018
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

Successfully merging this pull request may close these issues.

2 participants