Skip to content

Commit

Permalink
Not all Prometheus rules are alerts. (#490)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
tomwilkie authored Mar 11, 2021
1 parent 96b03e7 commit 113fa69
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mixin-utils/utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,18 @@ local g = import 'grafana-builder/grafana.libsonnet';
// - url_format: an URL format for the runbook, the alert name will be substituted in the URL.
// - groups: the list of rule groups containing alerts.
withRunbookURL(url_format, groups)::
local update_rule(rule) =
if std.objectHas(rule, 'alert')
then rule {
annotations+: {
runbook_url: url_format % rule.alert,
},
}
else rule;
[
group {
rules: [
alert {
annotations+: {
runbook_url: url_format % alert.alert,
},
}
update_rule(alert)
for alert in group.rules
],
}
Expand Down

0 comments on commit 113fa69

Please sign in to comment.