Documentation ¶
Index ¶
- Constants
- Variables
- func Autostyle(i int) chart.Style
- func Close()
- func Load(c *conf.Conf) error
- func Match(pattern, name string) (matched bool, err error)
- func Run() error
- type Action
- type ActionType
- type AlertError
- type AlertStatus
- type Context
- func (c *Context) Ack() string
- func (c *Context) Eval(v interface{}) (interface{}, error)
- func (c *Context) EvalAll(v interface{}) (interface{}, error)
- func (c *Context) Expr(v string) string
- func (c *Context) GetMeta(metric, name string, v interface{}) (interface{}, error)
- func (c *Context) Graph(v interface{}, args ...string) (interface{}, error)
- func (c *Context) GraphAll(v interface{}, args ...string) (interface{}, error)
- func (c *Context) GraphLink(v string) string
- func (c *Context) HTTPGet(url string) string
- func (c *Context) HTTPGetJSON(url string) (*jsonq.JsonQuery, error)
- func (c *Context) HTTPPost(url, bodyType, data string) string
- func (c *Context) HostView(host string) string
- func (c *Context) Incident() string
- func (c *Context) LSQuery(index_root, filter, sduration, eduration string, size int) (interface{}, error)
- func (c *Context) LSQueryAll(index_root, keystring, filter, sduration, eduration string, size int) (interface{}, error)
- func (c *Context) LeftJoin(v ...interface{}) (interface{}, error)
- func (c *Context) Lookup(table, key string) (string, error)
- func (c *Context) LookupAll(table, key string, group interface{}) (string, error)
- func (c *Context) Rule() (string, error)
- type Event
- type HostData
- type HostInterface
- type Incident
- type MetadataMetric
- type Metavalue
- type Result
- type RunHistory
- type Schedule
- func (s *Schedule) Action(user, message string, t ActionType, ak expr.AlertKey) error
- func (s *Schedule) ActionNotify(at ActionType, user, message string, aks []expr.AlertKey)
- func (s *Schedule) AddNotification(ak expr.AlertKey, n *conf.Notification, started time.Time)
- func (s *Schedule) AddSilence(start, end time.Time, alert, tagList string, forget, confirm bool, ...) (map[expr.AlertKey]bool, error)
- func (s *Schedule) AlertSuccessful(name string) bool
- func (s *Schedule) CheckAlert(T miniprofiler.Timer, r *RunHistory, a *conf.Alert)
- func (s *Schedule) CheckExpr(T miniprofiler.Timer, rh *RunHistory, a *conf.Alert, e *expr.Expr, ...) (alerts expr.AlertKeys, err error)
- func (s *Schedule) CheckNotifications() time.Duration
- func (s *Schedule) ClearErrorLine(alert string, startTime time.Time)
- func (s *Schedule) ClearSilence(id string) error
- func (s *Schedule) Close()
- func (s *Schedule) CollectStates()
- func (s *Schedule) Data(rh *RunHistory, st *State, a *conf.Alert, isEmail bool) *Context
- func (s *Schedule) ExecuteBadTemplate(s_err, b_err error, rh *RunHistory, a *conf.Alert, st *State) (subject, body []byte, err error)
- func (s *Schedule) ExecuteBody(rh *RunHistory, a *conf.Alert, st *State, isEmail bool) ([]byte, []*conf.Attachment, error)
- func (s *Schedule) ExecuteSubject(rh *RunHistory, a *conf.Alert, st *State, isEmail bool) ([]byte, error)
- func (s *Schedule) ExprGraph(t miniprofiler.Timer, unit string, res []*expr.Result) (chart.Chart, error)
- func (s *Schedule) ExprPNG(t miniprofiler.Timer, w io.Writer, width, height int, unit string, ...) error
- func (s *Schedule) ExprSVG(t miniprofiler.Timer, w io.Writer, width, height int, unit string, ...) error
- func (s *Schedule) GetErrorHistory() map[string]*AlertStatus
- func (s *Schedule) GetIncidentEvents(id uint64) (*Incident, []Event, []Action, error)
- func (s *Schedule) GetIncidents(alert string, from, to time.Time) []*Incident
- func (s *Schedule) GetLockStatus() (holder string, since time.Time)
- func (s *Schedule) GetMetadata(metric string, subset opentsdb.TagSet) []metadata.Metasend
- func (s *Schedule) GetOrCreateStatus(ak expr.AlertKey) *State
- func (s *Schedule) GetStateFileBackup() ([]byte, error)
- func (s *Schedule) GetStatus(ak expr.AlertKey) *State
- func (s *Schedule) Host(filter string) map[string]*HostData
- func (s *Schedule) Init(c *conf.Conf) error
- func (s *Schedule) Load(c *conf.Conf) error
- func (s *Schedule) LoadTempConfig(hash string) (text string, err error)
- func (s *Schedule) Lock(method string)
- func (s *Schedule) MarshalGroups(T miniprofiler.Timer, filter string) (*StateGroups, error)
- func (s *Schedule) MetadataMetrics(metric string) map[string]*MetadataMetric
- func (s *Schedule) NewRunHistory(start time.Time, cache *cache.Cache) *RunHistory
- func (s *Schedule) Notify(st *State, n *conf.Notification)
- func (s *Schedule) PingHosts()
- func (s *Schedule) PutMetadata(k metadata.Metakey, v interface{})
- func (s *Schedule) RestoreState() error
- func (s *Schedule) Run() error
- func (s *Schedule) RunAlert(a *conf.Alert)
- func (s *Schedule) RunHistory(r *RunHistory)
- func (s *Schedule) SaveTempConfig(text string) (hash string, err error)
- func (s *Schedule) SetStatus(ak expr.AlertKey, st *State)
- func (s *Schedule) Silenced() map[expr.AlertKey]Silence
- func (s *Schedule) Unlock()
- type Silence
- type State
- func (s *State) AbnormalEvent() *Event
- func (s *State) AbnormalStatus() Status
- func (s *State) Action(user, message string, t ActionType, timestamp time.Time)
- func (s *State) AlertKey() expr.AlertKey
- func (s *State) Append(event *Event) Status
- func (s *State) Copy() *State
- func (s *State) IsActive() bool
- func (s *State) Last() Event
- func (s *State) Status() Status
- func (s *State) Touch()
- type StateGroup
- type StateGroups
- type StateTuple
- type States
- type Status
Constants ¶
const (
Separator = filepath.Separator
)
Variables ¶
var DefaultSched = &Schedule{}
var ErrBadPattern = errors.New("syntax error in pattern")
ErrBadPattern indicates a globbing pattern was malformed.
Functions ¶
func Match ¶
Match returns true if name matches any of the patterns. The pattern syntax is:
pattern: { term } [ '|' { term } '|' ... ] term: '*' matches any sequence of non-Separator characters '?' matches any single non-Separator character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
Match requires pattern to match all of name, not just a substring. The only possible returned error is ErrBadPattern, when pattern is malformed.
Types ¶
type ActionType ¶
type ActionType int
const ( ActionNone ActionType = iota ActionAcknowledge ActionClose ActionForget )
func (ActionType) MarshalJSON ¶
func (a ActionType) MarshalJSON() ([]byte, error)
func (ActionType) String ¶
func (a ActionType) String() string
type AlertStatus ¶
type AlertStatus struct { Success bool Errors []*AlertError }
Alert Status is the current state of a single alert
type Context ¶
type Context struct { *State Alert *conf.Alert IsEmail bool Attachments []*conf.Attachment // contains filtered or unexported fields }
func (*Context) Eval ¶
Eval takes a result or an expression which it evaluates to a result. It returns a value with tags corresponding to the context's tags. If no such result is found, the first result with nil tags is returned. If no such result is found, nil is returned.
func (*Context) Expr ¶
Expr takes an expression in the form of a string, changes the tags to match the context of the alert, and returns a link to the expression page.
func (*Context) Graph ¶
Graph returns an SVG for the given result (or expression, for which it gets the result) with same tags as the context's tags.
func (*Context) GraphAll ¶
GraphAll returns an SVG for the given result (or expression, for which it gets the result).
func (*Context) GraphLink ¶
GraphLink takes an expression in the form of a string, and returns a link to the expression page's graph tab with the time set.
func (*Context) LSQueryAll ¶
func (*Context) LeftJoin ¶
LeftJoin takes slices of results and expressions for which it gets the slices of results. Then it joins the 2nd and higher slice of results onto the first slice of results. Joining is performed by group: a group that includes all tags (with same values) of the first group is a match.
func (*Context) Lookup ¶
Lookup returns the value for a key in the lookup table for the context's tagset.
type HostData ¶
type HostData struct { CPU struct { Logical int64 `json:",omitempty"` Physical int64 `json:",omitempty"` Used float64 `json:",omitempty"` Processors map[string]string `json:",omitempty"` } Interfaces map[string]*HostInterface LastBoot int64 `json:",omitempty"` LastUpdate int64 `json:",omitempty"` Manufacturer string `json:",omitempty"` Memory struct { Modules map[string]string `json:",omitempty"` Total int64 `json:",omitempty"` Used int64 `json:",omitempty"` } Model string `json:",omitempty"` Name string `json:",omitempty"` OS struct { Caption string `json:",omitempty"` Version string `json:",omitempty"` } SerialNumber string `json:",omitempty"` }
type HostInterface ¶
type HostInterface struct { Description string `json:",omitempty"` IPAddresses []string `json:",omitempty"` Inbps int64 `json:",omitempty"` LinkSpeed int64 `json:",omitempty"` MAC string `json:",omitempty"` Master string `json:",omitempty"` Name string `json:",omitempty"` Outbps int64 `json:",omitempty"` }
type MetadataMetric ¶
type RunHistory ¶
type RunHistory struct { Cache *cache.Cache Start time.Time Context opentsdb.Context GraphiteContext graphite.Context InfluxConfig client.Config Logstash expr.LogstashElasticHosts Events map[expr.AlertKey]*Event // contains filtered or unexported fields }
func (*RunHistory) AtTime ¶
func (rh *RunHistory) AtTime(t time.Time) *RunHistory
AtTime creates a new RunHistory starting at t with the same context and events as rh.
func (*RunHistory) GetUnknownAndUnevaluatedAlertKeys ¶
func (r *RunHistory) GetUnknownAndUnevaluatedAlertKeys(alert string) (unknown, uneval []expr.AlertKey)
type Schedule ¶
type Schedule struct { Conf *conf.Conf Silence map[string]*Silence Group map[time.Time]expr.AlertKeys // Key/value data associated with a metric, tagset, and an additional name Metadata map[metadata.Metakey]*Metavalue Incidents map[uint64]*Incident Search *search.Search AlertStatuses map[string]*AlertStatus //notifications we are currently tracking, potentially with future or repeated actions. Notifications map[expr.AlertKey]map[string]time.Time LastCheck time.Time // contains filtered or unexported fields }
func (*Schedule) ActionNotify ¶
func (s *Schedule) ActionNotify(at ActionType, user, message string, aks []expr.AlertKey)
func (*Schedule) AddNotification ¶
func (*Schedule) AddSilence ¶
func (*Schedule) AlertSuccessful ¶
func (*Schedule) CheckAlert ¶
func (s *Schedule) CheckAlert(T miniprofiler.Timer, r *RunHistory, a *conf.Alert)
func (*Schedule) CheckNotifications ¶
CheckNotifications processes past notification events. It returns the duration until the soonest notification triggers.
func (*Schedule) ClearErrorLine ¶
func (*Schedule) ClearSilence ¶
func (*Schedule) CollectStates ¶
func (s *Schedule) CollectStates()
CollectStates sends various state information to bosun with collect.
func (*Schedule) ExecuteBadTemplate ¶
func (*Schedule) ExecuteBody ¶
func (s *Schedule) ExecuteBody(rh *RunHistory, a *conf.Alert, st *State, isEmail bool) ([]byte, []*conf.Attachment, error)
func (*Schedule) ExecuteSubject ¶
func (*Schedule) GetErrorHistory ¶
func (s *Schedule) GetErrorHistory() map[string]*AlertStatus
func (*Schedule) GetIncidentEvents ¶
func (*Schedule) GetIncidents ¶
func (*Schedule) GetLockStatus ¶
func (*Schedule) GetMetadata ¶
func (*Schedule) GetStateFileBackup ¶
func (*Schedule) LoadTempConfig ¶
Retreive the specified config text from state file.
func (*Schedule) MarshalGroups ¶
func (s *Schedule) MarshalGroups(T miniprofiler.Timer, filter string) (*StateGroups, error)
func (*Schedule) MetadataMetrics ¶
func (s *Schedule) MetadataMetrics(metric string) map[string]*MetadataMetric
func (*Schedule) NewRunHistory ¶
func (*Schedule) PutMetadata ¶
func (*Schedule) RestoreState ¶
RestoreState restores notification and alert state from the file on disk.
func (*Schedule) RunHistory ¶
func (s *Schedule) RunHistory(r *RunHistory)
RunHistory processes an event history and triggers notifications if needed.
func (*Schedule) SaveTempConfig ¶
Saves the provided config text in state file for later access. Returns a hash of the file to be used as a retreival key.
type Silence ¶
type Silence struct {
Start, End time.Time
Alert string
Tags opentsdb.TagSet
Forget bool
User string
Message string
}
func (*Silence) MarshalJSON ¶
type State ¶
type State struct { *Result // Most recent last. History []Event `json:",omitempty"` Actions []Action `json:",omitempty"` Touched time.Time Alert string // helper data since AlertKeys don't serialize to JSON well Tags string // string representation of Group Group opentsdb.TagSet Subject string Body string EmailBody []byte `json:"-"` EmailSubject []byte `json:"-"` Attachments []*conf.Attachment `json:"-"` NeedAck bool Open bool Forgotten bool Unevaluated bool LastLogTime time.Time }
func (*State) AbnormalEvent ¶
AbnormalEvent returns the most recent non-normal event, or nil if none found.
func (*State) AbnormalStatus ¶
AbnormalStatus returns the most recent non-normal status, or StNone if none found.
func (*State) Action ¶
func (s *State) Action(user, message string, t ActionType, timestamp time.Time)
type StateGroup ¶
type StateGroup struct { Active bool `json:",omitempty"` Status Status Silenced bool IsError bool `json:",omitempty"` Subject string `json:",omitempty"` Alert string `json:",omitempty"` AlertKey expr.AlertKey `json:",omitempty"` Ago string `json:",omitempty"` State *State `json:",omitempty"` Children []*StateGroup `json:",omitempty"` }
type StateGroups ¶
type StateGroups struct { Groups struct { NeedAck []*StateGroup `json:",omitempty"` Acknowledged []*StateGroup `json:",omitempty"` } TimeAndDate []int FailingAlerts, UnclosedErrors int }
type States ¶
func (States) GroupSets ¶
GroupSets returns slices of TagSets, grouped by most common ancestor. Those with no shared ancestor are grouped by alert name.
func (States) GroupStates ¶
GroupStates groups by NeedAck, Active, Status, and Silenced.