Documentation ¶
Index ¶
- Variables
- func RegisterCondition(typeName string, factory ConditionFactory)
- func RegisterNotifier(typeName string, factory NotifierFactory)
- type AlertTestCommand
- type Condition
- type ConditionFactory
- type ConditionResult
- type DashAlertExtractor
- type DefaultEvalHandler
- type DefaultResultHandler
- type DefaultRuleReader
- type Engine
- type EvalContext
- func (c *EvalContext) GetDashboardSlug() (string, error)
- func (a *EvalContext) GetDurationMs() float64
- func (c *EvalContext) GetNotificationTitle() string
- func (c *EvalContext) GetRuleUrl() (string, error)
- func (c *EvalContext) GetStateModel() *StateDescription
- func (c *EvalContext) ShouldSendNotification() bool
- func (c *EvalContext) ShouldUpdateAlertState() bool
- type EvalHandler
- type EvalMatch
- type Job
- type Level
- type NotificationTestCommand
- type Notifier
- type NotifierFactory
- type ResultHandler
- type ResultLogEntry
- type RootNotifier
- type Rule
- type RuleReader
- type Scheduler
- type SchedulerImpl
- type StateDescription
- type Ticker
- type UpdateDashboardAlertsCommand
- 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(typeName string, factory NotifierFactory)
Types ¶
type AlertTestCommand ¶
type AlertTestCommand struct { Dashboard *simplejson.Json PanelId int64 OrgId int64 Result *EvalContext }
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 }
func NewDashAlertExtractor ¶
func NewDashAlertExtractor(dash *m.Dashboard, orgId int64) *DashAlertExtractor
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() *DefaultResultHandler
func (*DefaultResultHandler) GetStateFromEvaluation ¶
func (handler *DefaultResultHandler) GetStateFromEvaluation(evalContext *EvalContext) m.AlertStateType
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 Description 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) GetDashboardSlug ¶
func (c *EvalContext) GetDashboardSlug() (string, error)
func (*EvalContext) GetDurationMs ¶
func (a *EvalContext) GetDurationMs() float64
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) ShouldSendNotification ¶
func (c *EvalContext) ShouldSendNotification() bool
func (*EvalContext) ShouldUpdateAlertState ¶
func (c *EvalContext) ShouldUpdateAlertState() bool
type EvalHandler ¶
type EvalHandler interface {
Eval(evalContext *EvalContext)
}
type NotificationTestCommand ¶
type NotificationTestCommand struct { State m.AlertStateType Name string Type string Settings *simplejson.Json }
type NotifierFactory ¶
type NotifierFactory func(notification *m.AlertNotification) (Notifier, error)
type ResultHandler ¶
type ResultHandler interface {
Handle(evalContext *EvalContext) error
}
type ResultLogEntry ¶
type ResultLogEntry struct { Message string Data interface{} }
type RootNotifier ¶
type RootNotifier struct {
// contains filtered or unexported fields
}
func NewRootNotifier ¶
func NewRootNotifier() *RootNotifier
func (*RootNotifier) GetIsDefault ¶
func (n *RootNotifier) GetIsDefault() bool
func (*RootNotifier) GetNotifierId ¶
func (n *RootNotifier) GetNotifierId() int64
func (*RootNotifier) GetType ¶
func (n *RootNotifier) GetType() string
func (*RootNotifier) NeedsImage ¶
func (n *RootNotifier) NeedsImage() bool
func (*RootNotifier) Notify ¶
func (n *RootNotifier) Notify(context *EvalContext) error
func (*RootNotifier) PassesFilter ¶
func (n *RootNotifier) PassesFilter(rule *Rule) bool
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
type ValidationError ¶
type ValidationError struct {
Reason string
}
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.