notifier

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2017 License: GPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package notifier manages notifications for consul-alerts

Package notifier manages notifications for consul-alerts

Index

Constants

View Source
const (
	SYSTEM_HEALTHY  string = "HEALTHY"
	SYSTEM_UNSTABLE string = "UNSTABLE"
	SYSTEM_CRITICAL string = "CRITICAL"
)

Variables

This section is empty.

Functions

func MakeBody added in v0.4.0

func MakeBody(messages Messages) string

func MakeSubject added in v0.4.0

func MakeSubject(messages Messages) string

Types

type AwsSnsNotifier added in v0.4.0

type AwsSnsNotifier struct {
	Enabled  bool
	Region   string `json:"region"`
	TopicArn string `json:"topic-arn"`
}

func (*AwsSnsNotifier) Copy added in v0.5.0

func (awssns *AwsSnsNotifier) Copy() Notifier

func (*AwsSnsNotifier) NotifierName added in v0.4.0

func (awssns *AwsSnsNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*AwsSnsNotifier) Notify added in v0.4.0

func (awssns *AwsSnsNotifier) Notify(messages Messages) bool

func (*AwsSnsNotifier) Send added in v0.4.0

func (awssns *AwsSnsNotifier) Send(subject string, message string) bool

type EmailData

type EmailData struct {
	ClusterName  string
	SystemStatus string
	FailCount    int
	WarnCount    int
	PassCount    int
	Nodes        map[string]Messages
}

func (EmailData) IsCritical

func (e EmailData) IsCritical() bool

func (EmailData) IsPassing

func (e EmailData) IsPassing() bool

func (EmailData) IsWarning

func (e EmailData) IsWarning() bool

type EmailNotifier

type EmailNotifier struct {
	ClusterName string `json:"cluster-name"`
	Enabled     bool
	Template    string   `json:"template"`
	Url         string   `json:"url"`
	Port        int      `json:"port"`
	Username    string   `json:"username"`
	Password    string   `json:"password"`
	SenderAlias string   `json:"sender-alias"`
	SenderEmail string   `json:"sender-email"`
	Receivers   []string `json:"receivers"`
	OnePerAlert bool     `json:"one-per-alert"`
	OnePerNode  bool     `json:"one-per-node"`
}

func (*EmailNotifier) Copy added in v0.5.0

func (emailNotifier *EmailNotifier) Copy() Notifier

func (*EmailNotifier) NotifierName added in v0.4.0

func (emailNotifier *EmailNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*EmailNotifier) Notify

func (emailNotifier *EmailNotifier) Notify(alerts Messages) bool

Notify sends messages to the endpoint notifier

type HipChatNotifier added in v0.3.1

type HipChatNotifier struct {
	Enabled     bool
	ClusterName string `json:"cluster-name"`
	RoomId      string `json:"room-id"`
	AuthToken   string `json:"auth-token"`
	BaseURL     string `json:"base-url"`
	From        string `json:"from"`
}

func (*HipChatNotifier) Copy added in v0.5.0

func (notifier *HipChatNotifier) Copy() Notifier

func (*HipChatNotifier) NotifierName added in v0.4.0

func (notifier *HipChatNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*HipChatNotifier) Notify added in v0.3.1

