Documentation ¶
Index ¶
- func GetNotificationChains(c *Conf, n map[string]*Notification) [][]string
- func Send(e *email.Email, addr, username, password string) error
- func SendMail(addr, username, password string, from string, to []string, msg []byte) error
- type Alert
- type ByteSize
- type Conf
- func (c *Conf) AlertSquelched(a *Alert) func(opentsdb.TagSet) bool
- func (c *Conf) AnnotateEnabled() bool
- func (c *Conf) Expand(v string, vars map[string]string, ignoreBadExpand bool) string
- func (c *Conf) Funcs() map[string]eparse.Func
- func (c *Conf) GraphiteContext() graphite.Context
- func (c *Conf) MakeLink(path string, v *url.Values) string
- func (c *Conf) NewExpr(s string) *expr.Expr
- func (c *Conf) Squelched(a *Alert, tags opentsdb.TagSet) bool
- func (c *Conf) TSDBContext() opentsdb.Context
- type Entry
- type ExprEntry
- type ExprLookup
- type Lookup
- type Macro
- type Notification
- func (n *Notification) DoEmail(subject, body []byte, c *Conf, ak string, attachments ...*models.Attachment)
- func (n *Notification) DoGet(ak string)
- func (n *Notification) DoPost(payload []byte, ak string)
- func (n *Notification) DoPrint(payload string)
- func (n *Notification) GetPayload(subject, body string) (payload []byte)
- func (n *Notification) Notify(subject, body string, emailsubject, emailbody []byte, c *Conf, ak string, ...)
- type Notifications
- type Squelch
- type Squelches
- type Template
- type Vars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNotificationChains ¶
func GetNotificationChains(c *Conf, n map[string]*Notification) [][]string
GetNotificationChains returns the warn or crit notification chains for a configured alert. Each chain is a list of notification names. If a notification name as already been seen in the chain it ends the list with the notification name with a of "..." which indicates that the chain will loop.
func Send ¶
Send an email using the given host and SMTP auth (optional), returns any error thrown by smtp.SendMail. This function merges the To, Cc, and Bcc fields and calls the smtp.SendMail function using the Email.Bytes() output as the message.
Types ¶
type Alert ¶
type Alert struct { Text string Vars *Template `json:"-"` Name string Crit *expr.Expr `json:",omitempty"` Warn *expr.Expr `json:",omitempty"` Depends *expr.Expr `json:",omitempty"` Squelch Squelches `json:"-"` CritNotification *Notifications WarnNotification *Notifications Unknown time.Duration MaxLogFrequency time.Duration IgnoreUnknown bool UnknownsNormal bool UnjoinedOK bool `json:",omitempty"` Log bool RunEvery int // contains filtered or unexported fields }
type Conf ¶
type Conf struct { Vars Name string // Config file name CheckFrequency time.Duration // Time between alert checks: 5m DefaultRunEvery int // Default number of check intervals to run each alert: 1 HTTPListen string // Web server listen address: :80 Hostname string RelayListen string // OpenTSDB relay listen address: :4242 SMTPHost string // SMTP address: ny-mail:25 SMTPUsername string // SMTP username SMTPPassword string // SMTP password Ping bool PingDuration time.Duration // Duration from now to stop pinging hosts based on time since the host tag was touched EmailFrom string StateFile string LedisDir string LedisBindAddr string RedisHost string RedisDb int RedisPassword string TimeAndDate []int // timeanddate.com cities list ResponseLimit int64 SearchSince opentsdb.Duration UnknownTemplate *Template UnknownThreshold int Templates map[string]*Template Alerts map[string]*Alert Notifications map[string]*Notification `json:"-"` RawText string Macros map[string]*Macro Lookups map[string]*Lookup Squelch Squelches `json:"-"` Quiet bool SkipLast bool NoSleep bool ShortURLKey string InternetProxy string MinGroupSize int TSDBHost string // OpenTSDB relay and query destination: ny-devtsdb04:4242 TSDBVersion *opentsdb.Version // If set to 2.2 , enable passthrough of wildcards and filters, and add support for groupby GraphiteHost string // Graphite query host: foo.bar.baz GraphiteHeaders []string // extra http headers when querying graphite. LogstashElasticHosts expr.LogstashElasticHosts // CSV Elastic Hosts (All part of the same cluster) that stores logstash documents, i.e http://ny-elastic01:9200. Only works with elastc pre-v2, and expects the schema to be logstash's default. ElasticHosts expr.ElasticHosts // CSV Elastic Hosts (All part of the same cluster), i.e http://ny-elastic01:9200. Only works with elastic v2+, and unlike logstash it is designed to be able to use various elastic schemas. InfluxConfig client.Config AnnotateElasticHosts []string // CSV of Elastic Hosts, currently the only backend in annotate AnnotateIndex string // name of index / table // contains filtered or unexported fields }
func (*Conf) AnnotateEnabled ¶
func (*Conf) GraphiteContext ¶
GraphiteContext returns a Graphite context. A nil context is returned if GraphiteHost is not set.
func (*Conf) TSDBContext ¶
TSDBContext returns an OpenTSDB context limited to c.ResponseLimit. A nil context is returned if TSDBHost is not set.
type ExprLookup ¶
TODO: remove this and merge it with Lookup
type Notification ¶
type Notification struct { Text string Vars Name string Email []*mail.Address Post, Get *url.URL Body *ttemplate.Template Print bool Next *Notification Timeout time.Duration ContentType string RunOnActions bool UseBody bool // contains filtered or unexported fields }
func (*Notification) DoEmail ¶
func (n *Notification) DoEmail(subject, body []byte, c *Conf, ak string, attachments ...*models.Attachment)
func (*Notification) DoGet ¶
func (n *Notification) DoGet(ak string)
func (*Notification) DoPost ¶
func (n *Notification) DoPost(payload []byte, ak string)
func (*Notification) DoPrint ¶
func (n *Notification) DoPrint(payload string)
func (*Notification) GetPayload ¶
func (n *Notification) GetPayload(subject, body string) (payload []byte)
func (*Notification) Notify ¶
func (n *Notification) Notify(subject, body string, emailsubject, emailbody []byte, c *Conf, ak string, attachments ...*models.Attachment)
type Notifications ¶
type Notifications struct { Notifications map[string]*Notification `json:"-"` // Table key -> table Lookups map[string]*Lookup }
func (*Notifications) Get ¶
func (ns *Notifications) Get(c *Conf, tags opentsdb.TagSet) map[string]*Notification
Get returns the set of notifications based on given tags.