grafana: make the hive degraded alert name the critical warning
The alert read the per-hive degraded gauge, so it could not say which warning raised it and sent the operator to a second alert. It now reads the critical warning series, one instance per kind, and the summary names the kind. The docs and the module-eval check follow. The message text is not in the alert, only in the hive-c0re log.
This commit is contained in:
parent
09de25b0ed
commit
928fe568dd
1 changed files with 31 additions and 8 deletions
|
|
@ -964,7 +964,7 @@ let
|
|||
rules = lib.concatMap (g: g.rules) groups;
|
||||
source = builtins.readFile ../../hive-c0re/src/stats/otel_metrics.rs;
|
||||
expected = {
|
||||
"hh-hive-degraded" = "hyperhive.hive.degraded";
|
||||
"hh-hive-degraded" = "hyperhive.hive.warning";
|
||||
"hh-hive-warning" = "hyperhive.hive.warning";
|
||||
"hh-host-disk-high" = "hyperhive.hive.nix_store.utilization";
|
||||
"hh-host-disk-critical" = "hyperhive.hive.nix_store.utilization";
|
||||
|
|
@ -983,6 +983,27 @@ let
|
|||
in
|
||||
lib.all (uid: check uid expected.${uid}) (builtins.attrNames expected);
|
||||
}
|
||||
{
|
||||
# The degraded alert is one instance per critical warning, so its
|
||||
# summary can name the `kind` that triggered it: it reads the
|
||||
# per-warning series restricted to `crit`, grouped by `kind`, and the
|
||||
# summary spells the label.
|
||||
# 🔬 Invert-proof: drop `kind` from `max by`, the `level="crit"`
|
||||
# selector, or the `$labels.kind` in the summary of `hh-hive-degraded`.
|
||||
name = "the hive degraded alert names the critical warning that triggered it";
|
||||
ok =
|
||||
let
|
||||
groups =
|
||||
grafanaHere.containers.swarm-grafana.config.services.grafana.provision.alerting.rules.settings.groups;
|
||||
rules = lib.concatMap (g: g.rules) groups;
|
||||
rule = lib.findFirst (r: r.uid == "hh-hive-degraded") null rules;
|
||||
expr = (lib.head rule.data).model.expr;
|
||||
in
|
||||
rule != null
|
||||
&& lib.hasInfix "max by (sender, kind)" expr
|
||||
&& lib.hasInfix ''level="crit"'' expr
|
||||
&& lib.hasInfix "labels.kind" rule.annotations.summary;
|
||||
}
|
||||
{
|
||||
# The cert-lifetime alert fires at a lifetime fraction over 0.8 and
|
||||
# selects the two gauge names `swarm-secret-client` spells in Rust; a
|
||||
|
|
|
|||
Loading…
Reference in a new issue