func (notifier *HipChatNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

type InfluxdbNotifier

type InfluxdbNotifier struct {
	Enabled    bool
	Host       string `json:"host"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	Database   string `json:"database"`
	SeriesName string `json:"series-name"`
}

func (*InfluxdbNotifier) Copy added in v0.5.0

func (influxdb *InfluxdbNotifier) Copy() Notifier

func (*InfluxdbNotifier) NotifierName added in v0.4.0

func (influxdb *InfluxdbNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*InfluxdbNotifier) Notify

func (influxdb *InfluxdbNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

type LogNotifier

type LogNotifier struct {
	Enabled bool
	Path    string `json:"path"`
}

func (*LogNotifier) Copy added in v0.5.0

func (logNotifier *LogNotifier) Copy() Notifier

func (*LogNotifier) NotifierName added in v0.4.0

func (logNotifier *LogNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*LogNotifier) Notify

func (logNotifier *LogNotifier) Notify(alerts Messages) bool

Notify sends messages to the endpoint notifier

type MattermostAuthInfo added in v0.5.0

type MattermostAuthInfo struct {
	UserID             string    `json:"id"`
	CreateAt           int64     `json:"create_at"`
	UpdateAt           int64     `json:"update_at"`
	DeleteAt           int64     `json:"delete_at"`
	UserName           string    `json:"username"`
	AuthData           string    `json:"auth_data"`
	AuthService        string    `json:"auth_service"`
	Email              string    `json:"email"`
	EmailVerified      bool      `json:"email_verified"`
	NickName           string    `json:"nickname"`
	FirstName          string    `json:"first_name"`
	LastName           string    `json:"last_name"`
	Roles              string    `json:"roles"`
	AllowMarketing     bool      `json:"allow_marketing"`
	NotifyProps        StringMap `json:"notify_props"`
	Props              StringMap `json:"props"`
	LastPasswordUpdate int64     `json:"last_password_update"`
	LastPictureUpdate  int64     `json:"last_picture_update"`
}

type MattermostChannelInfo added in v0.5.0

type MattermostChannelInfo struct {
	ChannelID     string `json:"id"`
	CreateAt      int64  `json:"create_at"`
	UpdateAt      int64  `json:"update_at"`
	DeleteAt      int64  `json:"delete_at"`
	TeamID        string `json:"team_id"`
	Type          string `json:"type"`
	DisplayName   string `json:"display_name"`
	Name          string `json:"name"`
	Header        string `json:"header"`
	Purpose       string `json:"purpose"`
	LastPostAt    int64  `json:"last_post_at"`
	TotalMsgCount int64  `json:"total_msg_count"`
	ExtraUpdateAt int64  `json:"extra_update_at"`
	CreatorID     string `json:"creator_id"`
}

type MattermostChannelList added in v0.5.0

type MattermostChannelList struct {
	Channels []MattermostChannelInfo
}

type MattermostLoginInfo added in v0.5.0

type MattermostLoginInfo struct {
	LoginID  string `json:"login_id"`
	Password string `json:"password"`
}

type MattermostNotifier added in v0.5.0

type MattermostNotifier struct {
	ClusterName string
	Url         string
	UserName    string
	Password    string
	Team        string
	Channel     string
	Detailed    bool
	NotifName   string
	Enabled     bool

	/* Filled in after authentication */
	Initialized bool
	Token       string
	TeamID      string
	UserID      string
	ChannelID   string
	Text        string
}

func (*MattermostNotifier) Authenticate added in v0.5.0

func (mattermost *MattermostNotifier) Authenticate() bool

func (*MattermostNotifier) Copy added in v0.5.0

func (mattermost *MattermostNotifier) Copy() Notifier

func (*MattermostNotifier) GetAllTeams added in v0.5.0

func (mattermost *MattermostNotifier) GetAllTeams(teams *[]MattermostTeamInfo) bool

func (*MattermostNotifier) GetChannels added in v0.5.0

func (mattermost *MattermostNotifier) GetChannels(teamID string, channels *[]MattermostChannelInfo) bool

func (*MattermostNotifier) GetMe added in v0.5.0

func (mattermost *MattermostNotifier) GetMe(me *MattermostUserInfo) bool

func (*MattermostNotifier) GetTeam added in v0.5.0

func (mattermost *MattermostNotifier) GetTeam(teamID string, teamInfo *MattermostTeamInfo) bool

func (*MattermostNotifier) GetURL added in v0.5.0

func (mattermost *MattermostNotifier) GetURL() string

func (*MattermostNotifier) GetUser added in v0.5.0

func (mattermost *MattermostNotifier) GetUser(userID string, userInfo *MattermostUserInfo) bool

func (*MattermostNotifier) Init added in v0.5.0

func (mattermost *MattermostNotifier) Init() bool

func (*MattermostNotifier) NotifierName added in v0.5.0

func (mattermost *MattermostNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*MattermostNotifier) Notify added in v0.5.0

func (mattermost *MattermostNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

func (*MattermostNotifier) PostMessage added in v0.5.0

func (mattermost *MattermostNotifier) PostMessage(teamID string, channelID string, postInfo *MattermostPostInfo) bool

type MattermostPostInfo added in v0.5.0

type MattermostPostInfo struct {
	PostID        string    `json:"id"`
	CreateAt      int64     `json:"create_at"`
	UpdateAt      int64     `json:"update_at"`
	DeleteAt      int64     `json:"delete_at"`
	UserID        string    `json:"user_id"`
	ChannelID     string    `json:"channel_id"`
	RootID        string    `json:"root_id"`
	ParentID      string    `json:"parent_id"`
	OriginalID    string    `json:"original_id"`
	Message       string    `json:"message"`
	Type          string    `json:"type"`
	Props         StringMap `json:"props"`
	Hashtags      string    `json:"hashtags"`
	Filenames     StringMap `json:"filenames"`
	PendingPostID string    `json:"pending_post_id"`
}

type MattermostTeamInfo added in v0.5.0

type MattermostTeamInfo struct {
	TeamID          string `json:"id"`
	CreateAt        int64  `json:"create_at"`
	UpdateAt        int64  `json:"update_at"`
	DeleteAt        int64  `json:"delete_at"`
	DisplayName     string `json:"display_name"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	Type            string `json:"type"`
	AllowedDomains  string `json:"allowed_domains"`
	InviteID        string `json:"invite_id"`
	AllowOpenInvite bool   `json:"allow_open_invite"`
}

type MattermostUserInfo added in v0.5.0

type MattermostUserInfo struct {
	UserID             string    `json:"id"`
	CreateAt           int64     `json:"create_at"`
	UpdateAt           int64     `json:"update_at"`
	DeleteAt           int64     `json:"delete_at"`
	Username           string    `json:"username"`
	FirstName          string    `json:"first_name"`
	LastName           string    `json:"last_name"`
	Nickname           string    `json:"nickname"`
	Email              string    `json:"email"`
	EmailVerified      bool      `json:"email_verified"`
	Password           string    `json:"password"`
	AuthData           *string   `json:"auth_data"`
	AuthService        string    `json:"auth_service"`
	Roles              string    `json:"roles"`
	NotifyProps        StringMap `json:"notify_props"`
	Props              StringMap `json:"props,omitempty"`
	LastPasswordUpdate int64     `json:"last_password_update"`
	LastPictureUpdate  int64     `json:"last_picture_update"`
	FailedAttempts     int       `json:"failed_attempts"`
	MfaActive          bool      `json:"mfa_active"`
	MfaSecret          string    `json:"mfa_secret"`
}

type Message

type Message struct {
	Node         string
	ServiceId    string
	Service      string
	CheckId      string
	Check        string
	Status       string
	Output       string
	Notes        string
	Interval     int
	RmdCheck     time.Time
	NotifList    map[string]bool
	VarOverrides Notifiers
	Timestamp    time.Time
}

func (Message) IsCritical

func (m Message) IsCritical() bool

func (Message) IsPassing

func (m Message) IsPassing() bool

func (Message) IsWarning

func (m Message) IsWarning() bool

type Messages

type Messages []Message

func (Messages) Summary

func (m Messages) Summary() (overallStatus string, pass, warn, fail int)

type Notifier

type Notifier interface {
	Notify(alerts Messages) bool
	NotifierName() string
	Copy() Notifier
}

type Notifiers added in v0.5.0

type Notifiers struct {
	Email      *EmailNotifier      `json:"email"`
	Log        *LogNotifier        `json:"log"`
	Influxdb   *InfluxdbNotifier   `json:"influxdb"`
	Slack      *SlackNotifier      `json:"slack"`
	Mattermost *MattermostNotifier `json:"mattermost"`
	PagerDuty  *PagerDutyNotifier  `json:"pagerduty"`
	HipChat    *HipChatNotifier    `json:"hipchat"`
	OpsGenie   *OpsGenieNotifier   `json:"opsgenie"`
	AwsSns     *AwsSnsNotifier     `json:"awssns"`
	VictorOps  *VictorOpsNotifier  `json:"victorops"`
	Custom     []string            `json:"custom"`
}

func (Notifiers) GetNotifier added in v0.5.0

func (n Notifiers) GetNotifier(name string) (Notifier, bool)

type OpsGenieNotifier added in v0.3.3

type OpsGenieNotifier struct {
	Enabled     bool
	ClusterName string `json:"cluster-name"`
	ApiKey      string `json:"api-key"`
}

func (*OpsGenieNotifier) Copy added in v0.5.0

func (opsgenie *OpsGenieNotifier) Copy() Notifier

func (*OpsGenieNotifier) NotifierName added in v0.4.0

func (opsgenie *OpsGenieNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*OpsGenieNotifier) Notify added in v0.3.3

func (opsgenie *OpsGenieNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

type PagerDutyNotifier added in v0.1.2

type PagerDutyNotifier struct {
	Enabled    bool
	ServiceKey string `json:"service-key"`
	ClientName string `json:"client-name"`
	ClientUrl  string `json:"client-url"`
}

func (*PagerDutyNotifier) Copy added in v0.5.0

func (pd *PagerDutyNotifier) Copy() Notifier

func (*PagerDutyNotifier) NotifierName added in v0.4.0

func (pd *PagerDutyNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*PagerDutyNotifier) Notify added in v0.1.2

func (pd *PagerDutyNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

type SlackNotifier

type SlackNotifier struct {
	ClusterName string       `json:"-"`
	Url         string       `json:"-"`
	Channel     string       `json:"channel"`
	Username    string       `json:"username"`
	IconUrl     string       `json:"icon_url"`
	IconEmoji   string       `json:"icon_emoji"`
	Text        string       `json:"text,omitempty"`
	Attachments []attachment `json:"attachments,omitempty"`
	Detailed    bool         `json:"-"`
	Enabled     bool
}

func (*SlackNotifier) Copy added in v0.5.0

func (slack *SlackNotifier) Copy() Notifier

func (*SlackNotifier) NotifierName added in v0.4.0

func (slack *SlackNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*SlackNotifier) Notify

func (slack *SlackNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

type StringMap added in v0.5.0

type StringMap map[string]string

type VictorOpsEvent added in v0.4.0

type VictorOpsEvent struct {
	// Explicitly listed by http://victorops.force.com/knowledgebase/articles/Integration/Alert-Ingestion-API-Documentation/
	MessageType       string `json:"message_type"`
	EntityID          string `json:"entity_id"`
	Timestamp         uint32 `json:"timestamp"`
	StateMessage      string `json:"state_message"`
	MonitoringTool    string `json:"monitoring_tool"`
	EntityDisplayName string `json:"entity_display_name"`

	// Helpful fields from http://victorops.force.com/knowledgebase/articles/Getting_Started/Incident-Fields-Glossary/?l=en_US&fs=RelatedArticle
	HostName    string `json:"host_name"`
	MonitorName string `json:"monitor_name"`

	// VictorOps lets you add arbitrary fields to help custom notification logic, so we'll set
	// node, service, service ID, check, and check ID
	ConsulNode      string `json:"consul_node"`
	ConsulService   string `json:"consul_service,omitempty"`
	ConsulServiceID string `json:"consul_service_id,omitempty"`
	ConsulCheck     string `json:"consul_check"`
	ConsulCheckID   string `json:"consul_check_id"`
}

VictorOpsEvent represents the options we'll pass to the VictorOps API

type VictorOpsNotifier added in v0.4.0

type VictorOpsNotifier struct {
	Enabled    bool
	APIKey     string `json:"api-key"`
	RoutingKey string `json:"routing-key"`
}

VictorOpsNotifier provides configuration options for the VictorOps notifier

func (*VictorOpsNotifier) Copy added in v0.5.0

func (vo *VictorOpsNotifier) Copy() Notifier

func (*VictorOpsNotifier) NotifierName added in v0.4.0

func (vo *VictorOpsNotifier) NotifierName() string

NotifierName provides name for notifier selection

func (*VictorOpsNotifier) Notify added in v0.4.0

func (vo *VictorOpsNotifier) Notify(messages Messages) bool

Notify sends messages to the endpoint notifier

Jump to

Keyboard shortcuts

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