fix: harden MonitorService evaluation loop (#942)

- Change network metrics (net_rx/net_tx) from cumulative totals to MB/s rates
  so alert thresholds are operationally meaningful
- Wrap all external calls (Docker stats, systeminformation, docker df) in
  10-second timeout via Promise.race to prevent hung operations from
  blocking the evaluation loop indefinitely
- Parallelize host CPU/RAM/disk queries with Promise.all to bound worst-case
  latency at 10 seconds instead of 30
- Use epsilon comparison for == operator so floating-point metric values
  can match integer thresholds
- Clean up stale entries in activeBreaches and previousNetworkStats maps
  after rules are deleted or containers stop
- Add standard INFO logging for alert firings and WARN logging for slow
  cycles and timeouts; add diagnostic cycle timing and breach-count log
This commit is contained in:
Anso
2026-05-06 13:28:07 -04:00
committed by GitHub
parent b2d786d5e0
commit 13cb49ce3a
2 changed files with 101 additions and 17 deletions
+2 -2
View File
@@ -54,8 +54,8 @@ const metricOptions = [
{ value: 'cpu_percent', label: 'CPU Usage (%)' },
{ value: 'memory_percent', label: 'Memory Usage (%)' },
{ value: 'memory_mb', label: 'Memory Usage (MB)' },
{ value: 'net_rx', label: 'Network In (MB)' },
{ value: 'net_tx', label: 'Network Out (MB)' },
{ value: 'net_rx', label: 'Network In (MB/s)' },
{ value: 'net_tx', label: 'Network Out (MB/s)' },
{ value: 'restart_count', label: 'Restart Count' },
];