notify

package
v0.0.0-...-de1800b Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const MinTimeout = 10 * time.Second

MinTimeout is the minimum timeout that is set for the context of a call to a notification pipeline.

Variables

This section is empty.

Functions

func FiringAlerts

func FiringAlerts(ctx context.Context) ([]uint64, bool)

FiringAlerts extracts a slice of firing alerts from the context. Iff none exists, the second argument is false.

func GroupKey

func GroupKey(ctx context.Context) (string, bool)

GroupKey extracts a group key from the context. Iff none exists, the second argument is false.

func GroupLabels

func GroupLabels(ctx context.Context) (model.LabelSet, bool)

GroupLabels extracts grouping label set from the context. Iff none exists, the second argument is false.

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

func Now

func Now(ctx context.Context) (time.Time, bool)

Now extracts a now timestamp from the context. Iff none exists, the second argument is false.

func ReceiverName

func ReceiverName(ctx context.Context) (string, bool)

ReceiverName extracts a receiver name from the context. Iff none exists, the second argument is false.

func RepeatInterval

func RepeatInterval(ctx context.Context) (time.Duration, bool)

RepeatInterval extracts a repeat interval from the context. Iff none exists, the second argument is false.

func ResolvedAlerts

func ResolvedAlerts(ctx context.Context) ([]uint64, bool)

ResolvedAlerts extracts a slice of firing alerts from the context. Iff none exists, the second argument is false.

func WithFiringAlerts

func WithFiringAlerts(ctx context.Context, alerts []uint64) context.Context

WithFiringAlerts populates a context with a slice of firing alerts.

func WithGroupKey

func WithGroupKey(ctx context.Context, s string) context.Context

WithGroupKey populates a context with a group key.

func WithGroupLabels

func WithGroupLabels(ctx context.Context, lset model.LabelSet) context.Context

WithGroupLabels populates a context with grouping labels.

func WithNow

func WithNow(ctx context.Context, t time.Time) context.Context

WithNow populates a context with a now timestamp.

func WithReceiverName

func WithReceiverName(ctx context.Context, rcv string) context.Context

WithReceiverName populates a context with a receiver name.

func WithRepeatInterval

func WithRepeatInterval(ctx context.Context, t time.Duration) context.Context

WithRepeatInterval populates a context with a repeat interval.

func WithResolvedAlerts

func WithResolvedAlerts(ctx context.Context, alerts []uint64) context.Context

WithResolvedAlerts populates a context with a slice of resolved alerts.

Types

type DedupStage

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

DedupStage filters alerts. Filtering happens based on a notification log.

func NewDedupStage

func NewDedupStage(i Integration, l NotificationLog, recv *nflogpb.Receiver) *DedupStage

NewDedupStage wraps a DedupStage that runs against the given notification log.

func (*DedupStage) Exec

