Menu
Public repository / master
AkurAI-Monitor / src/models.rs
Latest change 0f9f642e4702d9b174c075dc1d32cd5bb60a63c4 - style: cargo fmt (AKURAI-MONITOR-8) by Ólafur Búi Ólafsson
use serde::Serialize;
/// A component-level degradation with drill-down evidence.
#[derive(Debug, Serialize)]
pub struct DegradedState {
pub component: String,
pub description: String,
/// Row IDs that back this degradation (metric ids, alert_event ids, etc.).
pub evidence_ids: Vec<i64>,
}
/// Version freshness across tenant-scoped applications.
#[derive(Debug, Serialize)]
pub struct VersionFreshness {
pub status: String, // "current" | "outdated" | "unknown"
pub app_count: i64,
pub outdated_count: i64,
pub evidence_ids: Vec<i64>,
}
/// Recency of tenant-scoped telemetry without exposing its host or application.
#[derive(Debug, Serialize)]
pub struct SourceFreshness {
/// "fresh", "stale", or "unknown".
pub status: String,
pub last_observed_at: Option<i64>,
pub age_seconds: Option<i64>,
/// Latest metric row backing the freshness result, when one exists.
pub evidence_ids: Vec<i64>,
}
/// Tenant-scoped health aggregate returned by GET /api/health/:org_id/:workspace_id.
///
/// Every value scoped strictly to the given tenant; missing data renders as
/// `None` / `"unknown"` — never as a misleading zero.
#[derive(Debug, Serialize)]
pub struct HealthSummary {
pub org_id: String,
pub workspace_id: String,
/// Overall status: "healthy", "degraded", or "unknown".
pub status: String,
/// Fraction of up-samples in the window, or None if the "up" metric is absent.
pub availability_pct: Option<f64>,
/// Age of the most recent backup in seconds, or None if no backup metric exists.
pub last_backup_age_seconds: Option<i64>,
pub source_freshness: SourceFreshness,
pub version_freshness: VersionFreshness,
/// Count of alert_events for this tenant that have not been resolved.
pub unresolved_critical_incidents: i64,
/// One entry per degraded component; empty when status is "healthy".
pub degraded_states: Vec<DegradedState>,
/// Total metric samples in the window (any name).
pub sample_count: i64,
pub window_seconds: i64,
pub computed_at: i64,
}