Skip to content

prometheus-mysqld-exporter

On MySQL instance

Bash
sudo nano /etc/default/prometheus-mysqld-exporter
  • add
Bash
ARGS='--config.my-cnf /etc/mysql/prometheus.cnf'

Check more options:

Bash
ARGS='--config.my-cnf /etc/mysql/prometheus.cnf --collect.info_schema.processlist'
  • Create /etc/mysql/prometheus.cnf
Bash
sudo nano /etc/mysql/prometheus.cnf
Text Only
[client]
user = prometheus
password = prometheus
[client.servers]
user = prometheus
password = prometheus
  • Create MySQL user
MySQL
CREATE USER 'prometheus'@'%' IDENTIFIED BY 'prometheus' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'prometheus'@'%';
flush privileges;
  • Install prometheus-mysqld-exporter
Bash
sudo apt install prometheus-mysqld-exporter

Prometheus side

  • prometheus.yml
YAML
  - job_name: mysql1
    static_configs:
      - targets: ['mysql1:9104']
        labels:
          alias: mysql1

  - job_name: mysql2
    static_configs:
      - targets: ['mysql2:9104']
        labels:
          alias: mysql2