channels

package
v0.0.0-test Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpsgenieSendTags    = "tags"
	OpsgenieSendDetails = "details"
	OpsgenieSendBoth    = "both"
)
View Source
const (
	FooterIconURL      = "https://grafana.com/assets/img/fav32.png"
	ColorAlertFiring   = "#D63232"
	ColorAlertResolved = "#36a64f"
)
View Source
const TemplateForTestsString = `` /* 1311-byte string literal not displayed */

TemplateForTestsString is the template used for unit tests and integration tests. We have it separate from above default template because any tiny change in the template will require updating almost all channel tests (15+ files) and it's very time consuming.

Variables

View Source
var (
	OpsgenieAlertURL = "https://api.opsgenie.com/v2/alerts"
	ValidPriorities  = map[string]bool{"P1": true, "P2": true, "P3": true, "P4": true, "P5": true}
)
View Source
var DefaultTemplateString = `` /* 2108-byte string literal not displayed */
View Source
var GetBoundary = func() string {
	return ""
}

GetBoundary is used for overriding the behaviour for tests and set a boundary for multipart body. DO NOT set this outside tests.

View Source
var (
	LineNotifyURL string = "https://notify-api.line.me/api/notify"
)
View Source
var (
	PagerdutyEventAPIURL = "https://events.pagerduty.com/v2/enqueue"
)
View Source
var (
	PushoverEndpoint = "https://api.pushover.net/1/messages.json"
)
View Source
var SlackAPIEndpoint = "https://slack.com/api/chat.postMessage"
View Source
var (
	TelegramAPIURL = "https://api.telegram.org/bot%s/sendMessage"
)
View Source
var (
	ThreemaGwBaseURL = "https://msgapi.threema.ch/send_simple"
)

Functions

This section is empty.

Types

type AlertmanagerNotifier

type AlertmanagerNotifier struct {
	*Base
	// contains filtered or unexported fields
}

AlertmanagerNotifier sends alert notifications to the alert manager

func NewAlertmanagerNotifier

NewAlertmanagerNotifier returns a new Alertmanager notifier.

func (*AlertmanagerNotifier) Notify

