quantrs2_device/performance_dashboard/
alerting.rs

1//! Alerting Configuration Types
2
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use std::time::Duration;
6
7/// Alerting configuration
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct AlertingConfig {
10    /// Enable alerting system
11    pub enable_alerting: bool,
12    /// Alert thresholds
13    pub alert_thresholds: HashMap<String, AlertThreshold>,
14    /// Notification channels
15    pub notification_channels: Vec<NotificationChannel>,
16    /// Alert escalation rules
17    pub escalation_rules: Vec<EscalationRule>,
18    /// Anomaly detection settings
19    pub anomaly_detection: AnomalyDetectionConfig,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct AlertThreshold {
24    pub metric_name: String,
25    pub threshold_value: f64,
26    pub comparison_operator: ComparisonOperator,
27    pub severity: AlertSeverity,
28    pub duration_threshold: Duration,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
32pub enum NotificationChannel {
33    Email,
34    Slack,
35    SMS,
36    Webhook,
37    PushNotification,
38    Dashboard,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct EscalationRule {
43    pub trigger_condition: String,
44    pub escalation_delay: Duration,
45    pub escalation_targets: Vec<String>,
46    pub escalation_severity: AlertSeverity,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct AnomalyDetectionConfig {
51    pub detection_algorithms: Vec<AnomalyDetectionAlgorithm>,
52    pub sensitivity: f64,
53    pub baseline_window: Duration,
54    pub detection_window: Duration,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
58pub enum ComparisonOperator {
59    GreaterThan,
60    LessThan,
61    Equal,
62    NotEqual,
63    GreaterThanOrEqual,
64    LessThanOrEqual,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
68pub enum AlertSeverity {
69    Low,
70    Medium,
71    High,
72    Critical,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
76pub enum AnomalyDetectionAlgorithm {
77    StatisticalOutlier,
78    MovingAverage,
79    ExponentialSmoothing,
80    IsolationForest,
81    LocalOutlierFactor,
82    MachineLearning,
83}