From 74692676af6d5b20d53fde4d6295753a56b9504e Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Tue, 21 Jun 2022 14:36:05 -0700 Subject: [PATCH] Add a function to remove an alert rule Signed-off-by: Callum Styan --- mixin-utils/utils.libsonnet | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mixin-utils/utils.libsonnet b/mixin-utils/utils.libsonnet index def1e87fb..051f09bab 100644 --- a/mixin-utils/utils.libsonnet +++ b/mixin-utils/utils.libsonnet @@ -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)), + }, + }, }