pub struct AnomalyDetector { /* private fields */ }Expand description
Anomaly detection engine
Implementations§
Source§impl AnomalyDetector
impl AnomalyDetector
Sourcepub fn with_params(
z_score_threshold: f64,
iqr_multiplier: f64,
moving_avg_window: usize,
smoothing_alpha: f64,
) -> Self
pub fn with_params( z_score_threshold: f64, iqr_multiplier: f64, moving_avg_window: usize, smoothing_alpha: f64, ) -> Self
Create with custom parameters
Sourcepub fn track_metric(&mut self, name: &str, value: f64, timestamp: DateTime<Utc>)
pub fn track_metric(&mut self, name: &str, value: f64, timestamp: DateTime<Utc>)
Track metric value
Sourcepub fn detect(
&self,
metric_name: &str,
current_value: f64,
method: DetectionMethod,
) -> Option<AnomalyResult>
pub fn detect( &self, metric_name: &str, current_value: f64, method: DetectionMethod, ) -> Option<AnomalyResult>
Detect anomaly using specified method
Sourcepub fn analyze_log(&mut self, log: &LogEntry) -> Vec<ThreatAlert>
pub fn analyze_log(&mut self, log: &LogEntry) -> Vec<ThreatAlert>
Analyze log for metric anomalies
Sourcepub fn get_metric(&self, name: &str) -> Option<&TimeSeries>
pub fn get_metric(&self, name: &str) -> Option<&TimeSeries>
Get metric statistics
Sourcepub fn get_all_metrics(&self) -> Vec<&str>
pub fn get_all_metrics(&self) -> Vec<&str>
Get all tracked metrics
Sourcepub fn clear_old_data(&mut self, before: DateTime<Utc>)
pub fn clear_old_data(&mut self, before: DateTime<Utc>)
Clear old data from metrics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnomalyDetector
impl RefUnwindSafe for AnomalyDetector
impl Send for AnomalyDetector
impl Sync for AnomalyDetector
impl Unpin for AnomalyDetector
impl UnwindSafe for AnomalyDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more