conditions

package
v0.3.10-0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NO_DATA = "nodata"

	HOST_TAG_NAME   = "name"
	HOST_TAG_ID     = "id"
	HOST_TAG_IP     = "access_ip"
	RESOURCE_TAG_IP = "ips"
	HOST_TAG_BRAND  = "brand"
)

Variables

This section is empty.

Functions

func GetFetchImpByDb

func GetFetchImpByDb(db string) iEvalMatchFetch

func ListAllResources

func ListAllResources(manager modulebase.Manager, params *jsonutils.JSONDict) ([]jsonutils.JSONObject, error)

func NewCommonAlertReducer

func NewCommonAlertReducer(t string) *queryReducer

func RestryFetchImp

func RestryFetchImp(db string, imp iEvalMatchFetch)

Types

type AlertEvaluator

type AlertEvaluator interface {
	Eval(reducedValue *float64) bool
	String() string
}

AlertEvaluator evaluates the reduced value of a timeserie. Returning true if a timeseries is violating the condition ex: ThresholdEvaluator, NoValueEvaluator, RangeEvaluator

func NewAlertEvaluator

func NewAlertEvaluator(cond *monitor.Condition) (AlertEvaluator, error)

NewAlertEvaluator is a factory function for returning an `AlertEvaluator` depending on the input condition.

type AlertQuery

type AlertQuery struct {
	Model        monitor.MetricQuery
	DataSourceId string
	From         string
	To           string
}

AlertQuery contains information about what datasource a query should be send to and the query object.

type FormatCond

type FormatCond struct {
	QueryMeta    *tsdb.QueryResultMeta
	QueryKeyInfo string
	Reducer      string
	Evaluator    AlertEvaluator
}

func (FormatCond) String

func (c FormatCond) String() string

type MetricQueryCondition

type MetricQueryCondition struct {
	QueryCons     []QueryCondition
	HandleRequest tsdb.HandleRequestFunc
}

func NewMetricQueryCondition

func NewMetricQueryCondition(models []*monitor.AlertCondition) (*MetricQueryCondition, error)

func (*MetricQueryCondition) ExecuteQuery

func (query *MetricQueryCondition) ExecuteQuery() (*mq.Metrics, error)

type NoDataQueryCondition

type NoDataQueryCondition struct {
	*QueryCondition
}

func (*NoDataQueryCondition) Eval

func (*NoDataQueryCondition) NewNoDataEvalMatch

func (c *NoDataQueryCondition) NewNoDataEvalMatch(context *alerting.EvalContext, host jsonutils.JSONObject) (*monitor.EvalMatch, error)

type QueryCondition

type QueryCondition struct {
	Index         int
	Query         AlertQuery
	Reducer       Reducer
	Evaluator     AlertEvaluator
	Operator      string
	HandleRequest tsdb.HandleRequestFunc
	ResType       string
}

QueryCondition is responsible for issue and query. reduce the timeseries into single values and evaluate if they are firing or not.

func (*QueryCondition) Eval

Eval evaluates te `QueryCondition`.

func (*QueryCondition) FetchCustomizeEvalMatch

func (c *QueryCondition) FetchCustomizeEvalMatch(context *alerting.EvalContext, evalMatch *monitor.EvalMatch,
	alertDetails *monitor.CommonAlertMetricDetails)

func (*QueryCondition) FillSerieByResourceField

func (c *QueryCondition) FillSerieByResourceField(resource jsonutils.JSONObject,
	series *tsdb.TimeSeries)

func (*QueryCondition) GenerateFormatCond

func (c *QueryCondition) GenerateFormatCond(meta *tsdb.QueryResultMeta, metric string) *FormatCond

func (*QueryCondition) GetCommonAlertDetails

func (c *QueryCondition) GetCommonAlertDetails(context *alerting.EvalContext) (*monitor.CommonAlertMetricDetails, error)

func (*QueryCondition) GetQueryResources

func (c *QueryCondition) GetQueryResources() ([]jsonutils.JSONObject, error)

func (*QueryCondition) NewEvalMatch

func (c *QueryCondition) NewEvalMatch(context *alerting.EvalContext, series tsdb.TimeSeries,
	meta *tsdb.QueryResultMeta, value *float64, valStrArr []string) (*monitor.EvalMatch, error)

type Reducer

type Reducer interface {
	Reduce(series *tsdb.TimeSeries) (*float64, []string)
	GetType() string
	GetParams() []float64
}

func NewAlertReducer

func NewAlertReducer(cond *monitor.Condition) (Reducer, error)

func NewSuggestRuleReducer

func NewSuggestRuleReducer(t string, duration time.Duration) Reducer

type SuggestQueryCondition

type SuggestQueryCondition struct {
	*QueryCondition
}

func (*SuggestQueryCondition) Eval

Jump to

Keyboard shortcuts

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