test(alerts): fix the silent-finding time and keep cpu_pct first in the host_agent catalog (#5062)
CI / lint (push) Successful in 3s
CI / integration (push) Successful in 55s
CI / unit (push) Successful in 1m13s
CI / publish (push) Successful in 1m25s

CI 8325: NOW - 10 min is 11:50, not 09:50; and rule_fields' refusal lists
the catalog in order, so seconds_since_seen goes last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 13:23:18 -04:00
co-authored by Claude Opus 5.5
parent c368e93e2c
commit b009a8dd30
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ def get_alert_metrics() -> dict[str, list[str]]:
disk_used_pct per mount, resource "<host>:<mount>"). seconds_since_seen
comes from the scheduler, not the agent: "agent offline" is > 180."""
return {"host_agent": [
"seconds_since_seen", "cpu_pct", "mem_used_pct", "mem_available_bytes", "swap_used_bytes",
"cpu_pct", "mem_used_pct", "mem_available_bytes", "swap_used_bytes",
"disk_used_pct_worst", "disk_used_pct", "load_1m", "load_5m", "load_15m",
"uptime_secs",
"uptime_secs", "seconds_since_seen",
]}
+2 -2
View File
@@ -161,10 +161,10 @@ def test_alert_findings_say_when_a_metric_went_silent():
no_data_since=silent), rule),
])
assert (quiet["kind"], quiet["severity"]) == ("alert_no_data", "warning")
assert quiet["since"] == "2026-10-06T09:50:00Z" and "stopped reporting" in quiet["summary"]
assert quiet["since"] == "2026-10-06T11:50:00Z" and "stopped reporting" in quiet["summary"]
# A firing alert that goes silent stays a firing finding, marked.
assert (firing["kind"], firing["severity"]) == ("alert_firing", "critical")
assert "no data since 2026-10-06T09:50:00Z" in firing["summary"]
assert "no data since 2026-10-06T11:50:00Z" in firing["summary"]
THRESHOLDS = {"cpu": {"warn": 80, "crit": 90}, "mem": {"warn": 80, "crit": 90},