libomni/types/db/v1/
alert.rs1use serde::{Deserialize, Serialize};
2use chrono::{DateTime, Utc};
3
4#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
6pub struct Alert {
7 pub id: i64,
8 pub alert_type: String,
9 pub severity: String,
10 pub service: String,
11 pub message: String,
12 pub timestamp: DateTime<Utc>,
13 pub status: String,
14 pub resolved_at: Option<DateTime<Utc>>,
15 pub resolved_by: Option<i64>,
16 pub metadata: Option<serde_json::Value>,
17 pub org_id: Option<i64>,
18 pub app_id: Option<i64>,
19 pub instance_id: Option<i64>,
20 pub region_id: Option<i64>,
21 pub node_id: Option<i64>,
22}
23
24#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
26pub struct AlertAcknowledgment {
27 pub id: i64,
28 pub alert_id: i64,
29 pub user_id: i64,
30 pub acknowledged_at: DateTime<Utc>,
31 pub notes: Option<String>,
32}
33
34#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
36pub struct AlertEscalation {
37 pub id: i64,
38 pub alert_id: i64,
39 pub escalation_level: i64,
40 pub escalated_at: DateTime<Utc>,
41 pub escalated_to: serde_json::Value,
42 pub escalation_method: String,
43 pub response_required_by: Option<DateTime<Utc>>,
44}
45
46#[derive(Debug, Serialize, Deserialize)]
49pub struct AlertWithRelatedData {
50 pub alert: Alert,
52 pub acknowledgments: Vec<AlertAcknowledgment>,
54 pub escalations: Vec<AlertEscalation>,
56 pub history: Vec<AlertHistory>
58}
59
60#[derive(Debug, Serialize, Deserialize)]
63pub struct AlertWithAcknowledgments {
64 pub alert: Alert,
66 pub acknowledgments: Vec<AlertAcknowledgment>,
68 pub is_acknowledged: bool,
70 pub acknowledgment_count: i64,
72 pub latest_acknowledgment: Option<chrono::DateTime<chrono::Utc>>,
74}
75
76#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
78pub struct AlertHistory {
79 pub id: i64,
80 pub alert_id: i64,
81 pub action: String,
82 pub performed_by: Option<i64>,
83 pub performed_at: DateTime<Utc>,
84 pub previous_state: Option<serde_json::Value>,
85 pub new_state: Option<serde_json::Value>,
86 pub notes: Option<String>,
87}