Metric threshold rules for custom reports #34

Merged
Gilles merged 20 commits from feat/23-metric-thresholds into master 2026-10-28 22:53:30 +00:00
Owner

Closes #23

Part of the server monitoring plan (phase 2.2). Stacked on #33 (base feat/29-stale-trigger).

Changes

  • Trigger.METRIC_THRESHOLD ("Seuil sur une métrique", default severity warning). Params validated by the rule API: key (required), operator (>, >=, <, <=, default >=), warn and/or fail (at least one).
  • New apps.events.thresholds: metric lookup by key (falls back to the label), level computation, and apply().
  • process_report (custom reports only): matching enabled rules raise each metric's status, the report's status and summary.status to the worst of sender and rules — never lowered — before de-duplication and aggregation, so badges and aggregate status reflect it.
  • Event: fires when the computed level goes up (ok → warn, warn → fail, ok → fail), with a message like disk_pct = 85% >= 80%; dropping back re-arms it (state in EventRuleState.last_status).
  • README, feature catalog; tests in apps/events/test_thresholds.py.

Checks

pytest (219 passed), pylint 10/10, autopep8, bandit clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_014BSmBtGWeFBD9z4mYm9SjA

Closes #23 Part of the server monitoring plan (phase 2.2). **Stacked on #33** (base `feat/29-stale-trigger`). ## Changes - `Trigger.METRIC_THRESHOLD` ("Seuil sur une métrique", default severity warning). Params validated by the rule API: `key` (required), `operator` (`>`, `>=`, `<`, `<=`, default `>=`), `warn` and/or `fail` (at least one). - New `apps.events.thresholds`: metric lookup by `key` (falls back to the label), level computation, and `apply()`. - `process_report` (custom reports only): matching enabled rules raise each metric's `status`, the report's status and `summary.status` to the worst of sender and rules — never lowered — **before** de-duplication and aggregation, so badges and aggregate status reflect it. - Event: fires when the computed level goes up (ok → warn, warn → fail, ok → fail), with a message like `disk_pct = 85% >= 80%`; dropping back re-arms it (state in `EventRuleState.last_status`). - README, feature catalog; tests in `apps/events/test_thresholds.py`. ## Checks pytest (219 passed), pylint 10/10, autopep8, bandit clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BSmBtGWeFBD9z4mYm9SjA
feature: metric threshold rules for custom reports
All checks were successful
ci / test (pull_request) Successful in 3m13s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
e6dec8df33
- New report-level trigger metric_threshold: a metric found by its
  stable `key` (or label), an operator and warn and/or fail thresholds.
- Matching enabled rules are applied while a custom report is
  processed: the metric's and the report's status become the worst of
  the sender's and the rules' (never lowered), so badges and aggregates
  follow.
- The event fires when the computed level goes up (ok -> warn,
  warn -> fail, ok -> fail); going back down re-arms it.

Closes #23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BSmBtGWeFBD9z4mYm9SjA
Author
Owner
<!-- argus-link-bot:argus/backend --> 📊 [Rapports Argus pour cette PR](https://reports.stationmyr.net/argus/backend/pr/34)
Merge branch 'feat/29-stale-trigger' into feat/23-metric-thresholds
All checks were successful
ci / test (pull_request) Successful in 3m12s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
bdbd489a1f
Merge branch 'feat/29-stale-trigger' into feat/23-metric-thresholds
Some checks failed
ci / test (pull_request) Has been cancelled
ci / e2e (pull_request) Has been cancelled
ci / docker (pull_request) Has been cancelled
ci / deploy (pull_request) Has been cancelled
f6d211fa96
Merge branch 'feat/29-stale-trigger' into feat/23-metric-thresholds
All checks were successful
ci / test (pull_request) Successful in 3m9s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
1a0f2cafbe
Merge branch 'feat/29-stale-trigger' into feat/23-metric-thresholds
All checks were successful
ci / test (pull_request) Successful in 3m10s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
8f0862a70d
Gilles changed target branch from feat/29-stale-trigger to master 2026-10-28 22:46:09 +00:00
Merge remote-tracking branch 'origin/master' into feat/23-metric-thresholds
All checks were successful
ci / test (pull_request) Successful in 3m9s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
4c67cb0bee
# Conflicts:
#	README.md
#	apps/events/engine.py
#	apps/events/models.py
#	apps/events/serializers.py
#	e2e/features.catalog.yaml
Gilles scheduled this pull request to auto merge when all checks succeed 2026-10-28 22:47:19 +00:00
Gilles scheduled this pull request to auto merge when all checks succeed 2026-10-28 22:47:29 +00:00
Gilles merged commit a153f2a13b into master 2026-10-28 22:53:30 +00:00
Gilles deleted branch feat/23-metric-thresholds 2026-10-28 22:53:31 +00:00
Sign in to join this conversation.
No description provided.