Skip to content

Commit 3c07292

Browse files
authored
Merge pull request #269 from grafana/runbook-url
Add an util function to add runbook URL to all alerts in rule groups.
2 parents b9cc0f3 + c38092c commit 3c07292

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mixin-utils/utils.libsonnet

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,22 @@ local g = import 'grafana-builder/grafana.libsonnet';
118118
for matcher in std.filter(function(matcher) matcher.op != 'nop', selector)
119119
];
120120
'{%s}' % std.join(', ', pairs),
121+
122+
// withRunbookURL - Add/Override the runbook_url annotations for all alerts inside a list of rule groups.
123+
// - url_format: an URL format for the runbook, the alert name will be substituted in the URL.
124+
// - groups: the list of rule groups containing alerts.
125+
withRunbookURL(url_format, groups)::
126+
[
127+
group {
128+
rules: [
129+
alert {
130+
annotations+: {
131+
runbook_url: url_format % alert.alert,
132+
},
133+
}
134+
for alert in group.rules
135+
],
136+
}
137+
for group in groups
138+
],
121139
}

0 commit comments

Comments
 (0)