alerter

package
v0.0.0-...-7cb0e1f Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

The alerter package is responsible for receiving alert messages generated by monitors and dispatching them via the appropriate alerter type such as Slack, PagerDuty and so forth.

While the alerter does not utilize etcd watch functionality, it loads the appropriate alerter config on each message it receives. Due to this, it is important that the alerter is managed by the overwatch package (ie. gets shutdown/restarted during backend problems).

Index

Constants

View Source
const (
	DEFAULT_EMAIL_FROM = "9volt-alerter@example.com"
	DEFAULT_EMAIL_AUTH = "plain"
)
View Source
const (
	EVENT_TYPE_TRIGGER = "trigger"
	EVENT_TYPE_RESOLVE = "resolve"
)
View Source
const (
	RESOLVE_COLOR  = "#36a64f" // green
	WARNING_COLOR  = "#ff9400" // orange
	CRITICAL_COLOR = "#ff0000" // red

	DEFAULT_SLACK_USERNAME = "9volt-bot"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerter

type Alerter struct {
	MemberID       string
	Config         *config.Config
	Log            log.FieldLogger
	Alerters       map[string]IAlerter
	MessageChannel <-chan *Message

	base.Component
}

func New

func New(cfg *config.Config, messageChannel <-chan *Message) *Alerter

func (*Alerter) Start

func (a *Alerter) Start() error

func (*Alerter) Stop

func (a *Alerter) Stop() error

type AlerterConfig

type AlerterConfig struct {
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Options     map[string]string `json:"options"`
}

type Email

type Email struct {
	Config     *config.Config
	Identifier string
}

func NewEmail

func NewEmail(cfg *config.Config) *Email

func (*Email) Identify

func (e *Email) Identify() string

func (*Email) Send

func (e *Email) Send(msg *Message, alerterConfig *AlerterConfig) error

func (*Email) ValidateConfig

func (e *Email) ValidateConfig(alerterConfig *AlerterConfig) error

type IAlerter

type IAlerter interface {
	Send(*Message, *AlerterConfig) error
	Identify() string
	ValidateConfig(*AlerterConfig) error
}

type Message

type Message struct {
	Type        string            // "resolve", "warning", "critical"
	Key         []string          // Keys coming from the monitor config for Critical or WarningAlerters
	Title       string            // Short description of the alert
	Text        string            // In-depth description of the alert state
	Source      string            // Origin of the alert
	Description string            // Original check description so we can be verbose about what we are alerting on
	Count       int               // How many check attempts were made
	Contents    map[string]string // Set checker-specific data (ensuring alerters know how to use the data)
	// contains filtered or unexported fields
}

type Pagerduty

type Pagerduty struct {
	Config     *config.Config
	Identifier string
}

func NewPagerduty

func NewPagerduty(cfg *config.Config) *Pagerduty

func (*Pagerduty) Identify

func (p *Pagerduty) Identify() string

func (*Pagerduty) Send

func (p *Pagerduty) Send(msg *Message, alerterConfig *AlerterConfig) error

func (*Pagerduty) ValidateConfig

func (p *Pagerduty) ValidateConfig(alerterConfig *AlerterConfig) error

type Slack

type Slack struct {
	Config     *config.Config
	Identifier string
}

func NewSlack

func NewSlack(cfg *config.Config) *Slack

func (*Slack) Identify

func (s *Slack) Identify() string

func (*Slack) Send

func (s *Slack) Send(msg *Message, alerterConfig *AlerterConfig) error

func (*Slack) ValidateConfig

func (s *Slack) ValidateConfig(alerterConfig *AlerterConfig) error

Ensure that our alerter config contains all of the necessary information

Jump to

Keyboard shortcuts

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