feat: Implement Phase 2 alerting system with anomaly detection
All checks were successful
Test Asgard Runner / test (push) Successful in 2s

Proactive monitoring infrastructure for server health:

**Alert Service:**
- Population drop detection (configurable % threshold)
- FPS degradation monitoring (configurable FPS threshold)
- Multi-channel notifications (Discord, Pushbullet, Email)
- Spam prevention (30-min duplicate suppression)
- Severity levels (Info, Warning, Critical)

**Database:**
- alert_config table (thresholds per license)
- alert_history table (event log with metadata)
- 90-day retention with cleanup job

**Integration:**
- Discord/Pushbullet service integration
- Notification config retrieval from public_site_config
- Ready for stats pipeline integration

Purpose: Server admins get alerted when anomalies occur
(population crashes, performance degradation). Configurable
thresholds enable proactive server management.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell
2026-02-15 14:28:51 -05:00
parent 8790072609
commit 3e8b29f2ee
7 changed files with 606 additions and 9 deletions

View File

@@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added (Phase 2 — Alerting System)
**Backend:**
- Migration 008: Alert configuration and history tables
- `alert_config` table with threshold settings per license (population drop %, FPS threshold)
- `alert_history` table logging all triggered alerts with metadata
- Default alert config created for all existing licenses
- Alert service (`services/alerting.rs`):
- `check_population_anomaly()` — Detects player count drops exceeding threshold
- `check_fps_degradation()` — Monitors server performance degradation
- Spam prevention (30-minute duplicate suppression)
- Multi-channel notifications (Discord + Pushbullet + Email)
- Severity levels: Info, Warning, Critical
- Alert database layer (`db/alerts.rs`):
- `get_alert_config()` / `update_alert_config()` — Threshold configuration
- `insert_alert()` / `mark_alert_notified()` — Alert history tracking
- `check_recent_alert()` — Duplicate detection
- `cleanup_old_alerts()` — 90-day retention cleanup
- Updated `db/notifications.rs` — Notification config retrieval with webhook/API key support
**Alert Types:**
- Population Drop — Triggers when player count drops >X% in 1 hour
- FPS Degradation — Triggers when FPS falls below configurable threshold
- Server Crash — Critical alert for auto-recovery failures
- Wipe Failed — Alert when wipe execution fails
**Purpose:** Proactive monitoring for server health issues. Alerts server admins via Discord/Pushbullet when anomalies detected (population crashes, performance degradation). Configurable thresholds per license.
### Added (Phase 2 — Wipe Performance Analytics)
**Backend:**