mysqlrouter_exporter and Router Registration
This article explains how to deploy mysqlrouter_exporter with router_exporter_install.yml and register Router metrics in Prometheus.
If you want the standalone project background first, read mysqlrouter_exporter Project Overview.
mysqlrouter_exporter now has a standalone upstream project:
- GitHub: https://github.com/fanderchan/mysqlrouter_exporter
dbbotkeepsrouter_exporter_install.ymland the compatibility role so the integrated workflow continues to work.
1. Dependency chain
| Item | Details |
|---|---|
| Prerequisites | monitoring_prometheus_deployment.yml is complete, innodb_cluster_router.yml is complete, and the Router REST API is reachable |
| Required variables | mysqlrouter_exporter_api_base_url, mysqlrouter_exporter_api_user, mysqlrouter_exporter_api_password, and mysqlrouter_exporter_port |
| Conditional variables | If router_rest_api_auth_mode: file, make sure router_rest_api_file_user / router_rest_api_file_password stays consistent with the exporter settings |
| Install mode | mysqlrouter_exporter_install_type: dbbot uses the bundled compatibility binary; package uses the standalone release artifact |
| Next step | After registration, validate the Router targets in Prometheus and the Router dashboards in Grafana; if the Router host also needs host metrics, run node_exporter_install.yml separately |
2. Default variables
The defaults live in mysql_ansible/playbooks/vars/var_router_exporter_install.yml:
mysqlrouter_exporter_install: true
mysqlrouter_exporter_install_type: dbbot
mysqlrouter_exporter_version: "0.0.1"
mysqlrouter_exporter_package: "mysqlrouter_exporter_0.0.1_linux_amd64.tar.gz"
mysqlrouter_exporter_url: "https://github.com/fanderchan/mysqlrouter_exporter/releases/download/v0.0.1/mysqlrouter_exporter_0.0.1_linux_amd64.tar.gz"
mysqlrouter_exporter_port: 9165
mysqlrouter_exporter_api_base_url: "https://127.0.0.1:8443/api/20190715"
mysqlrouter_exporter_api_user: router_api_user
mysqlrouter_exporter_api_password: "Dbbot_router_api_user@8888"
mysqlrouter_exporter_insecure_skip_verify: true
Notes:
mysqlrouter_exporter_api_base_urlreads the local Router REST API by default.- If you change the Router
httpport or bind address, update this value as well. - The default credentials are intended to match Router’s
router_rest_api_file_user/router_rest_api_file_password. mysqlrouter_exporter_install_type: dbbotuses the bundled compatibility binary from thedbbotrelease package.mysqlrouter_exporter_install_type: packagedownloads the standalone project’s release archive frommysqlrouter_exporter_url; you can override the URL to pin a specific release.
3. Execute deployment
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook router_exporter_install.yml
Additional notes:
dbbotmode directly deploys the bundledmysqlrouter_exportercompatibility binary.packagemode preparesmysqlrouter_exporter_*.tar.gzon the control host and installs from that archive on the target host.- If you want to pin a specific standalone release, override
mysqlrouter_exporter_url.
4. Register in Prometheus
Prefer the dbbotctl wrapper:
dbbotctl exporter register -t router -H 192.0.2.151 -s 192.0.2.161 -p ${prometheus_server_root_password}
dbbotctl exporter register -t router -H 192.0.2.152 -s 192.0.2.161 -p ${prometheus_server_root_password}
Additional notes:
- If you changed
mysqlrouter_exporter_port, append-Pduring registration. - If the Router REST API does not use the default
8443, append--router-api-port <port>so theinstance/service_namelabels stay correct. - You can still add labels such as
--region,--cluster,--replication-set,--node-name, and--topology.
Direct access to the underlying binary is still available:
- Bundled binary:
/usr/local/dbbot/libexec/dbbotctl/exporterregistrar - Source directory:
/usr/local/dbbot/mysql_ansible/exporterregistrar
5. Validation
On the Router host, check:
curl -k -u "${router_rest_api_file_user}:${router_rest_api_file_password}" https://127.0.0.1:8443/api/20190715/swagger.json
curl http://127.0.0.1:9165/metrics
On the Prometheus side, verify:
Status -> Targetsshowsmysqlrouter_exporter- the
mysqlrouter_upmetric is present - the Router dashboards show route, metadata refresh, and listener status