Skip to content

Commit f0a2740

Browse files
authored
Add a function to remove an alert rule (#812)
Signed-off-by: Callum Styan <[email protected]>
1 parent f8d8de5 commit f0a2740

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mixin-utils/utils.libsonnet

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,15 @@ local g = import 'grafana-builder/grafana.libsonnet';
166166
groups: std.map(overrideInGroup, super.groups),
167167
},
168168
},
169+
170+
removeAlerts(alerts):: {
171+
local removeRule(rule) =
172+
if 'alert' in rule && std.objectHas(alerts, rule.alert)
173+
then {}
174+
else rule,
175+
local removeInGroup(group) = group { rules: std.map(removeRule, super.rules) },
176+
prometheusAlerts+:: {
177+
groups: std.prune(std.map(removeInGroup, super.groups)),
178+
},
179+
},
169180
}

0 commit comments

Comments
 (0)