From 18f6c45a5f2ac8f40fc88e86c20a8888bf76973a Mon Sep 17 00:00:00 2001 From: asdf1234 Date: Sat, 30 Nov 2024 09:09:21 +0800 Subject: [PATCH 1/2] Update mysqld-exporter.yml add some rules --- dist/rules/mysql/mysqld-exporter.yml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dist/rules/mysql/mysqld-exporter.yml b/dist/rules/mysql/mysqld-exporter.yml index 380fca3b1..a9bdff858 100644 --- a/dist/rules/mysql/mysqld-exporter.yml +++ b/dist/rules/mysql/mysqld-exporter.yml @@ -93,3 +93,48 @@ groups: annotations: summary: MySQL restarted (instance {{ $labels.instance }}) description: "MySQL has just been restarted, less than one minute ago on {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + + - alert: Mysql_High_QPS + expr: 'irate(mysql_global_status_questions[1m]) > 10000' + for: 2m + labels: + severity: info + annotations: + summary: Mysql_High_QPS (instance {{ $labels.instance }}) + description: "Mysql_High_QPS on {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + + - alert: MySQL too many open files + expr: 'mysql_global_status_innodb_num_open_files / mysql_global_variables_open_files_limit * 100 > 75' + for: 2m + labels: + severity: warning + annotations: + summary: MySQL too many Open files (instance {{ $labels.instance }}) + description: "MySQL too many Open files,please conside increase variables open_files_limit {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + + - alert: MySQL too many connections + expr: 'sum by(instance) (mysql_info_schema_processes_by_host) / sum by(instance) (mysql_global_variables_max_connections) * 100 > 80' + for: 2m + labels: + severity: warning + annotations: + summary: MySQL too many connections (instance {{ $labels.instance }}) + description: "MySQL too many connections,current connections is more than 80% {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + + - alert: MySQL InnoDB Force Recovery is enabled + expr: 'mysql_global_variables_innodb_force_recovery != 0' + for: 2m + labels: + severity: warning + annotations: + summary: MySQL InnoDB Force Recovery is enabled (instance {{ $labels.instance }}) + description: "MySQL InnoDB Force Recovery not equal 0 {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + + - alert: MySQL InnoDB history_len too long + expr: 'mysql_info_schema_innodb_metrics_transaction_trx_rseg_history_len > 50000' + for: 2m + labels: + severity: warning + annotations: + summary: MySQL history_len (undo log) too long (instance {{ $labels.instance }}) + description: "MySQL history_len (undo log) too long {{ $labels.instance }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" From aa84f3ac957e2231755976a4f1a499b918df10b6 Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Sat, 30 Nov 2024 10:23:47 +0100 Subject: [PATCH 2/2] Add new MySQL monitoring rules --- _data/rules.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/_data/rules.yml b/_data/rules.yml index f05d28916..cf744c7cb 100644 --- a/_data/rules.yml +++ b/_data/rules.yml @@ -628,6 +628,26 @@ groups: description: MySQL has just been restarted, less than one minute ago on {{ $labels.instance }}. query: "mysql_global_status_uptime < 60" severity: info + - name: MySQL High QPS + description: MySQL is being overload with unusual QPS (> 10k QPS). + query: "irate(mysql_global_status_questions[1m]) > 10000" + severity: info + for: 2m + - name: MySQL too many open files + description: MySQL has too many open files, consider increase variables open_files_limit on {{ $labels.instance }}. + query: "mysql_global_status_innodb_num_open_files / mysql_global_variables_open_files_limit * 100 > 75" + severity: warning + for: 2m + - name: MySQL InnoDB Force Recovery is enabled + description: "MySQL InnoDB force recovery is enabled on {{ $labels.instance }}" + query: "mysql_global_variables_innodb_force_recovery != 0" + severity: warning + for: 2m + - name: MySQL InnoDB history_len too long + description: "MySQL history_len (undo log) too long on {{ $labels.instance }}" + query: "mysql_info_schema_innodb_metrics_transaction_trx_rseg_history_len > 50000" + severity: warning + for: 2m - name: PostgreSQL exporters: