Documentation ¶
Index ¶
- Variables
- func RegisterCondition(typeName string, factory ConditionFactory)
- func RegisterNotifier(plugin *NotifierPlugin)
- type AlertTestCommand
- type AlertingService
- type Condition
- type ConditionFactory
- type ConditionResult
- type DashAlertExtractor
- type DefaultEvalHandler
- type DefaultResultHandler
- type DefaultRuleReader
- type EvalContext
- func (c *EvalContext) GetDashboardUID() (*m.DashboardRef, error)
- func (a *EvalContext) GetDurationMs() float64
- func (c *EvalContext) GetNewState() m.AlertStateType
- func (c *EvalContext) GetNotificationTitle() string
- func (c *EvalContext) GetRuleUrl() (string, error)
- func (c *EvalContext) GetStateModel() *StateDescription
- func (c *EvalContext) ShouldUpdateAlertState() bool
- type EvalHandler
- type EvalMatch
- type Job
- type Level
- type NotificationService
- type NotificationTestCommand
- type Notifier
- type NotifierFactory
- type NotifierPlugin
- type NotifierSlice
- type ResultHandler
- type ResultLogEntry
- type Rule
- type RuleReader
- type Scheduler
- type SchedulerImpl
- type StateDescription
- type Ticker
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ValueFormatRegex = regexp.MustCompile(`^\d+`) UnitFormatRegex = regexp.MustCompile(`\w{1}$`) )
Functions ¶
func RegisterCondition ¶
func RegisterCondition(typeName string, factory ConditionFactory)
func RegisterNotifier ¶
func RegisterNotifier(plugin *NotifierPlugin)
Types ¶
type AlertTestCommand ¶
type AlertTestCommand struct { Dashboard *simplejson.Json PanelId int64 OrgId int64 Result *EvalContext }
type AlertingService ¶ added in v5.2.0
type AlertingService struct { RenderService rendering.Service `inject:""` // contains filtered or unexported fields }
func NewEngine ¶
func NewEngine() *AlertingService
func (*AlertingService) Init ¶ added in v5.2.0
func (e *AlertingService) Init() error
func (*AlertingService) IsDisabled ¶ added in v5.2.0
func (e *AlertingService) IsDisabled() bool
type Condition ¶
type Condition interface {
Eval(result *EvalContext) (*ConditionResult, error)
}
type ConditionFactory ¶
type ConditionFactory func(model *simplejson.Json, index int) (Condition, error)
type ConditionResult ¶
type DashAlertExtractor ¶
type DashAlertExtractor struct { Dash *m.Dashboard OrgID int64 // contains filtered or unexported fields }
DashAlertExtractor extracts alerts from the dashboard json
func NewDashAlertExtractor ¶
func NewDashAlertExtractor(dash *m.Dashboard, orgID int64) *DashAlertExtractor
NewDashAlertExtractor returns a new DashAlertExtractor
func (*DashAlertExtractor) GetAlerts ¶
func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error)
GetAlerts extracts alerts from the dashboard json and does full validation on the alert json data
func (*DashAlertExtractor) ValidateAlerts ¶ added in v5.0.4
func (e *DashAlertExtractor) ValidateAlerts() error
ValidateAlerts validates alerts in the dashboard json but does not require a valid dashboard id in the first validation pass
type DefaultEvalHandler ¶
type DefaultEvalHandler struct {
// contains filtered or unexported fields
}
func NewEvalHandler ¶
func NewEvalHandler() *DefaultEvalHandler
func (*DefaultEvalHandler) Eval ¶
func (e *DefaultEvalHandler) Eval(context *EvalContext)
type DefaultResultHandler ¶
type DefaultResultHandler struct {
// contains filtered or unexported fields
}
func NewResultHandler ¶
func NewResultHandler(renderService rendering.Service) *DefaultResultHandler
func (*DefaultResultHandler) Handle ¶
func (handler *DefaultResultHandler) Handle(evalContext *EvalContext) error
type DefaultRuleReader ¶
func NewRuleReader ¶
func NewRuleReader() *DefaultRuleReader
func (*DefaultRuleReader) Fetch ¶
func (arr *DefaultRuleReader) Fetch() []*Rule
type EvalContext ¶
type EvalContext struct { Firing bool IsTestRun bool EvalMatches []*EvalMatch Logs []*ResultLogEntry Error error ConditionEvals string StartTime time.Time EndTime time.Time Rule *Rule ImagePublicUrl string ImageOnDiskPath string NoDataFound bool PrevAlertState m.AlertStateType Ctx context.Context // contains filtered or unexported fields }
func NewEvalContext ¶
func NewEvalContext(alertCtx context.Context, rule *Rule) *EvalContext
func (*EvalContext) GetDashboardUID ¶
func (c *EvalContext) GetDashboardUID() (*m.DashboardRef, error)
func (*EvalContext) GetDurationMs ¶
func (a *EvalContext) GetDurationMs() float64
func (*EvalContext) GetNewState ¶ added in v5.1.0
func (c *EvalContext) GetNewState() m.AlertStateType
func (*EvalContext) GetNotificationTitle ¶
func (c *EvalContext) GetNotificationTitle() string
func (*EvalContext) GetRuleUrl ¶
func (c *EvalContext) GetRuleUrl() (string, error)
func (*EvalContext) GetStateModel ¶
func (c *EvalContext) GetStateModel() *StateDescription
func (*EvalContext) ShouldUpdateAlertState ¶
func (c *EvalContext) ShouldUpdateAlertState() bool
type EvalHandler ¶
type EvalHandler interface {
Eval(evalContext *EvalContext)
}
type NotificationService ¶
type NotificationService interface {
SendIfNeeded(context *EvalContext) error
}
func NewNotificationService ¶
func NewNotificationService(renderService rendering.Service) NotificationService
type NotificationTestCommand ¶
type NotificationTestCommand struct { State m.AlertStateType Name string Type string Settings *simplejson.Json }
type Notifier ¶
type Notifier interface { Notify(evalContext *EvalContext) error GetType() string NeedsImage() bool // ShouldNotify checks this evaluation should send an alert notification ShouldNotify(ctx context.Context, evalContext *EvalContext) bool GetNotifierId() int64 GetIsDefault() bool GetSendReminder() bool GetFrequency() time.Duration }
type NotifierFactory ¶
type NotifierFactory func(notification *m.AlertNotification) (Notifier, error)
type NotifierPlugin ¶
type NotifierPlugin struct { Type string `json:"type"` Name string `json:"name"` Description string `json:"description"` OptionsTemplate string `json:"optionsTemplate"` Factory NotifierFactory `json:"-"` }
func GetNotifiers ¶
func GetNotifiers() []*NotifierPlugin
type NotifierSlice ¶
type NotifierSlice []Notifier
func (NotifierSlice) ShouldUploadImage ¶
func (notifiers NotifierSlice) ShouldUploadImage() bool
type ResultHandler ¶
type ResultHandler interface {
Handle(evalContext *EvalContext) error
}
type ResultLogEntry ¶
type ResultLogEntry struct { Message string Data interface{} }
type Rule ¶
type Rule struct { Id int64 OrgId int64 DashboardId int64 PanelId int64 Frequency int64 Name string Message string NoDataState m.NoDataOption ExecutionErrorState m.ExecutionErrorOption State m.AlertStateType Conditions []Condition Notifications []int64 }
type RuleReader ¶
type RuleReader interface {
Fetch() []*Rule
}
type Scheduler ¶
func NewScheduler ¶
func NewScheduler() Scheduler
type SchedulerImpl ¶
type SchedulerImpl struct {
// contains filtered or unexported fields
}
func (*SchedulerImpl) Update ¶
func (s *SchedulerImpl) Update(rules []*Rule)
type StateDescription ¶
type Ticker ¶
ticker is a ticker to power the alerting scheduler. it's like a time.Ticker, except:
- it doesn't drop ticks for slow receivers, rather, it queues up. so that callers are in control to instrument what's going on.
- it automatically ticks every second, which is the right thing in our current design
- it ticks on second marks or very shortly after. this provides a predictable load pattern (this shouldn't cause too much load contention issues because the next steps in the pipeline just process at their own pace)
- the timestamps are used to mark "last datapoint to query for" and as such, are a configurable amount of seconds in the past
- because we want to allow:
- a clean "resume where we left off" and "don't yield ticks we already did"
- adjusting offset over time to compensate for storage backing up or getting fast and providing lower latency you specify a lastProcessed timestamp as well as an offset at creation, or runtime
Source Files ¶
Click to show internal directories.
Click to hide internal directories.