Documentation ¶
Index ¶
Constants ¶
const ( EvaluatorNoValue = iota EvaluatorThreshold EvaluatorRanged )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConditionEvalJSON ¶
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 ConditionOperatorType `json:"type"`
}
type ConditionOperatorType ¶
type ConditionOperatorType string
The reducer function +enum
const ( ConditionOperatorAnd ConditionOperatorType = "and" ConditionOperatorOr ConditionOperatorType = "or" )
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 NewConditionCmd ¶
func NewConditionCmd(refID string, ccj []ConditionJSON) (*ConditionsCmd, error)
func UnmarshalConditionsCmd ¶
func UnmarshalConditionsCmd(rawQuery map[string]any, 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.
func (*ConditionsCmd) Type ¶
func (cmd *ConditionsCmd) Type() string
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 ¶
type EvaluatorKind ¶
type EvaluatorKind int