Skip to content

Commit d32e2ef

Browse files
authored
Fix patch_alerts (#1425)
1 parent b90276e commit d32e2ef

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

grafana-cloud-integration-utils/util.libsonnet

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,27 @@ local integration_version_panel(version, statusPanelDataSource, height, width, x
186186
// }
187187
// patch format:
188188
// {
189-
// Alert1+: {
189+
// Alert1: {
190190
// labels+: {
191191
// new_label: 'abc',
192192
// asserts_severity: super.severity,
193193
// }
194194
// },
195-
// Alert2+: {
195+
// Alert2: {
196196
// labels+: {
197197
// new_label: 'zyx',
198198
// }
199199
// }
200200
// }
201201
patch_alerts(prometheusAlerts, group_name, alert_rules_patch)::
202202
local patch_rules(rules, patch) =
203-
std.objectValues(
204-
{
205-
[o.key]: o.value[0]
206-
for o
207-
in
208-
std.objectKeysValues(xtd.aggregate.byKey(rules, 'alert'))
209-
}
210-
+ patch
211-
);
212-
203+
[
204+
if std.objectHasAll(patch, rule.alert) then
205+
rule + patch[rule.alert]
206+
else rule
207+
for rule
208+
in rules
209+
];
213210
{
214211
groups+:
215212
[

0 commit comments

Comments
 (0)