conf

package
v0.0.0-...-fd35013 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2016 License: MIT Imports: 33 Imported by: 0

Documentation

Index

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

func Send(e *email.Email, addr, username, password string) error

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.

func SendMail

func SendMail(addr, username, password string, from string, to []string, msg []byte) error

SendMail connects to the server at addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.

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 ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

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 New

func New(name, text string) (c *Conf, err error)

func ParseFile

func ParseFile(fname string) (*Conf, error)

func (*Conf) AlertSquelched

func (c *Conf) AlertSquelched(a *Alert) func(opentsdb.TagSet) bool

func (*Conf) AnnotateEnabled

func (c *Conf) AnnotateEnabled() bool

func (*Conf) Expand

func (c *Conf) Expand(v string, vars map[string]string, ignoreBadExpand bool) string

func (*Conf) Funcs

func (c *Conf) Funcs() map[string]eparse.Func

func (*Conf) GraphiteContext

func (c *Conf) GraphiteContext() graphite.Context

GraphiteContext returns a Graphite context. A nil context is returned if GraphiteHost is not set.

func (c *Conf) MakeLink(path string, v *url.Values) string

func (*Conf) NewExpr

func (c *Conf) NewExpr(s string) *expr.Expr

func (*Conf) Squelched

func (c *Conf) Squelched(a *Alert, tags opentsdb.TagSet) bool

func (*Conf) TSDBContext

func (c *Conf) TSDBContext() opentsdb.Context

TSDBContext returns an OpenTSDB context limited to c.ResponseLimit. A nil context is returned if TSDBHost is not set.

type Entry

type Entry struct {
	*ExprEntry
	Def  string
	Name string
}

type ExprEntry

type ExprEntry struct {
	AlertKey models.AlertKey
	Values   map[string]string
}

type ExprLookup

type ExprLookup struct {
	Tags    []string
	Entries []*ExprEntry
}

TODO: remove this and merge it with Lookup

func (*ExprLookup) Get

func (lookup *ExprLookup) Get(key string, tag opentsdb.TagSet) (value string, ok bool)

type Lookup

type Lookup struct {
	Text    string
	Name    string
	Tags    []string
	Entries []*Entry
}

func (*Lookup) ToExpr

func (lookup *Lookup) ToExpr() *ExprLookup

type Macro

type Macro struct {
	Text  string
	Pairs []nodePair
	Name  string
}

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.

type Squelch

type Squelch map[string]*regexp.Regexp

func (Squelch) Squelched

func (s Squelch) Squelched(tags opentsdb.TagSet) bool

type Squelches

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

func (*Squelches) Add

func (s *Squelches) Add(v string) error

func (*Squelches) Squelched

func (s *Squelches) Squelched(tags opentsdb.TagSet) bool

type Template

type Template struct {
	Text string
	Vars
	Name    string
	Body    *htemplate.Template `json:"-"`
	Subject *ttemplate.Template `json:"-"`
	// contains filtered or unexported fields
}

type Vars

type Vars map[string]string

Directories

Path Synopsis
Package parse builds parse trees for configurations as defined by conf.
Package parse builds parse trees for configurations as defined by conf.

Jump to

Keyboard shortcuts

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