1
1
groups :
2
- - name : MySQLExporterK8s
3
-
2
+ - name : MySQL General Alert Rules
4
3
rules :
5
- # 2.1.1
6
4
- alert : MySQLDown
7
- expr : " mysql_up == 0"
5
+ expr : mysql_up == 0
8
6
for : 0m
9
7
labels :
10
8
severity : critical
11
9
annotations :
12
- summary : MySQL instance {{ $labels.instance }} is down.
10
+ summary : MySQL instance {{ $labels.instance }} is down.
13
11
description : |
12
+ The MySQL instance is not reachable.
13
+ Please check if the MySQL process is running and the network connectivity.
14
+ LABELS = {{ $labels }}.
15
+
16
+ - alert : MySQLMetricsScrapeError
17
+ expr : increase(mysql_exporter_last_scrape_error[5m]) > 1
18
+ for : 0m
19
+ labels :
20
+ severity : warning
21
+ annotations :
22
+ summary : MySQL instance {{ $labels.instance }} has a metrics scrape error.
23
+ description : |
24
+ The MySQL Exporter encountered an error while scraping metrics.
25
+ Check the MySQL Exporter logs for more details.
14
26
LABELS = {{ $labels }}.
15
27
16
- # 2.1.2
17
- # customized: 80% -> 90%
18
28
- alert : MySQLTooManyConnections(>90%)
19
29
expr : max_over_time(mysql_global_status_threads_connected[1m]) / mysql_global_variables_max_connections * 100 > 90
20
30
for : 2m
@@ -24,10 +34,8 @@ groups:
24
34
summary : MySQL instance {{ $labels.instance }} is using > 90% of `max_connections`.
25
35
description : |
26
36
Consider checking the client application responsible for generating those additional connections.
27
- LABELS = {{ $labels }}.
37
+ LABELS = {{ $labels }}.
28
38
29
- # 2.1.4
30
- # customized: 60% -> 80%
31
39
- alert : MySQLHighThreadsRunning
32
40
expr : max_over_time(mysql_global_status_threads_running[1m]) / mysql_global_variables_max_connections * 100 > 80
33
41
for : 2m
@@ -36,10 +44,9 @@ groups:
36
44
annotations :
37
45
summary : MySQL instance {{ $labels.instance }} is actively using > 80% of `max_connections`.
38
46
description : |
39
- Consider reviewing the value of the `max-connections` config parameter or allocate more resources to your database server.
40
- LABELS = {{ $labels }}.
47
+ Consider reviewing the value of the `max-connections` config parameter or allocate more resources to your database server.
48
+ LABELS = {{ $labels }}.
41
49
42
- # 2.1.3
43
50
- alert : MySQLHighPreparedStatementsUtilization(>80%)
44
51
expr : max_over_time(mysql_global_status_prepared_stmt_count[1m]) / mysql_global_variables_max_prepared_stmt_count * 100 > 80
45
52
for : 2m
@@ -48,36 +55,32 @@ groups:
48
55
annotations :
49
56
summary : MySQL instance {{ $labels.instance }} is using > 80% of `max_prepared_stmt_count`.
50
57
description : |
51
- Too many prepared statements might consume a lot of memory.
52
- LABELS = {{ $labels }}.
58
+ Too many prepared statements might consume a lot of memory.
59
+ LABELS = {{ $labels }}.
53
60
54
- # 2.1.8
55
- # customized: warning -> info
56
61
- alert : MySQLSlowQueries
57
62
expr : increase(mysql_global_status_slow_queries[1m]) > 0
58
63
for : 2m
59
64
labels :
60
65
severity : info
61
66
annotations :
62
- summary : MySQL instance {{ $labels.instance }} has a slow query .
67
+ summary : MySQL instance {{ $labels.instance }} has slow queries .
63
68
description : |
64
- Consider optimizing the query by reviewing its execution plan, then rewrite the query and add any relevant indexes.
69
+ Consider optimizing the query by reviewing its execution plan, then rewrite the query and add any relevant indexes.
65
70
LABELS = {{ $labels }}.
66
71
67
- # 2.1.9
68
72
- alert : MySQLInnoDBLogWaits
69
73
expr : rate(mysql_global_status_innodb_log_waits[15m]) > 10
70
74
for : 0m
71
75
labels :
72
76
severity : warning
73
77
annotations :
74
- summary : MySQL instance {{ $labels.instance }} has long InnoDB log waits.
78
+ summary : MySQL instance {{ $labels.instance }} has long InnoDB log waits.
75
79
description : |
76
- MySQL InnoDB log writes might be stalling.
77
- Check I/O activity on your nodes to find the responsible process or query. Consider using iotop and the performance_schema.
80
+ MySQL InnoDB log writes might be stalling.
81
+ Check I/O activity on your nodes to find the responsible process or query. Consider using iotop and the performance_schema.
78
82
LABELS = {{ $labels }}.
79
83
80
- # 2.1.10
81
84
- alert : MySQLRestarted
82
85
expr : mysql_global_status_uptime < 60
83
86
for : 0m
@@ -86,6 +89,18 @@ groups:
86
89
annotations :
87
90
summary : MySQL instance {{ $labels.instance }} restarted.
88
91
description : |
89
- MySQL restarted less than one minute ago.
90
- If the restart was unplanned or frequent, check Loki logs (e.g. `error.log`).
92
+ MySQL restarted less than one minute ago.
93
+ If the restart was unplanned or frequent, check Loki logs (e.g. `error.log`).
94
+ LABELS = {{ $labels }}.
95
+
96
+ - alert : MySQLConnectionErrors
97
+ expr : increase(mysql_global_status_connection_errors_total[5m]) > 10
98
+ for : 0m
99
+ labels :
100
+ severity : warning
101
+ annotations :
102
+ summary : MySQL instance {{ $labels.instance }} has connection errors.
103
+ description : |
104
+ Connection errors might indicate network issues, authentication problems, or resource limitations.
105
+ Check the MySQL logs for more details.
91
106
LABELS = {{ $labels }}.
0 commit comments