Skip to content

Commit 1d3dbe6

Browse files
authored
Inhibit info alerts unless other alerts fire (prometheus-operator#1507)
* Inhibit info alerts unless other alerts fire * Fix nits
1 parent b2a250f commit 1d3dbe6

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

jsonnet/kube-prometheus/components/alertmanager.libsonnet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ local defaults = {
3535
source_matchers: ['severity = warning'],
3636
target_matchers: ['severity = info'],
3737
equal: ['namespace', 'alertname'],
38+
}, {
39+
source_matchers: ['alertname = InfoInhibitor'],
40+
target_matchers: ['severity = info'],
41+
equal: ['namespace'],
3842
}],
3943
route: {
4044
group_by: ['namespace'],
@@ -44,13 +48,15 @@ local defaults = {
4448
receiver: 'Default',
4549
routes: [
4650
{ receiver: 'Watchdog', matchers: ['alertname = Watchdog'] },
51+
{ receiver: 'null', matchers: ['alertname = InfoInhibitor'] },
4752
{ receiver: 'Critical', matchers: ['severity = critical'] },
4853
],
4954
},
5055
receivers: [
5156
{ name: 'Default' },
5257
{ name: 'Watchdog' },
5358
{ name: 'Critical' },
59+
{ name: 'null' },
5460
],
5561
},
5662
replicas: 3,

jsonnet/kube-prometheus/components/mixin/alerts/general.libsonnet

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
severity: 'none',
3434
},
3535
},
36+
{
37+
alert: 'InfoInhibitor',
38+
annotations: {
39+
summary: 'Info-level alert inhibition.',
40+
description: |||
41+
This is an alert that is used to inhibit info alerts.
42+
By themselves, the info-level alerts are sometimes very noisy, but they are relevant when combined with
43+
other alerts.
44+
This alert fires whenever there's a severity="info" alert, and stops firing when another alert with a
45+
severity of 'warning' or 'critical' starts firing on the same namespace.
46+
This alert should be routed to a null receiver and configured to inhibit alerts with severity="info".
47+
|||,
48+
},
49+
expr: 'ALERTS{severity = "info"} == 1 unless on(namespace) ALERTS{alertname != "InfoInhibitor", severity =~ "warning|critical", alertstate="firing"} == 1',
50+
labels: {
51+
severity: 'none',
52+
},
53+
},
3654
],
3755
},
3856
],

manifests/alertmanager-secret.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ stringData:
2828
- "severity = warning"
2929
"target_matchers":
3030
- "severity = info"
31+
- "equal":
32+
- "namespace"
33+
"source_matchers":
34+
- "alertname = InfoInhibitor"
35+
"target_matchers":
36+
- "severity = info"
3137
"receivers":
3238
- "name": "Default"
3339
- "name": "Watchdog"
3440
- "name": "Critical"
41+
- "name": "null"
3542
"route":
3643
"group_by":
3744
- "namespace"
@@ -43,6 +50,9 @@ stringData:
4350
- "matchers":
4451
- "alertname = Watchdog"
4552
"receiver": "Watchdog"
53+
- "matchers":
54+
- "alertname = InfoInhibitor"
55+
"receiver": "null"
4656
- "matchers":
4757
- "severity = critical"
4858
"receiver": "Critical"

manifests/kubePrometheus-prometheusRule.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ spec:
3838
expr: vector(1)
3939
labels:
4040
severity: none
41+
- alert: InfoInhibitor
42+
annotations:
43+
description: |
44+
This is an alert that is used to inhibit info alerts.
45+
By themselves, the info-level alerts are sometimes very noisy, but they are relevant when combined with
46+
other alerts.
47+
This alert fires whenever there's a severity="info" alert, and stops firing when another alert with a
48+
severity of 'warning' or 'critical' starts firing on the same namespace.
49+
This alert should be routed to a null receiver and configured to inhibit alerts with severity="info".
50+
runbook_url: https://runbooks.prometheus-operator.dev/runbooks/general/infoinhibitor
51+
summary: Info-level alert inhibition.
52+
expr: ALERTS{severity = "info"} == 1 unless on(namespace) ALERTS{alertname !=
53+
"InfoInhibitor", severity =~ "warning|critical", alertstate="firing"} == 1
54+
labels:
55+
severity: none
4156
- name: node-network
4257
rules:
4358
- alert: NodeNetworkInterfaceFlapping

0 commit comments

Comments
 (0)