Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixin: add extra alert options #7442

2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/alertmanager.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
19 changes: 19 additions & 0 deletions operations/mimir-mixin/alerts/alerts-utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,23 @@
}
for group in groups
],

withExtraLabelsAnnotations(groups)::
local update_rule(rule) =
if std.objectHas(rule, 'alert')
then rule {
annotations+: $._config.alert_extra_annotations,
labels+: $._config.alert_extra_labels,
}
else rule;
[
group {
rules: [
update_rule(rule)
for rule in group.rules
],
}
for group in groups
],

}
2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -803,5 +803,5 @@ local utils = import 'mixin-utils/utils.libsonnet';
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/autoscaling.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/blocks.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,5 @@
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/compactor.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
2 changes: 1 addition & 1 deletion operations/mimir-mixin/alerts/continuous-test.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
},
],

groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', alertGroups),
groups+: $.withRunbookURL('https://grafana.com/docs/mimir/latest/operators-guide/mimir-runbooks/#%s', $.withExtraLabelsAnnotations(alertGroups)),
}
6 changes: 6 additions & 0 deletions operations/mimir-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
namespace_query: 'cortex_build_info{%s=~"$cluster"}' % $._config.per_cluster_label,
},

// Used to add extra labels to all alerts. Careful: takes precedence over default labels.
alert_extra_labels: {},

// Used to add extra annotations to all alerts, Careful: takes precedence over default annotations.
alert_extra_annotations: {},

cortex_p99_latency_threshold_seconds: 2.5,

// Whether resources dashboards are enabled (based on cAdvisor metrics).
Expand Down
Loading