classic

package
v0.0.0-...-fb7f86c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EvaluatorNoValue = iota
	EvaluatorThreshold
	EvaluatorRanged
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConditionEvalJSON

type ConditionEvalJSON struct {
	Params []float64 `json:"params"`
	Type   string    `json:"type"` // e.g. "gt"
}

type ConditionJSON

type ConditionJSON struct {
	Evaluator ConditionEvalJSON     `json:"evaluator"`
	Operator  ConditionOperatorJSON `json:"operator"`
	Query     ConditionQueryJSON    `json:"query"`
	Reducer   ConditionReducerJSON  `json:"reducer"`
}

ConditionJSON is the JSON model for a single condition in ConditionsCmd. It is based on services/alerting/conditions/query.go's newQueryCondition().

type ConditionOperatorJSON

type ConditionOperatorJSON struct {
	Type string `json:"type"`
}

type ConditionQueryJSON

type ConditionQueryJSON struct {
	Params []string `json:"params"`
}

type ConditionReducerJSON

type ConditionReducerJSON struct {
	Type string `json:"type"`
}

type ConditionsCmd

type ConditionsCmd struct {
	Conditions []condition
	RefID      string
}

ConditionsCmd is a command that supports the reduction and comparison of conditions.

A condition in ConditionsCmd can reduce a time series, contain an instant metric, or the result of another expression; and checks if it exceeds a threshold, falls within a range, or does not contain a value.

If ConditionsCmd contains more than one condition, it reduces the boolean outcomes of the threshold, range or value checks using the logical operator of the right hand side condition until all conditions have been reduced to a single boolean outcome. ConditionsCmd does not follow operator precedence.

For example if we have the following classic condition:

min(A) > 5 OR max(B) < 10 AND C = 1

which reduces to the following boolean outcomes:

false OR true AND true

then the outcome of ConditionsCmd is true.

func UnmarshalConditionsCmd

func UnmarshalConditionsCmd(rawQuery map[string]interface{}, refID string) (*ConditionsCmd, error)

UnmarshalConditionsCmd creates a new ConditionsCmd.

func (*ConditionsCmd) Execute

func (cmd *ConditionsCmd) Execute(ctx context.Context, t time.Time, vars mathexp.Vars, tracer tracing.Tracer) (mathexp.Results, error)

Execute runs the command and returns the results or an error if the command failed to execute.

func (*ConditionsCmd) NeedsVars

func (cmd *ConditionsCmd) NeedsVars() []string

NeedsVars returns the variable names (refIds) that are dependencies to execute the command and allows the command to fulfill the Command interface.

type EvalMatch

type EvalMatch struct {
	Value  *float64    `json:"value"`
	Metric string      `json:"metric"`
	Labels data.Labels `json:"labels"`
}

EvalMatch represents the series violating the threshold. It goes into the metadata of data frames so it can be extracted.

func (EvalMatch) MarshalJSON

func (em EvalMatch) MarshalJSON() ([]byte, error)

type EvaluatorKind

type EvaluatorKind int

Jump to

Keyboard shortcuts

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