fixes
This commit is contained in:
1 parent
f30adf05af
commit
8824af8699
29 files changed
+1201
-115
No files matched your search
@@ -15,6 +15,12 @@ type SpikeConfig struct {
|
||||
Multiple float64 // a pattern must be novel or >= Multiple * its own baseline mean
|
||||
MinExcess int // and excess errors must be >= MinExcess
|
||||
TopPatterns int
|
||||
// DataSince is when data collection began (earliest row of any kind). When
|
||||
// set, no alert fires until WarmupWindows windows of baseline exist,
|
||||
// otherwise the first window after data begins reports everything as NEW.
|
||||
// Zero disables the guard.
|
||||
DataSince time.Time
|
||||
WarmupWindows int
|
||||
}
|
||||
|
||||
func DefaultSpikeConfig() SpikeConfig {
|
||||
@@ -64,6 +70,15 @@ func DetectSpikes(events []Event, at time.Time, cfg SpikeConfig) []Spike {
|
||||
at = at.UTC()
|
||||
start := at.Add(-cfg.Window)
|
||||
baseStart := start.Add(-time.Duration(cfg.BaselineWindows) * cfg.Window)
|
||||
if !cfg.DataSince.IsZero() {
|
||||
warm := cfg.WarmupWindows
|
||||
if warm <= 0 {
|
||||
warm = min(cfg.BaselineWindows, 6)
|
||||
}
|
||||
if start.Sub(cfg.DataSince.UTC()) < time.Duration(warm)*cfg.Window {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
type agg struct {
|
||||
cur int
|
||||
|
||||
Reference in new issue
Block a user