grafana/pkg/services/alerting/interfaces.go

66 lines
1.4 KiB
Go
Raw Normal View History

package alerting
import (
"context"
"time"
2018-09-27 07:32:54 -05:00
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb/legacydata"
)
type evalHandler interface {
Eval(evalContext *EvalContext)
}
type scheduler interface {
2016-07-27 09:29:28 -05:00
Tick(time time.Time, execQueue chan *Job)
Update(rules []*Rule)
}
// Notifier is responsible for sending alert notifications.
type Notifier interface {
Notify(evalContext *EvalContext) error
GetType() string
NeedsImage() bool
// ShouldNotify checks this evaluation should send an alert notification
2018-09-27 07:32:54 -05:00
ShouldNotify(ctx context.Context, evalContext *EvalContext, notificationState *models.AlertNotificationState) bool
GetNotifierUID() string
GetIsDefault() bool
GetSendReminder() bool
2018-10-17 03:41:18 -05:00
GetDisableResolveMessage() bool
GetFrequency() time.Duration
}
type notifierState struct {
2018-09-27 07:32:54 -05:00
notifier Notifier
state *models.AlertNotificationState
}
type notifierStateSlice []*notifierState
func (notifiers notifierStateSlice) ShouldUploadImage() bool {
2018-09-27 07:32:54 -05:00
for _, ns := range notifiers {
if ns.notifier.NeedsImage() {
return true
}
}
return false
}
// ConditionResult is the result of a condition evaluation.
type ConditionResult struct {
Firing bool
NoDataFound bool
Operator string
EvalMatches []*EvalMatch
AllMatches []*EvalMatch
}
// Condition is responsible for evaluating an alert condition.
2016-07-27 09:29:28 -05:00
type Condition interface {
Eval(result *EvalContext, requestHandler legacydata.RequestHandler) (*ConditionResult, error)
}