groups:

  • name: MySQLStatsAlert
    rules:
    • alert: MySQL is down
      expr: mysql_up == 0
      for: 1m
      labels:
      severity: critical
      annotations:
      summary: "Instance {{ $labels.instance }} MySQL is down"
      description: "MySQL database is down. This requires immediate action!"
    • alert: open files high
      expr: mysql_global_status_innodb_num_open_files > (mysql_global_variables_open_files_limit) * 0.75
      for: 1m
      labels:
      severity: warning
      annotations:
      summary: "Instance {{ $labels.instance }} open files high"
      description: "Open files is high. Please consider increasing open_files_limit."
    • alert: Mysql_Too_Many_Slow_Query
      expr: rate(mysql_global_status_slow_queries[30m]) > 3
      for: 2m
      labels:
      severity: warning
      annotations:
      summary: "Instance {{ $labels.instance }} Mysql_Too_Many_Slow_Query detected"
      description: "{{$labels.instance}}: Mysql current Slow_Query Sql is more than 3 ,(current value is: {{ $value }})"
    • alert: Mysql_Deadlock
      expr: mysql_global_status_innodb_deadlocks > 0
      for: 2m
      labels:
      severity: warning
      annotations:
      summary: "Instance {{ $labels.instance }} Mysql_Deadlock detected"
      description: "Open files is high. Mysql Deadlock was found ,(current value is: {{ $value }})"
    • alert: Mysql_Too_Many_sleep_threads
      expr: mysql_global_status_threads_running / mysql_global_status_threads_connected * 100 < 30
      for: 2m
      labels:
      severity: warning
      annotations:
      summary: "{{$labels.instance}}: Mysql_Too_Many_sleep_threads detected"
      description: "{{$labels.instance}}: Mysql_sleep_threads percent is more than {{ $value }}, please clean the sleeping threads"