conditions

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

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(s *mcclient.ClientSession, manager modulebase.Manager, params *jsonutils.JSONDict, scope string, showDetails bool) ([]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
	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    *monitor.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(userCred mcclient.TokenCredential, scope string, skipCheckSeries bool) (*monitor.MetricsQueryResult, 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 *monitor.TimeSeries)

func (*QueryCondition) GenerateFormatCond

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

func (*QueryCondition) GetCommonAlertDetails

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

func (*QueryCondition) GetQueryResources

func (c *QueryCondition) GetQueryResources(s *mcclient.ClientSession, scope string, showDetails bool) ([]jsonutils.JSONObject, error)

func (*QueryCondition) NewEvalMatch

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

type Reducer

type Reducer interface {
	Reduce(series *monitor.TimeSeries) (*float64, []string)
	GetType() monitor.ReducerType
	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