Files
gilles f0a071e83a feat(backend): historique, SSE et Prometheus — Phase 6
- Migration 002 : table metrics_history (index agent_id/timestamp)
- AppState : broadcast channels (metrics_tx, network_tx) + FromRef<SqlitePool>
- GET /api/v1/history/{agent_id}?hours=N : série temporelle, rétention 7 jours
- POST /api/v1/metrics : écrit dans history + broadcast SSE
- GET /api/v1/stream : Server-Sent Events (events metrics + network)
- GET /metrics : endpoint Prometheus text/plain (CPU, RAM, disque, temp, réseau)
- Bump version API 0.2.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 06:30:34 +02:00

16 lines
529 B
SQL

-- Historique des métriques (série temporelle)
-- Alimenté à chaque push agent, rétention 7 jours (purge automatique)
CREATE TABLE IF NOT EXISTS metrics_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
agent_id TEXT NOT NULL,
timestamp TEXT NOT NULL,
cpu_percent REAL,
ram_percent REAL,
disk_percent REAL,
temperature_c REAL,
net_rx_bps INTEGER,
net_tx_bps INTEGER
);
CREATE INDEX IF NOT EXISTS idx_mh_agent_ts ON metrics_history(agent_id, timestamp DESC);