Documentation
¶
Overview ¶
Package eval executes the condition for an alert definition, evaluates the condition results, and returns the alert instance states.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExprRequest ¶
func GetExprRequest(ctx AlertExecCtx, data []models.AlertQuery, now time.Time) (*expr.Request, error)
GetExprRequest validates the condition and creates a expr.Request from it.
Types ¶
type AlertExecCtx ¶
AlertExecCtx is the context provided for executing an alert condition.
type Evaluator ¶
func (*Evaluator) ConditionEval ¶
func (e *Evaluator) ConditionEval(condition *models.Condition, now time.Time, expressionService *expr.Service) (Results, error)
ConditionEval executes conditions and evaluates the result.
func (*Evaluator) QueriesAndExpressionsEval ¶
func (e *Evaluator) QueriesAndExpressionsEval(orgID int64, data []models.AlertQuery, now time.Time, expressionService *expr.Service) (*backend.QueryDataResponse, error)
QueriesAndExpressionsEval executes queries and expressions and returns the result.
type ExecutionResults ¶
type ExecutionResults struct {
Error error
// NoData contains the DatasourceUID for RefIDs that returned no data.
NoData map[string]string
Results data.Frames
}
ExecutionResults contains the unevaluated results from executing a condition.
type NumberValueCapture ¶
type Result ¶
type Result struct {
Instance data.Labels
State State // Enum
// Error message for Error state. should be nil if State != Error.
Error error
EvaluatedAt time.Time
EvaluationDuration time.Duration
// EvaluationString is a string representation of evaluation data such
// as EvalMatches (from "classic condition"), and in the future from operations
// like SSE "math".
EvaluationString string
// Values contains the RefID and value of reduce and math expressions.
// It does not contain values for classic conditions as the values
// in classic conditions do not have a RefID.
Values map[string]NumberValueCapture
}
Result contains the evaluated State of an alert instance identified by its labels.
type Results ¶
type Results []Result
Results is a slice of evaluated alert instances states.
func (Results) AsDataFrame ¶
AsDataFrame forms the EvalResults in Frame suitable for displaying in the table panel of the front end. It displays one row per alert instance, with a column for each label and one for the alerting state.
type State ¶
type State int
State is an enum of the evaluation State for an alert instance.
const ( // Normal is the eval state for an alert instance condition // that evaluated to false. Normal State = iota // Alerting is the eval state for an alert instance condition // that evaluated to true (Alerting). Alerting // Pending is the eval state for an alert instance condition // that evaluated to true (Alerting) but has not yet met // the For duration defined in AlertRule. Pending // NoData is the eval state for an alert rule condition // that evaluated to NoData. NoData // Error is the eval state for an alert rule condition // that evaluated to Error. Error )