alerting

package
v4.1.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

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 ConditionResult struct {
	Firing      bool
	NoDataFound bool
	Operator    string
	EvalMatches []*EvalMatch
}

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

func (*DashAlertExtractor) GetAlerts

func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error)

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

type DefaultRuleReader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRuleReader

func NewRuleReader() *DefaultRuleReader

func (*DefaultRuleReader) Fetch

func (arr *DefaultRuleReader) Fetch() []*Rule

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine() *Engine

func (*Engine) Run

func (e *Engine) Run(ctx context.Context) error

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) 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 EvalMatch

type EvalMatch struct {
	Value  float64           `json:"value"`
	Metric string            `json:"metric"`
	Tags   map[string]string `json:"tags"`
}

type Job

type Job struct {
	Offset     int64
	OffsetWait bool
	Delay      bool
	Running    bool
	Rule       *Rule
}

type Level

type Level struct {
	Operator string
	Value    float64
}

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
	PassesFilter(rule *Rule) bool

	GetNotifierId() int64
	GetIsDefault() bool
}

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
}

func NewRuleFromDBAlert

func NewRuleFromDBAlert(ruleDef *m.Alert) (*Rule, error)

type RuleReader

type RuleReader interface {
	Fetch() []*Rule
}

type Scheduler

type Scheduler interface {
	Tick(time time.Time, execQueue chan *Job)
	Update(rules []*Rule)
}

func NewScheduler

func NewScheduler() Scheduler

type SchedulerImpl

type SchedulerImpl struct {
	// contains filtered or unexported fields
}

func (*SchedulerImpl) Tick

func (s *SchedulerImpl) Tick(tickTime time.Time, execQueue chan *Job)

func (*SchedulerImpl) Update

func (s *SchedulerImpl) Update(rules []*Rule)

type StateDescription

type StateDescription struct {
	Color string
	Text  string
	Data  string
}

type Ticker

type Ticker struct {
	C chan time.Time
	// contains filtered or unexported fields
}

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

func NewTicker

func NewTicker(last time.Time, initialOffset time.Duration, c clock.Clock) *Ticker

NewTicker returns a ticker that ticks on second marks or very shortly after, and never drops ticks

type UpdateDashboardAlertsCommand

type UpdateDashboardAlertsCommand struct {
	UserId    int64
	OrgId     int64
	Dashboard *m.Dashboard
}

type ValidateDashboardAlertsCommand

type ValidateDashboardAlertsCommand struct {
	UserId    int64
	OrgId     int64
	Dashboard *m.Dashboard
}

type ValidationError

type ValidationError struct {
	Reason      string
	Err         error
	Alertid     int64
	DashboardId int64
	PanelId     int64
}

func (ValidationError) Error

func (e ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL