Documentation ¶
Overview ¶
Package eval executes the condition for an alert definition, evaluates the condition results, and returns the alert instance states.
Index ¶
Constants ¶
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 false. Alerting )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertExecCtx ¶
AlertExecCtx is the context provided for executing an alert condition.
type AlertQuery ¶
type AlertQuery struct { // RefID is the unique identifier of the query, set by the frontend call. RefID string `json:"refId"` // QueryType is an optional identifier for the type of query. // It can be used to distinguish different types of queries. QueryType string `json:"queryType"` // RelativeTimeRange is the relative Start and End of the query as sent by the frontend. RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"` DatasourceUID string `json:"-"` // JSON is the raw JSON query and includes the above properties as well as custom properties. Model json.RawMessage `json:"model"` // contains filtered or unexported fields }
AlertQuery represents a single query associated with an alert definition.
func (*AlertQuery) GetDatasource ¶
func (aq *AlertQuery) GetDatasource() (string, error)
GetDatasource returns the query datasource identifier.
func (*AlertQuery) IsExpression ¶
func (aq *AlertQuery) IsExpression() (bool, error)
IsExpression returns true if the alert query is an expression.
func (*AlertQuery) PreSave ¶
func (aq *AlertQuery) PreSave() error
PreSave sets query's properties. It should be called before being saved.
type Condition ¶
type Condition struct { RefID string `json:"refId"` OrgID int64 `json:"-"` QueriesAndExpressions []AlertQuery `json:"queriesAndExpressions"` }
Condition contains backend expressions and queries and the RefID of the query or expression that will be evaluated.
type Duration ¶
Duration is a type used for marshalling durations.
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type ExecutionResults ¶
ExecutionResults contains the unevaluated results from executing a condition.
type RelativeTimeRange ¶
RelativeTimeRange is the per query start and end time for requests.
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. This may be temporary, as there might be a fair amount we want to display in the frontend, and it might not make sense to store that in data.Frame. For the first pass, I would expect a Frame with a single row, and a column for each instance with a boolean value.