anomalydetector

package
v0.0.0-...-9afe088 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalQueryKey = "__**GlobalKeyQuery**__"
)

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(slice []string, contains string) bool

ContainsString checks if the slice has the contains value in it.

func PodByName

func PodByName(listOfPods []*kapiv1.Pod, exclusionFunc func(*kapiv1.Pod) (bool, error)) (allPods, excludeFromComparison map[string]*kapiv1.Pod, err error)

PodByName return 2 maps of pods all pods indexed by their names all pods to be excluded from comparison indexed by their names

Types

type AnomalyDetector

type AnomalyDetector interface {
	GetPodsOutOfBounds() ([]*kapiv1.Pod, error)
}

AnomalyDetector returns the list of pods that do not behave correctly according to the configuration

func New

New Factory for AnomalyDetection

type Config

type Config struct {
	Selector      labels.Selector
	PodLister     kv1.PodNamespaceLister
	Logger        logr.Logger
	ExclusionFunc func(*kapiv1.Pod) (bool, error)
}

Config generic part of the configuration for anomalyDetector

type ConfigPrometheusAnomalyDetector

type ConfigPrometheusAnomalyDetector struct {
	PrometheusService string
	PodNameKey        string
	AllPodsQuery      bool
	Query             string
	// contains filtered or unexported fields
}

ConfigPrometheusAnomalyDetector configuration to connect to prometheus

type ContinuousValueDeviationAnalyser

type ContinuousValueDeviationAnalyser struct {
	ConfigSpecific ContinuousValueDeviationConfig
	ConfigAnalyser Config
	// contains filtered or unexported fields
}

ContinuousValueDeviationAnalyser anomalyDetector that check the deviation of a continous value compare to average

func (*ContinuousValueDeviationAnalyser) GetPodsOutOfBounds

func (d *ContinuousValueDeviationAnalyser) GetPodsOutOfBounds() ([]*kapiv1.Pod, error)

GetPodsOutOfBounds implements interface AnomalyDetector

type ContinuousValueDeviationConfig

type ContinuousValueDeviationConfig struct {
	MaxDeviationPercent float64
}

ContinuousValueDeviationConfig Configuration for ContinuousValueDeviationAnalyser

type CustomAnomalyDetector

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

CustomAnomalyDetector call an external service to get the list of faulty pods

func (*CustomAnomalyDetector) GetPodsOutOfBounds

func (c *CustomAnomalyDetector) GetPodsOutOfBounds() ([]*kapiv1.Pod, error)

GetPodsOutOfBounds implements the anomaly detector interface

type DiscreteValueOutOfListAnalyser

type DiscreteValueOutOfListAnalyser struct {
	ConfigSpecific DiscreteValueOutOfListConfig
	ConfigAnalyser Config
	// contains filtered or unexported fields
}

DiscreteValueOutOfListAnalyser anomalyDetector that check the ratio of good/bad value and return the pods that exceed a given threshold for that ratio

func (*DiscreteValueOutOfListAnalyser) GetPodsOutOfBounds

func (d *DiscreteValueOutOfListAnalyser) GetPodsOutOfBounds() ([]*kapiv1.Pod, error)

GetPodsOutOfBounds implements interface AnomalyDetector

type DiscreteValueOutOfListConfig

type DiscreteValueOutOfListConfig struct {
	Key              string   // Key for the metrics. For the previous example it will be "code"
	GoodValues       []string // Good Values ["200","201"]. If empty means that BadValues should be used to do exclusion instead of inclusion.
	BadValues        []string // Bad Values ["500","404"].
	TolerancePercent uint
	// contains filtered or unexported fields
}

DiscreteValueOutOfListConfig configuration for DiscreteValueOutOfListAnalyser

type Factory

type Factory func(cfg FactoryConfig) (AnomalyDetector, error)

Factory functor for AnomalyDetection

func FakeFactory

func FakeFactory(p []*kapiv1.Pod, e error) Factory

FakeFactory create a fake anomaly detector factory that return a Fake anomaly detector

type FactoryConfig

type FactoryConfig struct {
	Config
	DiscreteValueOutOfListConfig   *DiscreteValueOutOfListConfig
	ContinuousValueDeviationConfig *ContinuousValueDeviationConfig
	ValueInRangeConfig             *ValueInRangeConfig
	PromConfig                     *ConfigPrometheusAnomalyDetector
	CustomService                  string
	// contains filtered or unexported fields
}

FactoryConfig parameters extended with factory features

type Fake

type Fake struct {
	Pods []*kapiv1.Pod
	Err  error
}

Fake should be used in test to mock an AnomalyDetector

func (*Fake) GetPodsOutOfBounds

func (f *Fake) GetPodsOutOfBounds() ([]*kapiv1.Pod, error)

GetPodsOutOfBounds implements AnomalyDetector

type ValueInRangeAnalyser

type ValueInRangeAnalyser struct {
	ConfigSpecific ValueInRangeConfig
	ConfigAnalyser Config
	// contains filtered or unexported fields
}

ValueInRangeAnalyser anomalyDetector that check the deviation of a continous value compare to average

func (*ValueInRangeAnalyser) GetPodsOutOfBounds

func (d *ValueInRangeAnalyser) GetPodsOutOfBounds() ([]*kapiv1.Pod, error)

GetPodsOutOfBounds implements interface AnomalyDetector

type ValueInRangeConfig

type ValueInRangeConfig struct {
	Min float64
	Max float64
}

ValueInRangeConfig Configuration for ValueInRangeAnalyser

Jump to

Keyboard shortcuts

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