feature: threshold rules with hysteresis and sustained breach #56
No reviewers
Labels
No labels
breaking
bug
ci
dependencies
documentation
feature
security
skip-changelog
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
argus/backend!56
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/threshold-hysteresis"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #54
garion's
swap_pct(rule>= 95) sits at 90-100 % every night: host-health flipped ok/warn 9 times between 2026-10-29 and 10-31, several of them single-report (1 h) warn episodes.Two optional params on
metric_thresholdrules, both unset by default -- existing rules behave exactly as before and store nothing:recover: hysteresis. Once warn/fail is confirmed, back to ok only when the value no longer passesrecover(warn >= 95, recover 85 → still warn at 90).for_count(1-100): the level is only raised after N consecutive reports at least that high; dropping stays immediate. While unconfirmed, the metric carriespending: {status, count, of}.How:
thresholds.sustained_level()reads the rule's state from the stream's previous report (summary["thresholds"][rule id]: level + streaks capped at N, so a steady breach keeps an identical summary and the source de-dup still applies)._on_metric_thresholdreuses the stored level instead of recomputing the raw one, so events and status agree._previous_in_stream()is now shared with the de-dup check.Replaying garion's real values (2026-10-30 22:00 → 10-31 07:20): with
for_count: 2, the isolated 23:09 warn disappears and 03:13-06:18 becomes a single warn episode confirmed at 04:15 (back to ok at 07:20).recover: 85is not a fit for swap: it sits at 93-94 % between peaks, so it would hold warn the whole night -- recover is for metrics with a real gap between their normal and breach values.Tests:
apps/events/test_sustained_thresholds.py+ param validation; full suite, pylint 10/10, autopep8 clean locally. Frontend form: argus/frontend#46.🤖 Generated with Claude Code
https://claude.ai/code/session_01AUcAVt7dKqdZsFwQdwZkxW
📊 Rapports Argus pour cette PR