judge

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// config
	JudgeConfig JudgeSection
	Ident       string

	// 连接池 node_address -> connection_pool
	JudgeConnPools *pools.ConnPools

	// queue
	JudgeQueues = cache.SafeJudgeQueue{}

	DefaultSendTaskSleepInterval = time.Millisecond * 50 //默认睡眠间隔为50ms
	DefaultSendQueueMaxSize      = 102400
	MaxSendRetry                 = 10
)
View Source
var (
	EVENT_ALERT   = "alert"
	EVENT_RECOVER = "recovery"
)

Functions

func AsyncJudge

func AsyncJudge(sema *semaphore.Semaphore, stra *models.Stra, exps []models.Exp, firstItem *dataobj.JudgeItem, now int64)

func GetData

func GetData(stra *models.Stra, exp models.Exp, firstItem *dataobj.JudgeItem, now int64) ([]*dataobj.TsdbQueryResponse, error)

func GetJudges

func GetJudges() []string

func GetReqs

func GetReqs(stra *models.Stra, metric string, nids, endpoints []string, now int64) []*dataobj.QueryData

func GetStra

func GetStra(sid int64) (*models.Stra, bool)

func InitJudge

func InitJudge(section JudgeSection, ident string)

func Judge

func Judge(stra *models.Stra, exp models.Exp, historyData []*dataobj.HistoryData, firstItem *dataobj.JudgeItem, now int64) (history dataobj.History, info string, lastValue string, status bool)

func NodataJudge

func NodataJudge(concurrency int)

func Push2JudgeQueue

func Push2JudgeQueue(items []*dataobj.MetricValue)

func Send

func Send(items []*dataobj.JudgeItem)

func Send2JudgeTask

func Send2JudgeTask(Q *list.SafeListLimited, addr string, concurrent int)

func TagMatch

func TagMatch(straTags []models.Tag, tag map[string]string) bool

func ToJudge

func ToJudge(historyMap *cache.JudgeItemMap, key string, val *dataobj.JudgeItem, now int64)

Types

type AllFunction

type AllFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (AllFunction) Compute

func (f AllFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type AvgFunction

type AvgFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (AvgFunction) Compute

func (f AvgFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type CAvgAbsFunction

type CAvgAbsFunction struct {
	Function
	Limit        int
	Operator     string
	RightValue   float64
	CompareValue float64
}

func (CAvgAbsFunction) Compute

func (f CAvgAbsFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type CAvgFunction

type CAvgFunction struct {
	Function
	Limit        int
	Operator     string
	RightValue   float64
	CompareValue float64
}

func (CAvgFunction) Compute

func (f CAvgFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type CAvgRateAbsFunction

type CAvgRateAbsFunction struct {
	Function
	Limit        int
	Operator     string
	RightValue   float64
	CompareValue float64
}

func (CAvgRateAbsFunction) Compute

func (f CAvgRateAbsFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type CAvgRateFunction

type CAvgRateFunction struct {
	Function
	Limit        int
	Operator     string
	RightValue   float64
	CompareValue float64
}

func (CAvgRateFunction) Compute

func (f CAvgRateFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type DiffFunction

type DiffFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (DiffFunction) Compute

func (f DiffFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

只要有一个点的diff触发阈值,就报警

type Function

type Function interface {
	Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)
}

func ParseFuncFromString

func ParseFuncFromString(str string, span []interface{}, operator string, rightValue float64) (fn Function, err error)

type HappenFunction

type HappenFunction struct {
	Function
	Num        int
	Limit      int
	Operator   string
	RightValue float64
}

func (HappenFunction) Compute

func (f HappenFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type JudgeSection

type JudgeSection struct {
	Batch       int    `yaml:"batch"`
	ConnTimeout int    `yaml:"connTimeout"`
	CallTimeout int    `yaml:"callTimeout"`
	WorkerNum   int    `yaml:"workerNum"`
	MaxConns    int    `yaml:"maxConns"`
	MaxIdle     int    `yaml:"maxIdle"`
	HbsMod      string `yaml:"hbsMod"`
	EventPrefix string `yaml:"eventPrefix"`
}

type MaxFunction

type MaxFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (MaxFunction) Compute

func (f MaxFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type MinFunction

type MinFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (MinFunction) Compute

func (f MinFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type NodataFunction

type NodataFunction struct {
	Function
}

func (NodataFunction) Compute

func (f NodataFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type PDiffFunction

type PDiffFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

pdiff(#3)

func (PDiffFunction) Compute

func (f PDiffFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type StddevFunction

type StddevFunction struct {
	Function
	Num   int
	Limit int
}

func (StddevFunction) Compute

func (f StddevFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

type SumFunction

type SumFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (SumFunction) Compute

func (f SumFunction) Compute(vs []*dataobj.HistoryData) (leftValue dataobj.JsonFloat, isTriggered bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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