module-eval: grafana and swarm-otel cases follow the sender stamp
This commit is contained in:
parent
2306b60473
commit
c529bab9ea
1 changed files with 70 additions and 16 deletions
|
|
@ -663,10 +663,10 @@ let
|
|||
) tables;
|
||||
}
|
||||
{
|
||||
# The host board ships, and every query filters on both template
|
||||
# variables: a panel missing one shows another hive's or host's numbers
|
||||
# under this selection.
|
||||
name = "the host dashboard ships, and every panel query filters on hive and host";
|
||||
# The host board ships, and every query filters on the host template
|
||||
# variable: a panel missing it shows another host's numbers
|
||||
# under this selection. No `hive` label exists to filter on.
|
||||
name = "the host dashboard ships, and every panel query filters on host";
|
||||
ok =
|
||||
let
|
||||
provider = lib.head grafanaWithAuthelia.containers.swarm-grafana.config.services.grafana.provision.dashboards.settings.providers;
|
||||
|
|
@ -676,9 +676,55 @@ let
|
|||
in
|
||||
lib.elem "host.json" shipped
|
||||
&& lib.length exprs > 0
|
||||
&& lib.all (e: lib.hasInfix "hive=~\"$hive\"" e && lib.hasInfix "\"host.name\"=~\"$host\"" e) exprs
|
||||
&& lib.all (e: !(lib.hasInfix "hive=~" e) && lib.hasInfix "\"host.name\"=~\"$host\"" e) exprs
|
||||
&& lib.any (e: lib.hasInfix "system.cpu.time" e) exprs;
|
||||
}
|
||||
{
|
||||
# Each hive's collector gets its own absence rule, keyed on the client id
|
||||
# the swarm collector stamps as `sender`, so a hive that sends nothing
|
||||
# still has an instance to fire. The roster is read from the fixture, and
|
||||
# the length clause keeps the `all` from holding over an empty one.
|
||||
# 🔬 Invert-proof: key the rule on `hive`, or drop the client prefix.
|
||||
name = "each hive's log-absence rule keys on the sender the swarm collector stamps";
|
||||
ok =
|
||||
let
|
||||
h = grafanaHere.services.hyperhive;
|
||||
groups =
|
||||
grafanaHere.containers.swarm-grafana.config.services.grafana.provision.alerting.rules.settings.groups;
|
||||
rules = lib.concatMap (g: g.rules) groups;
|
||||
expr =
|
||||
uid:
|
||||
(lib.head (lib.findFirst (r: r.uid == uid) { data = [ { model.expr = ""; } ]; } rules).data)
|
||||
.model.expr;
|
||||
hives = lib.attrNames h.swarm.hives;
|
||||
in
|
||||
lib.length hives > 0
|
||||
&& lib.all (
|
||||
n: lib.hasInfix ''sender:="${h.swarm.authelia.hiveClientPrefix}${n}"'' (expr "hh-logs-absent-${n}")
|
||||
) hives
|
||||
&& !(lib.any (n: lib.hasInfix "hive:" (expr "hh-logs-absent-${n}")) hives);
|
||||
}
|
||||
{
|
||||
# `hive` is no label of any stored series, so a dashboard that selects or
|
||||
# groups by it shows nothing. The agents board is the presence control:
|
||||
# it filters on `agent`, so a misspelt path cannot pass the absence arm.
|
||||
name = "no shipped dashboard selects or groups by a hive label";
|
||||
ok =
|
||||
let
|
||||
dir = ../host-modules/swarm-grafana/dashboards;
|
||||
names = lib.attrNames (
|
||||
lib.filterAttrs (n: t: t == "regular" && lib.hasSuffix ".json" n) (builtins.readDir dir)
|
||||
);
|
||||
text = n: builtins.readFile (dir + "/${n}");
|
||||
# Not `lib.hasInfix`: it is a regex match, which overflows the stack on a whole board.
|
||||
has = needle: s: builtins.replaceStrings [ needle ] [ "" ] s != s;
|
||||
in
|
||||
lib.length names > 20
|
||||
&& has "agent=~\\\"$agent\\\"" (text "agents.json")
|
||||
&& lib.all (
|
||||
n: !(has "hive=~" (text n)) && !(has "by (hive" (text n)) && !(has ", hive)" (text n))
|
||||
) names;
|
||||
}
|
||||
{
|
||||
# The egress board ships, and its queries read the two squid log lines as
|
||||
# squid writes them: the would_deny line's field layout, and the default
|
||||
|
|
@ -860,7 +906,7 @@ let
|
|||
rule != null
|
||||
&& lib.hasInfix ''_SYSTEMD_UNIT:="hive-agent.service"'' expr
|
||||
&& lib.hasInfix ''_msg:="turn failed"'' expr
|
||||
&& lib.hasInfix "stats by (hive, agent)" expr;
|
||||
&& lib.hasInfix "stats by (agent)" expr;
|
||||
}
|
||||
{
|
||||
# A classifier run without a verdict is visible only as these log
|
||||
|
|
@ -994,14 +1040,14 @@ let
|
|||
&& lib.hasInfix "max by (account, window)" expr;
|
||||
}
|
||||
{
|
||||
# The needs-login alert is one instance per (hive, agent), fires after
|
||||
# The needs-login alert is one instance per agent, fires after
|
||||
# 5 minutes on the gauge hive-c0re exports, and `hh-hive-warning` drops
|
||||
# `pending_logins` only for hives that export the gauge, so a login never
|
||||
# pages twice and a hive on an older hive-c0re still pages. The disk rule is
|
||||
# the presence control: it goes through the same lookup.
|
||||
# 🔬 Invert-proof: change `for`, `max by (hive, agent)` or the metric on
|
||||
# 🔬 Invert-proof: change `for`, `max by (agent)` or the metric on
|
||||
# `hh-agent-needs-login`, exclude `pending_logins` from `hh-hive-warning` for every hive
|
||||
# instead of per hive (drop the `unless on (hive)` clause), or rename the gauge in `otel_metrics.rs`.
|
||||
# instead of per hive (drop the `unless on (sender)` clause), or rename the gauge in `otel_metrics.rs`.
|
||||
name = "the needs-login alert is per agent, fires after 5 minutes and the hive warning rule skips pending_logins only for hives with the gauge";
|
||||
ok =
|
||||
let
|
||||
|
|
@ -1018,19 +1064,19 @@ let
|
|||
&& rule "hh-host-disk-high" != null
|
||||
&& lib.hasInfix ''{__name__="hyperhive.agent.needs_login"}'' (expr "hh-agent-needs-login")
|
||||
&& lib.hasInfix ''"hyperhive.agent.needs_login"'' source
|
||||
&& lib.hasInfix "max by (hive, agent)" (expr "hh-agent-needs-login")
|
||||
&& lib.hasInfix ''{__name__="hyperhive.hive.warning", kind="pending_logins"} unless on (hive) group by (hive) ({__name__="hyperhive.agent.needs_login"})'' (
|
||||
&& lib.hasInfix "max by (agent)" (expr "hh-agent-needs-login")
|
||||
&& lib.hasInfix ''{__name__="hyperhive.hive.warning", kind="pending_logins"} unless on (sender) group by (sender) ({__name__="hyperhive.agent.needs_login"})'' (
|
||||
expr "hh-hive-warning"
|
||||
)
|
||||
&& lib.hasInfix "disk_pressure" (expr "hh-hive-warning");
|
||||
}
|
||||
{
|
||||
# The OOM-kill alert is one instance per (hive, agent), fires over three
|
||||
# The OOM-kill alert is one instance per agent, fires over three
|
||||
# kills in the last hour with no `for`, and selects the counter name
|
||||
# `otel_metrics.rs` spells in Rust. The needs-login rule is the presence
|
||||
# control: it goes through the same lookup, so a misspelled attribute path
|
||||
# fails both arms.
|
||||
# 🔬 Invert-proof: change `threshold = 3`, `for`, `[1h]` or `sum by (hive, agent)`
|
||||
# 🔬 Invert-proof: change `threshold = 3`, `for`, `[1h]` or `sum by (agent)`
|
||||
# on `hh-agent-oom-kills`, or rename the counter in `otel_metrics.rs`.
|
||||
name = "the OOM-kill alert fires over three kills an hour per agent on the counter hive-c0re exports";
|
||||
ok =
|
||||
|
|
@ -1051,7 +1097,7 @@ let
|
|||
&& lib.hasInfix ''{__name__="hyperhive.container.memory.oom_kills"'' (query "hh-agent-oom-kills")
|
||||
.model.expr
|
||||
&& lib.hasInfix "[1h]" (query "hh-agent-oom-kills").model.expr
|
||||
&& lib.hasInfix "sum by (hive, agent)" (query "hh-agent-oom-kills").model.expr
|
||||
&& lib.hasInfix "sum by (agent)" (query "hh-agent-oom-kills").model.expr
|
||||
&& lib.hasInfix ''"hyperhive.container.memory.oom_kills"'' source
|
||||
&& (query "hh-agent-oom-kills").model.instant
|
||||
&& lib.hasInfix "{{ $labels.agent }}" oom.annotations.summary;
|
||||
|
|
|
|||
Loading…
Reference in a new issue