Skip to content

mysql

Use case

Watch a MySQL/MariaDB server’s basic load (connections, memory, query rate) and, optionally, replication lag on a replica. Connects natively (no mysql CLI/libmysqlclient dependency).

Configuration

Field Type Meaning
defaults_file string path to a my.cnf-style file with a [client] section (host/user/password/port/socket); default /opt/cmt/mysql.cnf
is_slave bool also check replication status; default false
max_behind int seconds; is_slave only - alert if the replica is further behind than this; default 900

mysql_*_rate items are per-second rates derived from a raw counter sample kept from this same check’s previous run - not computed on the first run, or if more than 900s have elapsed since then.

Output

In this order, all datapoints:

Item Type Meaning
mysql_version string server version string
mysql_connection int Threads_connected
mysql_runner int Threads_running
mysql_memory int (bytes) Memory_used
mysql_read_rate float (r/sec) Com_select, per second (after a previous sample exists)
mysql_write_rate float (w/sec) Com_insert+Com_update+Com_delete, per second
mysql_query_rate float (q/sec) Queries, per second
mysql_cx_rate float (conn/s) Connections, per second
mysql_slave_io_run string Slave_IO_Running (is_slave only)
mysql_slave_sql_run string Slave_SQL_Running (is_slave only)
mysql_slave_mpos string Master_Log_File (is_slave only)
mysql_slave_rpos string Relay_Master_Log_File (is_slave only)
mysql_slave_behind int (sec) Seconds_Behind_Master, or 999999999 if unavailable (is_slave only)

Example

checks:
  - module: mysql
    name: mydbcheck
    conf:
      defaults_file: /opt/cmt/mysql.cnf
      is_slave: true
      max_behind: 300
      severity_max: error
# /opt/cmt/mysql.cnf
[client]
host     = 127.0.0.1
user     = root
password = xxxxxxx
port     = 3306