This repository has been archived on 2023-04-02. You can view files and clone it, but cannot push or open issues or pull requests.
gitops-tbrnt/monitoring/vendor/kubernetes-mixin/alerts/add-runbook-links.libsonnet

24 lines
681 B
Plaintext

local utils = import '../lib/utils.libsonnet';
local lower(x) =
local cp(c) = std.codepoint(c);
local lowerLetter(c) =
if cp(c) >= 65 && cp(c) < 91
then std.char(cp(c) + 32)
else c;
std.join('', std.map(lowerLetter, std.stringChars(x)));
{
_config+:: {
runbookURLPattern: 'https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-%s',
},
prometheusAlerts+::
local addRunbookURL(rule) = rule {
[if 'alert' in rule && !('runbook_url' in rule.annotations) then 'annotations']+: {
runbook_url: $._config.runbookURLPattern % lower(rule.alert),
},
};
utils.mapRuleGroups(addRunbookURL),
}