func (n *AlertmanagerNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends alert notifications to Alertmanager.

func (*AlertmanagerNotifier) SendResolved

func (n *AlertmanagerNotifier) SendResolved() bool

type Base

type Base struct {
	Name                  string
	Type                  string
	UID                   string
	IsDefault             bool
	DisableResolveMessage bool
	// contains filtered or unexported fields
}

Base is the base implementation of a notifier. It contains the common fields across all notifier types.

func NewBase

func NewBase(model *models.AlertNotification) *Base

func (*Base) GetDisableResolveMessage

func (n *Base) GetDisableResolveMessage() bool

type DingDingNotifier

type DingDingNotifier struct {
	*Base
	MsgType string
	URL     string
	Message string
	// contains filtered or unexported fields
}

DingDingNotifier is responsible for sending alert notifications to ding ding.

func NewDingDingNotifier

func NewDingDingNotifier(model *NotificationChannelConfig, t *template.Template) (*DingDingNotifier, error)

NewDingDingNotifier is the constructor for the Dingding notifier

func (*DingDingNotifier) Notify

func (dd *DingDingNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends the alert notification to dingding.

func (*DingDingNotifier) SendResolved

func (dd *DingDingNotifier) SendResolved() bool

type DiscordNotifier

type DiscordNotifier struct {
	*Base

	Content            string
	AvatarURL          string
	WebhookURL         string
	UseDiscordUsername bool
	// contains filtered or unexported fields
}

func (DiscordNotifier) Notify

func (d DiscordNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

func (DiscordNotifier) SendResolved

func (d DiscordNotifier) SendResolved() bool

type EmailNotifier

type EmailNotifier struct {
	*Base
	Addresses   []string
	SingleEmail bool
	Message     string
	// contains filtered or unexported fields
}

EmailNotifier is responsible for sending alert notifications over email.

func NewEmailNotifier

func NewEmailNotifier(model *NotificationChannelConfig, t *template.Template) (*EmailNotifier, error)

NewEmailNotifier is the constructor function for the EmailNotifier.

func (*EmailNotifier) Notify

func (en *EmailNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends the alert notification.

func (*EmailNotifier) SendResolved

func (en *EmailNotifier) SendResolved() bool

type ExtendedAlert

type ExtendedAlert struct {
	Status       string      `json:"status"`
	Labels       template.KV `json:"labels"`
	Annotations  template.KV `json:"annotations"`
	StartsAt     time.Time   `json:"startsAt"`
	EndsAt       time.Time   `json:"endsAt"`
	GeneratorURL string      `json:"generatorURL"`
	Fingerprint  string      `json:"fingerprint"`
	SilenceURL   string      `json:"silenceURL"`
	DashboardURL string      `json:"dashboardURL"`
	PanelURL     string      `json:"panelURL"`
	ValueString  string      `json:"valueString"`
}

type ExtendedAlerts

type ExtendedAlerts []ExtendedAlert

func (ExtendedAlerts) Firing

func (as ExtendedAlerts) Firing() []ExtendedAlert

Firing returns the subset of alerts that are firing.

func (ExtendedAlerts) Resolved

func (as ExtendedAlerts) Resolved() []ExtendedAlert

Resolved returns the subset of alerts that are resolved.

type ExtendedData

type ExtendedData struct {
	Receiver string         `json:"receiver"`
	Status   string         `json:"status"`
	Alerts   ExtendedAlerts `json:"alerts"`

	GroupLabels       template.KV `json:"groupLabels"`
	CommonLabels      template.KV `json:"commonLabels"`
	CommonAnnotations template.KV `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

func ExtendData

func ExtendData(data *template.Data, logger log.Logger) *ExtendedData

func TmplText

func TmplText(ctx context.Context, tmpl *template.Template, alerts []*types.Alert, l log.Logger, tmplErr *error) (func(string) string, *ExtendedData)

type GetDecryptedValueFn

type GetDecryptedValueFn func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string

GetDecryptedValueFn is a function that returns the decrypted value of the given key. If the key is not present, then it returns the fallback value.

type GoogleChatNotifier

type GoogleChatNotifier struct {
	*Base
	URL string
	// contains filtered or unexported fields
}

GoogleChatNotifier is responsible for sending alert notifications to Google chat.

func (*GoogleChatNotifier) Notify

func (gcn *GoogleChatNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to Google Chat.

func (*GoogleChatNotifier) SendResolved

func (gcn *GoogleChatNotifier) SendResolved() bool

type KafkaNotifier

type KafkaNotifier struct {
	*Base
	Endpoint string
	Topic    string
	// contains filtered or unexported fields
}

KafkaNotifier is responsible for sending alert notifications to Kafka.

func NewKafkaNotifier

func NewKafkaNotifier(model *NotificationChannelConfig, t *template.Template) (*KafkaNotifier, error)

NewKafkaNotifier is the constructor function for the Kafka notifier.

func (*KafkaNotifier) Notify

func (kn *KafkaNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends the alert notification.

func (*KafkaNotifier) SendResolved

func (kn *KafkaNotifier) SendResolved() bool

type LineNotifier

type LineNotifier struct {
	*Base
	Token string
	// contains filtered or unexported fields
}

LineNotifier is responsible for sending alert notifications to LINE.

func NewLineNotifier

NewLineNotifier is the constructor for the LINE notifier

func (*LineNotifier) Notify

func (ln *LineNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to LINE

func (*LineNotifier) SendResolved

func (ln *LineNotifier) SendResolved() bool

type NotificationChannelConfig

type NotificationChannelConfig struct {
	OrgID                 int64             // only used internally
	UID                   string            `json:"uid"`
	Name                  string            `json:"name"`
	Type                  string            `json:"type"`
	DisableResolveMessage bool              `json:"disableResolveMessage"`
	Settings              *simplejson.Json  `json:"settings"`
	SecureSettings        map[string][]byte `json:"secureSettings"`
}

type OpsgenieNotifier

type OpsgenieNotifier struct {
	*Base
	APIKey           string
	APIUrl           string
	AutoClose        bool
	OverridePriority bool
	SendTagsAs       string
	// contains filtered or unexported fields
}

OpsgenieNotifier is responsible for sending alert notifications to Opsgenie.

func NewOpsgenieNotifier

NewOpsgenieNotifier is the constructor for the Opsgenie notifier

func (*OpsgenieNotifier) Notify

func (on *OpsgenieNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to Opsgenie

func (*OpsgenieNotifier) SendResolved

func (on *OpsgenieNotifier) SendResolved() bool

type PagerdutyNotifier

type PagerdutyNotifier struct {
	*Base
	Key           string
	Severity      string
	CustomDetails map[string]string
	Class         string
	Component     string
	Group         string
	Summary       string
	// contains filtered or unexported fields
}

PagerdutyNotifier is responsible for sending alert notifications to pagerduty

func NewPagerdutyNotifier

NewPagerdutyNotifier is the constructor for the PagerDuty notifier

func (*PagerdutyNotifier) Notify

func (pn *PagerdutyNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to PagerDuty

func (*PagerdutyNotifier) SendResolved

func (pn *PagerdutyNotifier) SendResolved() bool

type PushoverNotifier

type PushoverNotifier struct {
	*Base
	UserKey          string
	APIToken         string
	AlertingPriority int
	OKPriority       int
	Retry            int
	Expire           int
	Device           string
	AlertingSound    string
	OKSound          string
	Upload           bool
	Message          string
	// contains filtered or unexported fields
}

PushoverNotifier is responsible for sending alert notifications to Pushover

func NewPushoverNotifier

NewSlackNotifier is the constructor for the Slack notifier

func (*PushoverNotifier) Notify

func (pn *PushoverNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to Slack.

func (*PushoverNotifier) SendResolved

func (pn *PushoverNotifier) SendResolved() bool

type SensuGoNotifier

type SensuGoNotifier struct {
	*Base

	URL       string
	Entity    string
	Check     string
	Namespace string
	Handler   string
	APIKey    string
	Message   string
	// contains filtered or unexported fields
}

func NewSensuGoNotifier

NewSensuGoNotifier is the constructor for the SensuGo notifier

func (*SensuGoNotifier) Notify

func (sn *SensuGoNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to Sensu Go

func (*SensuGoNotifier) SendResolved

func (sn *SensuGoNotifier) SendResolved() bool

type SlackNotifier

type SlackNotifier struct {
	*Base

	URL            *url.URL
	Username       string
	IconEmoji      string
	IconURL        string
	Recipient      string
	Text           string
	Title          string
	MentionUsers   []string
	MentionGroups  []string
	MentionChannel string
	Token          string
	// contains filtered or unexported fields
}

SlackNotifier is responsible for sending alert notification to Slack.

func NewSlackNotifier

NewSlackNotifier is the constructor for the Slack notifier

func (*SlackNotifier) Notify

func (sn *SlackNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to Slack.

func (*SlackNotifier) SendResolved

func (sn *SlackNotifier) SendResolved() bool

type TeamsNotifier

type TeamsNotifier struct {
	*Base
	URL     string
	Message string
	// contains filtered or unexported fields
}

TeamsNotifier is responsible for sending alert notifications to Microsoft teams.

func NewTeamsNotifier

func NewTeamsNotifier(model *NotificationChannelConfig, t *template.Template) (*TeamsNotifier, error)

NewTeamsNotifier is the constructor for Teams notifier.

func (*TeamsNotifier) Notify

func (tn *TeamsNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to Microsoft teams.

func (*TeamsNotifier) SendResolved

func (tn *TeamsNotifier) SendResolved() bool

type TelegramNotifier

type TelegramNotifier struct {
	*Base
	BotToken string
	ChatID   string
	Message  string
	// contains filtered or unexported fields
}

TelegramNotifier is responsible for sending alert notifications to Telegram.

func NewTelegramNotifier

NewTelegramNotifier is the constructor for the Telegram notifier

func (*TelegramNotifier) Notify

func (tn *TelegramNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to Telegram.

func (*TelegramNotifier) SendResolved

func (tn *TelegramNotifier) SendResolved() bool

type ThreemaNotifier

type ThreemaNotifier struct {
	*Base
	GatewayID   string
	RecipientID string
	APISecret   string
	// contains filtered or unexported fields
}

ThreemaNotifier is responsible for sending alert notifications to Threema.

func NewThreemaNotifier

NewThreemaNotifier is the constructor for the Threema notifier

func (*ThreemaNotifier) Notify

func (tn *ThreemaNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify send an alert notification to Threema

func (*ThreemaNotifier) SendResolved

func (tn *ThreemaNotifier) SendResolved() bool

type VictoropsNotifier

type VictoropsNotifier struct {
	*Base
	URL         string
	MessageType string
	// contains filtered or unexported fields
}

VictoropsNotifier defines URL property for Victorops REST API and handles notification process by formatting POST body according to Victorops specifications (http://victorops.force.com/knowledgebase/articles/Integration/Alert-Ingestion-API-Documentation/)

func NewVictoropsNotifier

func NewVictoropsNotifier(model *NotificationChannelConfig, t *template.Template) (*VictoropsNotifier, error)

NewVictoropsNotifier creates an instance of VictoropsNotifier that handles posting notifications to Victorops REST API

func (*VictoropsNotifier) Notify

func (vn *VictoropsNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends notification to Victorops via POST to URL endpoint

func (*VictoropsNotifier) SendResolved

func (vn *VictoropsNotifier) SendResolved() bool

type WebhookNotifier

type WebhookNotifier struct {
	*Base
	URL        string
	User       string
	Password   string
	HTTPMethod string
	MaxAlerts  int
	// contains filtered or unexported fields
}

WebhookNotifier is responsible for sending alert notifications as webhooks.

func NewWebHookNotifier

NewWebHookNotifier is the constructor for the WebHook notifier.

func (*WebhookNotifier) Notify

func (wn *WebhookNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify implements the Notifier interface.

func (*WebhookNotifier) SendResolved

func (wn *WebhookNotifier) SendResolved() bool

Jump to

Keyboard shortcuts

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