github.com/thanos-io/thanos@v0.32.5/mixin/alerts/add-runbook-links.libsonnet (about) 1 local utils = import '../lib/utils.libsonnet'; 2 3 local lower(x) = 4 local cp(c) = std.codepoint(c); 5 local lowerLetter(c) = 6 if cp(c) >= 65 && cp(c) < 91 7 then std.char(cp(c) + 32) 8 else c; 9 std.join('', std.map(lowerLetter, std.stringChars(x))); 10 11 { 12 _config+:: { 13 runbookURLPattern: 'https://github.com/thanos-io/thanos/tree/main/mixin/runbook.md#alert-name-%s', 14 }, 15 16 prometheusAlerts+:: 17 local addRunbookURL(rule) = rule { 18 [if 'alert' in rule && !('runbook_url' in rule.annotations) then 'annotations']+: { 19 runbook_url: $._config.runbookURLPattern % lower(rule.alert), 20 }, 21 }; 22 utils.mapRuleGroups(addRunbookURL), 23 }