Documentation ¶
Index ¶
- Constants
- func Drain(r *http.Response)
- func FiringAlerts(ctx context.Context) ([]uint64, bool)
- func GetTemplateData(ctx context.Context, tmpl *template.Template, alerts []*types.Alert, ...) *template.Data
- func GroupKey(ctx context.Context) (string, bool)
- func GroupLabels(ctx context.Context) (model.LabelSet, bool)
- func Now(ctx context.Context) (time.Time, bool)
- func PostJSON(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)
- func PostText(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)
- func ReceiverName(ctx context.Context) (string, bool)
- func RedactURL(err error) error
- func RepeatInterval(ctx context.Context) (time.Duration, bool)
- func ResolvedAlerts(ctx context.Context) ([]uint64, bool)
- func TmplHTML(tmpl *template.Template, data *template.Data, err *error) func(string) string
- func TmplText(tmpl *template.Template, data *template.Data, err *error) func(string) string
- func Truncate(s string, n int) (string, bool)
- func WithFiringAlerts(ctx context.Context, alerts []uint64) context.Context
- func WithGroupKey(ctx context.Context, s string) context.Context
- func WithGroupLabels(ctx context.Context, lset model.LabelSet) context.Context
- func WithNow(ctx context.Context, t time.Time) context.Context
- func WithReceiverName(ctx context.Context, rcv string) context.Context
- func WithRepeatInterval(ctx context.Context, t time.Duration) context.Context
- func WithResolvedAlerts(ctx context.Context, alerts []uint64) context.Context
- type DedupStage
- type FanoutStage
- type GossipSettleStage
- type Integration
- type Key
- type MultiStage
- type MuteStage
- type NotificationLog
- type Notifier
- type PipelineBuilder
- type ResolvedSender
- type Retrier
- type RetryStage
- type RoutingStage
- type SetNotifiesStage
- type Stage
- type StageFunc
- type WaitStage
Constants ¶
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 Drain ¶ added in v0.18.0
Drain consumes and closes the response's body to make sure that the HTTP client can reuse existing connections.
func FiringAlerts ¶ added in v0.6.0
FiringAlerts extracts a slice of firing alerts from the context. Iff none exists, the second argument is false.
func GetTemplateData ¶ added in v0.18.0
func GetTemplateData(ctx context.Context, tmpl *template.Template, alerts []*types.Alert, l log.Logger) *template.Data
GetTemplateData creates the template data from the context and the alerts.
func GroupKey ¶
GroupKey extracts a group key from the context. Iff none exists, the second argument is false.
func GroupLabels ¶
GroupLabels extracts grouping label set from the context. Iff none exists, the second argument is false.
func Now ¶
Now extracts a now timestamp from the context. Iff none exists, the second argument is false.
func PostJSON ¶ added in v0.18.0
func PostJSON(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)
PostJSON sends a POST request with JSON payload to the given URL.
func PostText ¶ added in v0.18.0
func PostText(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)
PostText sends a POST request with text payload to the given URL.
func ReceiverName ¶ added in v0.5.0
ReceiverName extracts a receiver name from the context. Iff none exists, the second argument is false.
func RepeatInterval ¶
RepeatInterval extracts a repeat interval from the context. Iff none exists, the second argument is false.
func ResolvedAlerts ¶ added in v0.6.0
ResolvedAlerts extracts a slice of firing alerts from the context. Iff none exists, the second argument is false.
func TmplHTML ¶ added in v0.18.0
TmplHTML is using monadic error handling in order to make string templating less verbose. Use with care as the final error checking is easily missed.
func TmplText ¶ added in v0.18.0
TmplText is using monadic error handling in order to make string templating less verbose. Use with care as the final error checking is easily missed.
func WithFiringAlerts ¶ added in v0.6.0
WithFiringAlerts populates a context with a slice of firing alerts.
func WithGroupKey ¶
WithGroupKey populates a context with a group key.
func WithGroupLabels ¶
WithGroupLabels populates a context with grouping labels.
func WithReceiverName ¶ added in v0.5.0
WithReceiverName populates a context with a receiver name.
func WithRepeatInterval ¶
WithRepeatInterval populates a context with a repeat interval.
Types ¶
type DedupStage ¶ added in v0.5.0
type DedupStage struct {
// contains filtered or unexported fields
}
DedupStage filters alerts. Filtering happens based on a notification log.
func NewDedupStage ¶ added in v0.5.0
func NewDedupStage(rs ResolvedSender, l NotificationLog, recv *nflogpb.Receiver) *DedupStage
NewDedupStage wraps a DedupStage that runs against the given notification log.
type FanoutStage ¶ added in v0.5.0
type FanoutStage []Stage
FanoutStage executes its stages concurrently
func (FanoutStage) Exec ¶ added in v0.5.0
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 ¶ added in v0.15.0
type GossipSettleStage struct {
// contains filtered or unexported fields
}
GossipSettleStage waits until the Gossip has settled to forward alerts.
func NewGossipSettleStage ¶ added in v0.15.0
func NewGossipSettleStage(p *cluster.Peer) *GossipSettleStage
NewGossipSettleStage returns a new GossipSettleStage.
type Integration ¶ added in v0.5.0
type Integration struct {
// contains filtered or unexported fields
}
Integration wraps a notifier and its configuration to be uniquely identified by name and index from its origin in the configuration.
func NewIntegration ¶ added in v0.18.0
func NewIntegration(notifier Notifier, rs ResolvedSender, name string, idx int) Integration
NewIntegration returns a new integration.
func (*Integration) Index ¶ added in v0.18.0
func (i *Integration) Index() int
Index returns the index of the integration.
func (*Integration) Name ¶ added in v0.18.0
func (i *Integration) Name() string
Name returns the name of the integration.
func (*Integration) SendResolved ¶ added in v0.18.0
func (i *Integration) SendResolved() bool
SendResolved implements the ResolvedSender interface.
type Key ¶ added in v0.18.0
type Key string
Key is a string that can be hashed.
func ExtractGroupKey ¶ added in v0.18.0
ExtractGroupKey gets the group key from the context.
type MultiStage ¶ added in v0.5.0
type MultiStage []Stage
A MultiStage executes a series of stages sequentially.
type MuteStage ¶ added in v0.17.0
type MuteStage struct {
// contains filtered or unexported fields
}
MuteStage filters alerts through a Muter.
func NewMuteStage ¶ added in v0.17.0
NewMuteStage return a new MuteStage.
type NotificationLog ¶ added in v0.15.0
type Notifier ¶
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 PipelineBuilder ¶ added in v0.19.0
type PipelineBuilder struct {
// contains filtered or unexported fields
}
func NewPipelineBuilder ¶ added in v0.19.0
func NewPipelineBuilder(r prometheus.Registerer) *PipelineBuilder
func (*PipelineBuilder) New ¶ added in v0.19.0
func (pb *PipelineBuilder) New( receivers map[string][]Integration, wait func() time.Duration, inhibitor *inhibit.Inhibitor, silencer *silence.Silencer, notificationLog NotificationLog, peer *cluster.Peer, ) RoutingStage
New returns a map of receivers to Stages.
type ResolvedSender ¶ added in v0.18.0
type ResolvedSender interface {
SendResolved() bool
}
ResolvedSender returns true if resolved notifications should be sent.
type Retrier ¶ added in v0.19.0
type Retrier struct { // Function to return additional information in the error message. CustomDetailsFunc func(code int, body io.Reader) string // Additional HTTP status codes that should be retried. RetryCodes []int }
Retrier knows when to retry an HTTP request to a receiver. 2xx status codes are successful, anything else is a failure and only 5xx status codes should be retried.
type RetryStage ¶ added in v0.5.0
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 ¶ added in v0.5.0
func NewRetryStage(i Integration, groupName string, metrics *metrics) *RetryStage
NewRetryStage returns a new instance of a RetryStage.
type RoutingStage ¶ added in v0.5.0
RoutingStage executes the inner stages based on the receiver specified in the context.
type SetNotifiesStage ¶ added in v0.5.0
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 ¶ added in v0.5.0
func NewSetNotifiesStage(l NotificationLog, recv *nflogpb.Receiver) *SetNotifiesStage
NewSetNotifiesStage returns a new instance of a SetNotifiesStage.
type Stage ¶ added in v0.5.0
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 ¶ added in v0.5.0
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.
type WaitStage ¶ added in v0.5.0
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 ¶ added in v0.5.0
NewWaitStage returns a new WaitStage.