Skip to content

Commit

Permalink
Add a function to remove an alert rule (#812)
Browse files Browse the repository at this point in the history
Signed-off-by: Callum Styan <[email protected]>
  • Loading branch information
cstyan authored Jul 26, 2022
1 parent f8d8de5 commit f0a2740
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mixin-utils/utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,15 @@ local g = import 'grafana-builder/grafana.libsonnet';
groups: std.map(overrideInGroup, super.groups),
},
},

removeAlerts(alerts):: {
local removeRule(rule) =
if 'alert' in rule && std.objectHas(alerts, rule.alert)
then {}
else rule,
local removeInGroup(group) = group { rules: std.map(removeRule, super.rules) },
prometheusAlerts+:: {
groups: std.prune(std.map(removeInGroup, super.groups)),
},
},
}

0 comments on commit f0a2740

Please sign in to comment.