Documentation ¶
Overview ¶
Package eval executes the condition for an alert definition, evaluates the condition results, and returns the alert instance states.
Index ¶
- func GetExprRequest(ctx AlertExecCtx, data []models.AlertQuery, now time.Time, ...) (*expr.Request, error)
- type AlertExecCtx
- type Evaluator
- type ExecutionResults
- type FakeEvaluator
- func (_m *FakeEvaluator) ConditionEval(condition *models.Condition, now time.Time, expressionService *expr.Service) (Results, error)
- func (_m *FakeEvaluator) EXPECT() *FakeEvaluator_Expecter
- func (_m *FakeEvaluator) QueriesAndExpressionsEval(orgID int64, data []models.AlertQuery, now time.Time, ...) (*backend.QueryDataResponse, error)
- type FakeEvaluator_ConditionEval_Call
- type FakeEvaluator_Expecter
- func (_e *FakeEvaluator_Expecter) ConditionEval(condition interface{}, now interface{}, expressionService interface{}) *FakeEvaluator_ConditionEval_Call
- func (_e *FakeEvaluator_Expecter) QueriesAndExpressionsEval(orgID interface{}, data interface{}, now interface{}, ...) *FakeEvaluator_QueriesAndExpressionsEval_Call
- type FakeEvaluator_QueriesAndExpressionsEval_Call
- func (_c *FakeEvaluator_QueriesAndExpressionsEval_Call) Return(_a0 *backend.QueryDataResponse, _a1 error) *FakeEvaluator_QueriesAndExpressionsEval_Call
- func (_c *FakeEvaluator_QueriesAndExpressionsEval_Call) Run(run func(orgID int64, data []models.AlertQuery, now time.Time, ...)) *FakeEvaluator_QueriesAndExpressionsEval_Call
- type NumberValueCapture
- type Result
- type Results
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExprRequest ¶
func GetExprRequest(ctx AlertExecCtx, data []models.AlertQuery, now time.Time, dsCacheService datasources.CacheService, secretsService secrets.Service, cfg *setting.Cfg) (*expr.Request, error)
GetExprRequest validates the condition, gets the datasource information and creates an expr.Request from it.
Types ¶
type AlertExecCtx ¶
AlertExecCtx is the context provided for executing an alert condition.
type Evaluator ¶
type Evaluator interface { // ConditionEval executes conditions and evaluates the result. ConditionEval(condition *models.Condition, now time.Time, expressionService *expr.Service) (Results, error) // QueriesAndExpressionsEval executes queries and expressions and returns the result. QueriesAndExpressionsEval(orgID int64, data []models.AlertQuery, now time.Time, expressionService *expr.Service) (*backend.QueryDataResponse, error) }
func NewEvaluator ¶
func NewEvaluator( cfg *setting.Cfg, log log.Logger, datasourceCache datasources.CacheService, secretsService secrets.Service) Evaluator
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 FakeEvaluator ¶
FakeEvaluator is an autogenerated mock type for the Evaluator type
func (*FakeEvaluator) ConditionEval ¶
func (_m *FakeEvaluator) ConditionEval(condition *models.Condition, now time.Time, expressionService *expr.Service) (Results, error)
ConditionEval provides a mock function with given fields: condition, now, expressionService
func (*FakeEvaluator) EXPECT ¶
func (_m *FakeEvaluator) EXPECT() *FakeEvaluator_Expecter
func (*FakeEvaluator) QueriesAndExpressionsEval ¶
func (_m *FakeEvaluator) QueriesAndExpressionsEval(orgID int64, data []models.AlertQuery, now time.Time, expressionService *expr.Service) (*backend.QueryDataResponse, error)
QueriesAndExpressionsEval provides a mock function with given fields: orgID, data, now, expressionService
type FakeEvaluator_ConditionEval_Call ¶
FakeEvaluator_ConditionEval_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConditionEval'
func (*FakeEvaluator_ConditionEval_Call) Return ¶
func (_c *FakeEvaluator_ConditionEval_Call) Return(_a0 Results, _a1 error) *FakeEvaluator_ConditionEval_Call
func (*FakeEvaluator_ConditionEval_Call) Run ¶
func (_c *FakeEvaluator_ConditionEval_Call) Run(run func(condition *models.Condition, now time.Time, expressionService *expr.Service)) *FakeEvaluator_ConditionEval_Call
type FakeEvaluator_Expecter ¶
type FakeEvaluator_Expecter struct {
// contains filtered or unexported fields
}
func (*FakeEvaluator_Expecter) ConditionEval ¶
func (_e *FakeEvaluator_Expecter) ConditionEval(condition interface{}, now interface{}, expressionService interface{}) *FakeEvaluator_ConditionEval_Call
ConditionEval is a helper method to define mock.On call
- condition *models.Condition
- now time.Time
- expressionService *expr.Service
func (*FakeEvaluator_Expecter) QueriesAndExpressionsEval ¶
func (_e *FakeEvaluator_Expecter) QueriesAndExpressionsEval(orgID interface{}, data interface{}, now interface{}, expressionService interface{}) *FakeEvaluator_QueriesAndExpressionsEval_Call
QueriesAndExpressionsEval is a helper method to define mock.On call
- orgID int64
- data []models.AlertQuery
- now time.Time
- expressionService *expr.Service
type FakeEvaluator_QueriesAndExpressionsEval_Call ¶
FakeEvaluator_QueriesAndExpressionsEval_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueriesAndExpressionsEval'
func (*FakeEvaluator_QueriesAndExpressionsEval_Call) Return ¶
func (_c *FakeEvaluator_QueriesAndExpressionsEval_Call) Return(_a0 *backend.QueryDataResponse, _a1 error) *FakeEvaluator_QueriesAndExpressionsEval_Call
func (*FakeEvaluator_QueriesAndExpressionsEval_Call) Run ¶
func (_c *FakeEvaluator_QueriesAndExpressionsEval_Call) Run(run func(orgID int64, data []models.AlertQuery, now time.Time, expressionService *expr.Service)) *FakeEvaluator_QueriesAndExpressionsEval_Call
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 )