forked from grafana/mimir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalerts.libsonnet
More file actions
632 lines (629 loc) · 22.8 KB
/
Copy pathalerts.libsonnet
File metadata and controls
632 lines (629 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
(import 'alerts-utils.libsonnet') {
// simpleRegexpOpt produces a simple regexp that matches all strings in the input array.
local simpleRegexpOpt(strings) =
assert std.isArray(strings) : 'simpleRegexpOpt requires that `strings` is an array of strings`';
'(' + std.join('|', strings) + ')',
local groupDeploymentByRolloutGroup(metricName) =
'sum without(deployment) (label_replace(%s, "rollout_group", "$1", "deployment", "(.*?)(?:-zone-[a-z])?"))' % metricName,
local groupStatefulSetByRolloutGroup(metricName) =
'sum without(statefulset) (label_replace(%s, "rollout_group", "$1", "statefulset", "(.*?)(?:-zone-[a-z])?"))' % metricName,
groups+: [
{
name: 'mimir_alerts',
rules: [
{
alert: $.alertName('IngesterUnhealthy'),
'for': '15m',
expr: |||
min by (%s) (cortex_ring_members{state="Unhealthy", name="ingester"}) > 0
||| % $._config.alert_aggregation_labels,
labels: {
severity: 'critical',
},
annotations: {
message: '%(product)s cluster %(alert_aggregation_variables)s has {{ printf "%%f" $value }} unhealthy ingester(s).' % $._config,
},
},
{
alert: $.alertName('RequestErrors'),
// Note if alert_aggregation_labels is "job", this will repeat the label. But
// prometheus seems to tolerate that.
expr: |||
100 * sum by (%(group_by)s, job, route) (rate(cortex_request_duration_seconds_count{status_code=~"5..",route!~"%(excluded_routes)s"}[1m]))
/
sum by (%(group_by)s, job, route) (rate(cortex_request_duration_seconds_count{route!~"%(excluded_routes)s"}[1m]))
> 1
||| % {
group_by: $._config.alert_aggregation_labels,
excluded_routes: std.join('|', ['ready'] + $._config.alert_excluded_routes),
},
'for': '15m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
The route {{ $labels.route }} in %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% errors.
||| % $._config,
},
},
{
alert: $.alertName('RequestLatency'),
expr: |||
%(group_prefix_jobs)s_route:cortex_request_duration_seconds:99quantile{route!~"%(excluded_routes)s"}
>
%(cortex_p99_latency_threshold_seconds)s
||| % $._config {
excluded_routes: std.join('|', [
'metrics',
'/frontend.Frontend/Process',
'ready',
'/schedulerpb.SchedulerForFrontend/FrontendLoop',
'/schedulerpb.SchedulerForQuerier/QuerierLoop',
] + $._config.alert_excluded_routes),
},
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
{{ $labels.job }} {{ $labels.route }} is experiencing {{ printf "%.2f" $value }}s 99th percentile latency.
|||,
},
},
{
alert: $.alertName('QueriesIncorrect'),
expr: |||
100 * sum by (%s) (rate(test_exporter_test_case_result_total{result="fail"}[5m]))
/
sum by (%s) (rate(test_exporter_test_case_result_total[5m])) > 1
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
The %(product)s cluster %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% incorrect query results.
||| % $._config,
},
},
{
alert: $.alertName('InconsistentRuntimeConfig'),
expr: |||
count(count by(%s, job, sha256) (cortex_runtime_config_hash)) without(sha256) > 1
||| % $._config.alert_aggregation_labels,
'for': '1h',
labels: {
severity: 'critical',
},
annotations: {
message: |||
An inconsistent runtime config file is used across cluster %(alert_aggregation_variables)s.
||| % $._config,
},
},
{
alert: $.alertName('BadRuntimeConfig'),
expr: |||
# The metric value is reset to 0 on error while reloading the config at runtime.
cortex_runtime_config_last_reload_successful == 0
|||,
// Alert quicker for human errors.
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
{{ $labels.job }} failed to reload runtime config.
|||,
},
},
{
alert: $.alertName('FrontendQueriesStuck'),
expr: |||
sum by (%s) (cortex_query_frontend_queue_length) > 1
||| % $._config.alert_aggregation_labels,
'for': '5m', // We don't want to block for longer.
labels: {
severity: 'critical',
},
annotations: {
message: |||
There are {{ $value }} queued up queries in %(alert_aggregation_variables)s query-frontend.
||| % $._config,
},
},
{
alert: $.alertName('SchedulerQueriesStuck'),
expr: |||
sum by (%s) (cortex_query_scheduler_queue_length) > 1
||| % $._config.alert_aggregation_labels,
'for': '5m', // We don't want to block for longer.
labels: {
severity: 'critical',
},
annotations: {
message: |||
There are {{ $value }} queued up queries in %(alert_aggregation_variables)s query-scheduler.
||| % $._config,
},
},
{
alert: $.alertName('MemcachedRequestErrors'),
expr: |||
(
sum by(%s, name, operation) (rate(thanos_memcached_operation_failures_total[1m])) /
sum by(%s, name, operation) (rate(thanos_memcached_operations_total[1m]))
) * 100 > 5
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Memcached {{ $labels.name }} used by %(product)s %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% errors for {{ $labels.operation }} operation.
||| % $._config,
},
},
{
alert: $.alertName('IngesterRestarts'),
expr: |||
changes(process_start_time_seconds{job=~".+(cortex|ingester.*)"}[30m]) >= 2
|||,
labels: {
// This alert is on a cause not symptom. A couple of ingesters restarts may be suspicious but
// not necessarily an issue (eg. may happen because of the K8S node autoscaler), so we're
// keeping the alert as warning as a signal in case of an outage.
severity: 'warning',
},
annotations: {
message: '{{ $labels.job }}/{{ $labels.instance }} has restarted {{ printf "%.2f" $value }} times in the last 30 mins.',
},
},
{
alert: $.alertName('KVStoreFailure'),
expr: |||
(
sum by(%s, pod, status_code, kv_name) (rate(cortex_kv_request_duration_seconds_count{status_code!~"2.+"}[1m]))
/
sum by(%s, pod, status_code, kv_name) (rate(cortex_kv_request_duration_seconds_count[1m]))
)
# We want to get alerted only in case there's a constant failure.
== 1
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
%(product)s {{ $labels.pod }} in %(alert_aggregation_variables)s is failing to talk to the KV store {{ $labels.kv_name }}.
||| % $._config,
},
},
{
alert: $.alertName('MemoryMapAreasTooHigh'),
expr: |||
process_memory_map_areas{job=~".+(cortex|ingester.*|store-gateway.*)"} / process_memory_map_areas_limit{job=~".+(cortex|ingester.*|store-gateway.*)"} > 0.8
|||,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: '{{ $labels.job }}/{{ $labels.instance }} has a number of mmap-ed areas close to the limit.',
},
},
],
},
{
name: 'mimir_instance_limits_alerts',
rules: [
{
alert: $.alertName('IngesterReachingSeriesLimit'),
expr: |||
(
(cortex_ingester_memory_series / ignoring(limit) cortex_ingester_instance_limits{limit="max_series"})
and ignoring (limit)
(cortex_ingester_instance_limits{limit="max_series"} > 0)
) > 0.8
|||,
'for': '3h',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Ingester {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its series limit.
|||,
},
},
{
alert: $.alertName('IngesterReachingSeriesLimit'),
expr: |||
(
(cortex_ingester_memory_series / ignoring(limit) cortex_ingester_instance_limits{limit="max_series"})
and ignoring (limit)
(cortex_ingester_instance_limits{limit="max_series"} > 0)
) > 0.9
|||,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
Ingester {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its series limit.
|||,
},
},
{
alert: $.alertName('IngesterReachingTenantsLimit'),
expr: |||
(
(cortex_ingester_memory_users / ignoring(limit) cortex_ingester_instance_limits{limit="max_tenants"})
and ignoring (limit)
(cortex_ingester_instance_limits{limit="max_tenants"} > 0)
) > 0.7
|||,
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Ingester {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its tenant limit.
|||,
},
},
{
alert: $.alertName('IngesterReachingTenantsLimit'),
expr: |||
(
(cortex_ingester_memory_users / ignoring(limit) cortex_ingester_instance_limits{limit="max_tenants"})
and ignoring (limit)
(cortex_ingester_instance_limits{limit="max_tenants"} > 0)
) > 0.8
|||,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
Ingester {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its tenant limit.
|||,
},
},
{
alert: $.alertName('ReachingTCPConnectionsLimit'),
expr: |||
cortex_tcp_connections / cortex_tcp_connections_limit > 0.8 and
cortex_tcp_connections_limit > 0
|||,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
%(product)s instance {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its TCP connections limit for {{ $labels.protocol }} protocol.
||| % $._config,
},
},
{
alert: $.alertName('DistributorReachingInflightPushRequestLimit'),
expr: |||
(
(cortex_distributor_inflight_push_requests / ignoring(limit) cortex_distributor_instance_limits{limit="max_inflight_push_requests"})
and ignoring (limit)
(cortex_distributor_instance_limits{limit="max_inflight_push_requests"} > 0)
) > 0.8
|||,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
Distributor {{ $labels.job }}/{{ $labels.instance }} has reached {{ $value | humanizePercentage }} of its inflight push request limit.
|||,
},
},
],
},
{
name: 'mimir-rollout-alerts',
rules: [
{
alert: $.alertName('RolloutStuck'),
expr: |||
(
max without (revision) (
%(kube_statefulset_status_current_revision)s
unless
%(kube_statefulset_status_update_revision)s
)
*
(
%(kube_statefulset_replicas)s
!=
%(kube_statefulset_status_replicas_updated)s
)
) and (
changes(%(kube_statefulset_status_replicas_updated)s[15m:1m])
==
0
)
* on(%(aggregation_labels)s) group_left max by(%(aggregation_labels)s) (cortex_build_info)
||| % {
aggregation_labels: $._config.alert_aggregation_labels,
kube_statefulset_status_current_revision: groupStatefulSetByRolloutGroup('kube_statefulset_status_current_revision'),
kube_statefulset_status_update_revision: groupStatefulSetByRolloutGroup('kube_statefulset_status_update_revision'),
kube_statefulset_replicas: groupStatefulSetByRolloutGroup('kube_statefulset_replicas'),
kube_statefulset_status_replicas_updated: groupStatefulSetByRolloutGroup('kube_statefulset_status_replicas_updated'),
},
'for': '30m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
The {{ $labels.rollout_group }} rollout is stuck in %(alert_aggregation_variables)s.
||| % $._config,
},
},
{
alert: $.alertName('RolloutStuck'),
expr: |||
(
%(kube_deployment_spec_replicas)s
!=
%(kube_deployment_status_replicas_updated)s
) and (
changes(%(kube_deployment_status_replicas_updated)s[15m:1m])
==
0
)
* on(%(aggregation_labels)s) group_left max by(%(aggregation_labels)s) (cortex_build_info)
||| % {
aggregation_labels: $._config.alert_aggregation_labels,
kube_deployment_spec_replicas: groupDeploymentByRolloutGroup('kube_deployment_spec_replicas'),
kube_deployment_status_replicas_updated: groupDeploymentByRolloutGroup('kube_deployment_status_replicas_updated'),
},
'for': '30m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
The {{ $labels.rollout_group }} rollout is stuck in %(alert_aggregation_variables)s.
||| % $._config,
},
},
],
},
{
name: 'mimir-provisioning',
rules: [
{
alert: $.alertName('ProvisioningTooManyActiveSeries'),
// We target each ingester to 1.5M in-memory series. This alert fires if the average
// number of series / ingester in a Mimir cluster is > 1.6M for 2h (we compact
// the TSDB head every 2h).
expr: |||
avg by (%s) (cortex_ingester_memory_series) > 1.6e6
||| % [$._config.alert_aggregation_labels],
'for': '2h',
labels: {
severity: 'warning',
},
annotations: {
message: |||
The number of in-memory series per ingester in %(alert_aggregation_variables)s is too high.
||| % $._config,
},
},
{
alert: $.alertName('ProvisioningTooManyWrites'),
// 80k writes / s per ingester max.
expr: |||
avg by (%(alert_aggregation_labels)s) (%(alert_aggregation_rule_prefix)s_%(per_instance_label)s:cortex_ingester_ingested_samples_total:rate1m) > 80e3
||| % $._config,
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Ingesters in %(alert_aggregation_variables)s ingest too many samples per second.
||| % $._config,
},
},
{
alert: $.alertName('AllocatingTooMuchMemory'),
expr: |||
(
container_memory_working_set_bytes{container="ingester"}
/
container_spec_memory_limit_bytes{container="ingester"}
) > 0.65
|||,
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Ingester {{ $labels.pod }} in %(alert_aggregation_variables)s is using too much memory.
||| % $._config,
},
},
{
alert: $.alertName('AllocatingTooMuchMemory'),
expr: |||
(
container_memory_working_set_bytes{container="ingester"}
/
container_spec_memory_limit_bytes{container="ingester"}
) > 0.8
|||,
'for': '15m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
Ingester {{ $labels.pod }} in %(alert_aggregation_variables)s is using too much memory.
||| % $._config,
},
},
],
},
{
name: 'ruler_alerts',
rules: [
{
alert: $.alertName('RulerTooManyFailedPushes'),
expr: |||
100 * (
sum by (%s, instance) (rate(cortex_ruler_write_requests_failed_total[1m]))
/
sum by (%s, instance) (rate(cortex_ruler_write_requests_total[1m]))
) > 1
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
%(product)s Ruler {{ $labels.instance }} in %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% write (push) errors.
||| % $._config,
},
},
{
alert: $.alertName('RulerTooManyFailedQueries'),
expr: |||
100 * (
sum by (%s, instance) (rate(cortex_ruler_queries_failed_total[1m]))
/
sum by (%s, instance) (rate(cortex_ruler_queries_total[1m]))
) > 1
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
%(product)s Ruler {{ $labels.instance }} in %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% errors while evaluating rules.
||| % $._config,
},
},
{
alert: $.alertName('RulerMissedEvaluations'),
expr: |||
sum by (%s, instance, rule_group) (rate(cortex_prometheus_rule_group_iterations_missed_total[1m]))
/
sum by (%s, instance, rule_group) (rate(cortex_prometheus_rule_group_iterations_total[1m]))
> 0.01
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels],
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
%(product)s Ruler {{ $labels.instance }} in %(alert_aggregation_variables)s is experiencing {{ printf "%%.2f" $value }}%% missed iterations for the rule group {{ $labels.rule_group }}.
||| % $._config,
},
},
{
alert: $.alertName('RulerFailedRingCheck'),
expr: |||
sum by (%s, job) (rate(cortex_ruler_ring_check_errors_total[1m]))
> 0
||| % $._config.alert_aggregation_labels,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
%(product)s Rulers in %(alert_aggregation_variables)s are experiencing errors when checking the ring for rule group ownership.
||| % $._config,
},
},
],
},
{
name: 'gossip_alerts',
rules: [
{
alert: $.alertName('GossipMembersMismatch'),
expr:
|||
memberlist_client_cluster_members_count
!= on (%s) group_left
sum by (%s) (up{job=~".+/%s"})
||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels, simpleRegexpOpt($._config.job_names.ring_members)],
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
message: '%(product)s instance {{ $labels.instance }} in %(alert_aggregation_variables)s sees incorrect number of gossip members.' % $._config,
},
},
],
},
{
name: 'etcd_alerts',
rules: [
{
alert: 'EtcdAllocatingTooMuchMemory',
expr: |||
(
container_memory_working_set_bytes{container="etcd"}
/
container_spec_memory_limit_bytes{container="etcd"}
) > 0.65
|||,
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
message: |||
Too much memory being used by {{ $labels.namespace }}/{{ $labels.pod }} - bump memory limit.
|||,
},
},
{
alert: 'EtcdAllocatingTooMuchMemory',
expr: |||
(
container_memory_working_set_bytes{container="etcd"}
/
container_spec_memory_limit_bytes{container="etcd"}
) > 0.8
|||,
'for': '15m',
labels: {
severity: 'critical',
},
annotations: {
message: |||
Too much memory being used by {{ $labels.namespace }}/{{ $labels.pod }} - bump memory limit.
|||,
},
},
],
},
],
}