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:

1. Dependency chain

ItemDetails
Prerequisitesmonitoring_prometheus_deployment.yml is complete, innodb_cluster_router.yml is complete, and the Router REST API is reachable
Required variablesmysqlrouter_exporter_api_base_url, mysqlrouter_exporter_api_user, mysqlrouter_exporter_api_password, and mysqlrouter_exporter_port
Conditional variablesIf 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 modemysqlrouter_exporter_install_type: dbbot uses the bundled compatibility binary; package uses the standalone release artifact
Next stepAfter 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_url reads the local Router REST API by default.
  • If you change the Router http port 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: dbbot uses the bundled compatibility binary from the dbbot release package.
  • mysqlrouter_exporter_install_type: package downloads the standalone project’s release archive from mysqlrouter_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:

  • dbbot mode directly deploys the bundled mysqlrouter_exporter compatibility binary.
  • package mode prepares mysqlrouter_exporter_*.tar.gz on 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 -P during registration.
  • If the Router REST API does not use the default 8443, append --router-api-port <port> so the instance / service_name labels 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 -> Targets shows mysqlrouter_exporter
  • the mysqlrouter_up metric is present
  • the Router dashboards show route, metadata refresh, and listener status