About mysqld_exporter
mysqld_exporter is used to expose MySQL instance status to Prometheus. dbbot has provided default deployment variables and systemd templates.
Default values
The default variables are located in mysql_ansible/playbooks/default/var_mysqld_exporter_install.yml:
mysqld_exporter_install: truemysqld_exporter_install_type: dbbotmysqld_exporter_topology: automysqld_exporter_port: auto
Description:
- By default, the
mysqld_exporterbinary built into the dbbot repository is used. mysqld_exporter_topology: autoresolves automatically tomsormgr.mysqld_exporter_port: autowill automatically derive the exporter listening port according to9104 + (mysql_port - 3306).
Dependency chain
| Item | Details |
|---|---|
| Prerequisites | The MySQL instance is already deployed, mysql_admin_user / mysql_admin_password can log in locally, and for package mode the control node either has internet access or the offline package is already prepared |
| Required variables | mysqld_exporter_install_type, mysqld_exporter_topology, and mysqld_exporter_port; if the monitor account should be created automatically, keep fcs_role_mysqld_exporter_create_monitor_user: true |
| Next step | Register the exporter with dbbotctl exporter register -t mysql; if host metrics are also needed, run node_exporter_install.yml; if Router metrics are also needed, continue with router_exporter_install.yml |
Common scenarios
Primary-replica or single instance:
mysqld_exporter_install: true
mysqld_exporter_install_type: dbbot
mysqld_exporter_topology: auto
mysqld_exporter_port: auto
MGR:
mysqld_exporter_install: true
mysqld_exporter_install_type: dbbot
mysqld_exporter_topology: mgr
mysqld_exporter_port: auto
Multi-instance port planning
Default automatic derivation rules:
3306->91043307->91053310->9108
If you prefer to fix it to a custom port, you can also specify it explicitly:
mysqld_exporter_port: 9201
package mode
If you want to use the official release package, you can switch to package mode:
mysqld_exporter_install_type: package
mysqld_exporter_package: mysqld_exporter-0.18.0.linux-amd64.tar.gz
Official download example:
wget "https://github.com/prometheus/mysqld_exporter/releases/download/v0.18.0/mysqld_exporter-0.18.0.linux-amd64.tar.gz"
At this time any of the following conditions need to be met:
- Keep
fcs_auto_download_packages: trueso the control node can auto-download it - Or place the package into
mysql_ansible/downloads/in advance and setfcs_auto_download_packages: false
Used in conjunction with exporterregistrar
dbbotctl exporter register reuses exporterregistrar underneath and will also derive the MySQL exporter port from --db-port when -P is not explicitly specified.
Example:
dbbotctl exporter register -t mysql -H 192.0.2.131 --db-port 3310 -s 192.0.2.161 -p ${prometheus_server_root_password}
Execution entry
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook mysqld_exporter_install.yml
Compatibility note:
- The old
exporter_install.ymlentry still exists, but it is now only a compatibility alias formysqld_exporter_install.ymland no longer installsnode_exporterimplicitly.