func (n *DedupStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type Email

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

Email implements a Notifier for email notifications.

func NewEmail

func NewEmail(c *config.EmailConfig, t *template.Template, l log.Logger) *Email

NewEmail returns a new Email notifier.

func (*Email) Notify

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

Notify implements the Notifier interface.

type FanoutStage

type FanoutStage []Stage

FanoutStage executes its stages concurrently

func (FanoutStage) Exec

func (fs FanoutStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec attempts to execute all stages concurrently and discards the results. It returns its input alerts and a types.MultiError if one or more stages fail.

type GossipSettleStage

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

GossipSettleStage waits until the Gossip has settled to forward alerts.

func NewGossipSettleStage

func NewGossipSettleStage(p *cluster.Peer) *GossipSettleStage

NewGossipSettleStage returns a new GossipSettleStage.

func (*GossipSettleStage) Exec

func (n *GossipSettleStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

type Hipchat

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

Hipchat implements a Notifier for Hipchat notifications.

func NewHipchat

func NewHipchat(c *config.HipchatConfig, t *template.Template, l log.Logger) *Hipchat

NewHipchat returns a new Hipchat notification handler.

func (*Hipchat) Notify

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

Notify implements the Notifier interface.

type InhibitStage

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

InhibitStage filters alerts through an inhibition muter.

func NewInhibitStage

func NewInhibitStage(m types.Muter) *InhibitStage

NewInhibitStage return a new InhibitStage.

func (*InhibitStage) Exec

func (n *InhibitStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type Integration

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

An Integration wraps a notifier and its config to be uniquely identified by name and index from its origin in the configuration.

func BuildReceiverIntegrations

func BuildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, logger log.Logger) []Integration

BuildReceiverIntegrations builds a list of integration notifiers off of a receivers config.

func (*Integration) Notify

func (i *Integration) Notify(ctx context.Context, alerts ...*types.Alert) (bool, error)

Notify implements the Notifier interface.

type MultiStage

type MultiStage []Stage

A MultiStage executes a series of stages sequencially.

func (MultiStage) Exec

func (ms MultiStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type NotificationLog

type NotificationLog interface {
	Log(r *nflogpb.Receiver, gkey string, firingAlerts, resolvedAlerts []uint64) error
	Query(params ...nflog.QueryParam) ([]*nflogpb.Entry, error)
}

type Notifier

type Notifier interface {
	Notify(context.Context, ...*types.Alert) (bool, error)
}

A Notifier notifies about alerts under constraints of the given context. It returns an error if unsuccessful and a flag whether the error is recoverable. This information is useful for a retry logic.

type OpsGenie

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

OpsGenie implements a Notifier for OpsGenie notifications.

func NewOpsGenie

func NewOpsGenie(c *config.OpsGenieConfig, t *template.Template, l log.Logger) *OpsGenie

NewOpsGenie returns a new OpsGenie notifier.

func (*OpsGenie) Notify

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

Notify implements the Notifier interface.

type PagerDuty

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

PagerDuty implements a Notifier for PagerDuty notifications.

func NewPagerDuty

func NewPagerDuty(c *config.PagerdutyConfig, t *template.Template, l log.Logger) *PagerDuty

NewPagerDuty returns a new PagerDuty notifier.

func (*PagerDuty) Notify

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

Notify implements the Notifier interface.

https://v2.developer.pagerduty.com/docs/events-api-v2

type Pushover

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

Pushover implements a Notifier for Pushover notifications.

func NewPushover

func NewPushover(c *config.PushoverConfig, t *template.Template, l log.Logger) *Pushover

NewPushover returns a new Pushover notifier.

func (*Pushover) Notify

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

Notify implements the Notifier interface.

type RetryStage

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

RetryStage notifies via passed integration with exponential backoff until it succeeds. It aborts if the context is canceled or timed out.

func NewRetryStage

func NewRetryStage(i Integration, groupName string) *RetryStage

NewRetryStage returns a new instance of a RetryStage.

func (RetryStage) Exec

func (r RetryStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type RoutingStage

type RoutingStage map[string]Stage

RoutingStage executes the inner stages based on the receiver specified in the context.

func BuildPipeline

func BuildPipeline(
	confs []*config.Receiver,
	tmpl *template.Template,
	wait func() time.Duration,
	muter types.Muter,
	silences *silence.Silences,
	notificationLog NotificationLog,
	marker types.Marker,
	peer *cluster.Peer,
	logger log.Logger,
) RoutingStage

BuildPipeline builds a map of receivers to Stages.

func (RoutingStage) Exec

func (rs RoutingStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type SetNotifiesStage

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

SetNotifiesStage sets the notification information about passed alerts. The passed alerts should have already been sent to the receivers.

func NewSetNotifiesStage

func NewSetNotifiesStage(l NotificationLog, recv *nflogpb.Receiver) *SetNotifiesStage

NewSetNotifiesStage returns a new instance of a SetNotifiesStage.

func (SetNotifiesStage) Exec

func (n SetNotifiesStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type SilenceStage

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

SilenceStage filters alerts through a silence muter.

func NewSilenceStage

func NewSilenceStage(s *silence.Silences, mk types.Marker) *SilenceStage

NewSilenceStage returns a new SilenceStage.

func (*SilenceStage) Exec

func (n *SilenceStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type Slack

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

Slack implements a Notifier for Slack notifications.

func NewSlack

func NewSlack(c *config.SlackConfig, t *template.Template, l log.Logger) *Slack

NewSlack returns a new Slack notification handler.

func (*Slack) Notify

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

Notify implements the Notifier interface.

type Stage

type Stage interface {
	Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)
}

A Stage processes alerts under the constraints of the given context.

type StageFunc

type StageFunc func(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

StageFunc wraps a function to represent a Stage.

func (StageFunc) Exec

func (f StageFunc) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements Stage interface.

type VictorOps

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

VictorOps implements a Notifier for VictorOps notifications.

func NewVictorOps

func NewVictorOps(c *config.VictorOpsConfig, t *template.Template, l log.Logger) *VictorOps

NewVictorOps returns a new VictorOps notifier.

func (*VictorOps) Notify

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

Notify implements the Notifier interface.

type WaitStage

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

WaitStage waits for a certain amount of time before continuing or until the context is done.

func NewWaitStage

func NewWaitStage(wait func() time.Duration) *WaitStage

NewWaitStage returns a new WaitStage.

func (*WaitStage) Exec

func (ws *WaitStage) Exec(ctx context.Context, l log.Logger, alerts ...*types.Alert) (context.Context, []*types.Alert, error)

Exec implements the Stage interface.

type Webhook

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

Webhook implements a Notifier for generic webhooks.

func NewWebhook

func NewWebhook(conf *config.WebhookConfig, t *template.Template, l log.Logger) *Webhook

NewWebhook returns a new Webhook.

func (*Webhook) Notify

func (w *Webhook) Notify(ctx context.Context, alerts ...*types.Alert) (bool, error)

Notify implements the Notifier interface.

type WebhookMessage

type WebhookMessage struct {
	*template.Data

	// The protocol version.
	Version  string `json:"version"`
	GroupKey string `json:"groupKey"`
}

WebhookMessage defines the JSON object send to webhook endpoints.

type Wechat

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

Wechat implements a Notfier for wechat notifications

func NewWechat

func NewWechat(c *config.WechatConfig, t *template.Template, l log.Logger) *Wechat

NewWechat returns a new Wechat notifier.

func (*Wechat) Notify

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

Notify implements the Notifier interface.

type WechatToken

type WechatToken struct {
	AccessToken string `json:"access_token"`
}

Wechat AccessToken with corpid and corpsecret.

Jump to

Keyboard shortcuts

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