Browse Source

seasonality++

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
f7384b8526
  1. 16
      server/src/services/analytic_service/analytic_unit/anomaly_analytic_unit.rs

16
server/src/services/analytic_service/analytic_unit/anomaly_analytic_unit.rs

@ -60,7 +60,7 @@ impl AnalyticUnit for AnomalyAnalyticUnit {
from: u64, from: u64,
to: u64, to: u64,
) -> anyhow::Result<Vec<(u64, u64)>> { ) -> anyhow::Result<Vec<(u64, u64)>> {
let mr = ms.query(from, to, DETECTION_STEP).await.unwrap(); let mr = ms.query(from - self.config.seasonality, to, DETECTION_STEP).await.unwrap();
if mr.data.keys().len() == 0 { if mr.data.keys().len() == 0 {
return Ok(Vec::new()); return Ok(Vec::new());
@ -75,15 +75,17 @@ impl AnalyticUnit for AnomalyAnalyticUnit {
let mut result = Vec::new(); let mut result = Vec::new();
if let HSR::ConfidenceTimeSerie(hsr) = self.get_hsr_from_metric_result(&mr)? { let confidence_time_serie = self.get_hsr_from_metric_result(&mr)?;
if let HSR::ConfidenceTimeSerie(hsr) = confidence_time_serie {
let mut from = None; let mut from = None;
for ((t, _, (u, l)), (t1, rv)) in hsr.iter().zip(ts) { for ((t, _, (u, l)), (t1, rv)) in hsr.iter().zip(ts.iter()) {
if *t != t1 { if *t != *t1 {
return Err(anyhow::format_err!("incompatible hsr/ts")) return Err(anyhow::format_err!("incompatible hsr/ts"))
} }
if rv > *u || rv < *l { if rv > u || rv < l {
if from.is_none() { if from.is_none() {
from = Some(*t); from = Some(*t);
} }
@ -95,6 +97,10 @@ impl AnalyticUnit for AnomalyAnalyticUnit {
} }
} }
if from.is_some() {
result.push((from.unwrap(), ts.last().unwrap().0));
}
return Ok(result); return Ok(result);
} else { } else {

Loading…
Cancel
Save