feat(TASK-12): periodic telemetry reporter — 15min interval, collector POST

Background task spawned on server startup: every 15 minutes, checks opt-in
status, builds anonymous health report (node ID hash, version, uptime,
CPU/RAM/disk %, container states, recent alerts), saves to disk, and POSTs
to TELEMETRY_COLLECTOR_URL env var if configured. Non-fatal on failure.

Fixed FiredAlert field references (kind not rule_type, timestamp not
fired_at) in both monitoring and analytics modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-18 23:36:57 +00:00
parent b8afb10ec6
commit 41ab499698
3 changed files with 154 additions and 4 deletions

View File

@@ -172,13 +172,12 @@ impl RpcHandler {
.unwrap_or(0);
// Recent alerts from metrics store
let recent_alerts: Vec<serde_json::Value> = self.metrics_store.get_alerts().await
let recent_alerts: Vec<serde_json::Value> = self.metrics_store.get_fired_alerts(10).await
.into_iter()
.take(10)
.map(|a| serde_json::json!({
"rule": format!("{:?}", a.rule_type),
"rule": format!("{:?}", a.kind),
"message": a.message,
"fired_at": a.fired_at.to_rfc3339(),
"timestamp": a.timestamp,
}))
.collect();