detection

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2021 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MinData = 11

MinData is the minimum length of data for AnomalyDetector to work

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	// Name show detector name
	Name() string
	// Add add detect data
	Add(data TimedData)
	// AddAll add detect data array
	AddAll(vals []TimedData)
	// IsAnomaly checks if current values is anomaly
	IsAnomaly() (bool, error)
	// Metrics return current detector metrics
	Metrics() []string
	// SampleCount get current data count
	SampleCount() int
	// SampleDuration get current data time range
	SampleDuration() time.Duration
	// Reason get anomaly reason
	Reason() string
}

Detector defines detector methods

func NewUnionDetector

func NewUnionDetector(detectors []Detector) Detector

NewUnionDetector union multiple detectors

type EwmaDetector

type EwmaDetector struct {
	// contains filtered or unexported fields
}

EwmaDetector using ewma alg to detect anomaly values

func NewEwmaDetector

func NewEwmaDetector(metric string, n int) *EwmaDetector

NewEwmaDetector returns a AnomalyDetector which keeps n data. Note: please initialize the detector with at lease 10 data using Add() method. It is required by the EWMA library to be "ready" for producing value. AnomalyDetector is not thread safe

func (*EwmaDetector) Add

func (e *EwmaDetector) Add(data TimedData)

Add add detect data

func (*EwmaDetector) AddAll

func (e *EwmaDetector) AddAll(vals []TimedData)

AddAll add detect data array

func (*EwmaDetector) IsAnomaly

func (e *EwmaDetector) IsAnomaly() (bool, error)

IsAnomaly checks if current values is anomaly

func (*EwmaDetector) Mean

func (e *EwmaDetector) Mean() float64

Mean returns the mean value

func (*EwmaDetector) Metrics

func (e *EwmaDetector) Metrics() []string

Metrics return current detector metrics

func (*EwmaDetector) Name

func (e *EwmaDetector) Name() string

Name show detector name

func (*EwmaDetector) Reason

func (e *EwmaDetector) Reason() string

Reason get anomaly reason

func (*EwmaDetector) SampleCount

func (e *EwmaDetector) SampleCount() int

SampleCount get current data count

func (*EwmaDetector) SampleDuration

func (e *EwmaDetector) SampleDuration() time.Duration

SampleDuration get current data time range

func (*EwmaDetector) StdDev

func (e *EwmaDetector) StdDev() float64

StdDev returns the standard deviation

type ExpressionDetector

type ExpressionDetector struct {
	// contains filtered or unexported fields
}

ExpressionDetector using expressions to detect anomaly metrics

func NewExpressionDetector

func NewExpressionDetector(metrics []string, exp *govaluate.EvaluableExpression,
	options ...ExpressionOption) *ExpressionDetector

NewExpressionDetector new an expression detector

func (*ExpressionDetector) Add

func (e *ExpressionDetector) Add(data TimedData)

Add add detect data

func (*ExpressionDetector) AddAll

func (e *ExpressionDetector) AddAll(vals []TimedData)

AddAll add detect data array

func (*ExpressionDetector) IsAnomaly

func (e *ExpressionDetector) IsAnomaly() (bool, error)

IsAnomaly checks if current values is anomaly

func (*ExpressionDetector) Metrics

func (e *ExpressionDetector) Metrics() []string

Metrics return current detector metrics

func (*ExpressionDetector) Name

func (e *ExpressionDetector) Name() string

Name show detector name

func (*ExpressionDetector) Reason

func (e *ExpressionDetector) Reason() string

Reason get anomaly reason

func (*ExpressionDetector) SampleCount

func (e *ExpressionDetector) SampleCount() int

SampleCount get current data count

func (*ExpressionDetector) SampleDuration

func (e *ExpressionDetector) SampleDuration() time.Duration

SampleDuration get current data time range

type ExpressionOption

type ExpressionOption func(*ExpressionDetector) error

func ExpressionWarningArgs

func ExpressionWarningArgs(args *types.ExpressionArgs) ExpressionOption

ExpressionWarningArgs is used to set some expression args

type TimedData

type TimedData struct {
	Ts   time.Time
	Vals map[string]float64
}

TimedData is the data struct used by detector

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL