Skip to content

Commit 113fa69

Browse files
authored
Not all Prometheus rules are alerts. (#490)
* Not all Prometheus rules are alerts. This allows us to put recording rules in the same rule groups as alerts, which is useful when the alerts depend on the recording rules. Signed-off-by: Tom Wilkie <[email protected]> * make fmt Signed-off-by: Tom Wilkie <[email protected]>
1 parent 96b03e7 commit 113fa69

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mixin-utils/utils.libsonnet

+9-5
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,18 @@ local g = import 'grafana-builder/grafana.libsonnet';
123123
// - url_format: an URL format for the runbook, the alert name will be substituted in the URL.
124124
// - groups: the list of rule groups containing alerts.
125125
withRunbookURL(url_format, groups)::
126+
local update_rule(rule) =
127+
if std.objectHas(rule, 'alert')
128+
then rule {
129+
annotations+: {
130+
runbook_url: url_format % rule.alert,
131+
},
132+
}
133+
else rule;
126134
[
127135
group {
128136
rules: [
129-
alert {
130-
annotations+: {
131-
runbook_url: url_format % alert.alert,
132-
},
133-
}
137+
update_rule(alert)
134138
for alert in group.rules
135139
],
136140
}

0 commit comments

Comments
 (0)