Mysql monitoring indicators
1. Mysql monitors agent survival
PromQL statement:
mysql_up{job=~".*mysql"} == 0
Description: Check whether the mysql monitoring agent is alive, or whether the mysql service is down
2. Mysql monitors the number of connections
PromQL statement:
mysql_global_status_max_used_connections{job=~".*mysql"} > mysql_global_variables_max_connections{job=~".*mysql"}*0.75
Description: If the number of mysql connections exceeds 75%, a warning message will be issued
3. Mysql monitors the number of open files
PromQL statement:
mysql_global_status_innodb_num_open_files{job=~".*mysql"} > (mysql_global_variables_open_files_limit{job=~".*mysql"}) * 0.75
Description: If the number of open mysql files exceeds 75%, a warning message will be issued
4. Mysql monitoring is read-only from the library
PromQL statement:
mysql_global_variables_read_only{job=~".*mysql"} != 0
Note: If Mysql slave is not in read-only mode, it will alarm
5. Mysql monitors master-slave delay
PromQL statement:
rate(mysql_slave_status_seconds_behind_master{job=~".*mysql"}[5m]) > 30
Note: If the Mysql master-slave delays, it will alarm
6. Mysql monitors SQL threads
PromQL statement:
mysql_slave_status_slave_sql_running != 1
Description: If the MysqlSQL thread has stopped, alarm
7, Mysql monitors IO threads
PromQL statement:
mysql_slave_status_slave_io_running != 1
Description: Mysql monitoring IO thread has stopped and alarm
8. Mysql monitors ingress traffic
PromQL statement:
round(rate(mysql_global_status_bytes_received{job=~".*mysql"}[5m]) /1024*100)/100
Note: Mysql monitors the inlet flow unit is KB, if it is greater than 1024, it will alarm
9. Mysql monitors export traffic
PromQL statement:
round(rate(mysql_global_status_bytes_sent{job=~".*mysql"}[5m]) /1024*100)/100
Note: Mysql monitors the inlet flow unit is KB, if it is greater than 1024, it will alarm
10. MySQL monitors the rate of write operations
PromQL statement:
sum(rate(mysql_global_status_commands_total{command=~"insert|update|delete",job=~".*mysql"}[5m])) without (command)
Description: MySQL monitors the rate of write operations, and alarms if it is greater than 100
11. MySQL monitor performance status
PromQL statement:
rate(mysql_global_status_slow_queries{job=~".*mysql"}[5m])
Description: MySQL monitors the performance status, and alarms if it is greater than 10
12. MySQL monitor query rate
PromQL statement:
rate(mysql_global_status_questions{job=~".*mysql"}[5m])
Description: MySQL monitors the query rate, if it is greater than 500, it will alarm
13, the number of MySQL connections available
PromQL statement:
mysql_global_variables_max_connections{job=~".*mysql"} - mysql_global_status_threads_connected{job=~".*mysql"}
Description: The number of MySQL connections available, if it is less than 500, it will alarm
14. MySQL buffer pool utilization
PromQL statement:
round((sum(mysql_global_status_buffer_pool_pages) by (job) - sum(mysql_global_status_buffer_pool_pages{state="free"}) by (job)) / sum(mysql_global_status_buffer_pool_pages) by (job) *100)
Description: The number of MySQL connections available, alarms when greater than 80%