...

Package dispatch

import "github.com/prometheus/alertmanager/dispatch"
Overview
Index

Overview ▾

Variables

DefaultRouteOpts are the defaulting routing options which apply to the root route of a routing tree.

var DefaultRouteOpts = RouteOpts{
    GroupWait:         30 * time.Second,
    GroupInterval:     5 * time.Minute,
    RepeatInterval:    4 * time.Hour,
    GroupBy:           map[model.LabelName]struct{}{},
    GroupByAll:        false,
    MuteTimeIntervals: []string{},
}

type AlertGroup

AlertGroup represents how alerts exist within an aggrGroup.

type AlertGroup struct {
    Alerts   types.AlertSlice
    Labels   model.LabelSet
    Receiver string
}

type AlertGroups

type AlertGroups []*AlertGroup

func (AlertGroups) Len

func (ag AlertGroups) Len() int

func (AlertGroups) Less

func (ag AlertGroups) Less(i, j int) bool

func (AlertGroups) Swap

func (ag AlertGroups) Swap(i, j int)

type Dispatcher

Dispatcher sorts incoming alerts into aggregation groups and assigns the correct notifiers to each.

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

func NewDispatcher

func NewDispatcher(
    ap provider.Alerts,
    r *Route,
    s notify.Stage,
    mk types.Marker,
    to func(time.Duration) time.Duration,
    lim Limits,
    l log.Logger,
    m *DispatcherMetrics,
) *Dispatcher

NewDispatcher returns a new Dispatcher.

func (*Dispatcher) Groups

func (d *Dispatcher) Groups(routeFilter func(*Route) bool, alertFilter func(*types.Alert, time.Time) bool) (AlertGroups, map[model.Fingerprint][]string)

Groups returns a slice of AlertGroups from the dispatcher's internal state.

func (*Dispatcher) Run

func (d *Dispatcher) Run()

Run starts dispatching alerts incoming via the updates channel.

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Stop the dispatcher.

type DispatcherMetrics

DispatcherMetrics represents metrics associated to a dispatcher.

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

func NewDispatcherMetrics

func NewDispatcherMetrics(registerLimitMetrics bool, r prometheus.Registerer) *DispatcherMetrics

NewDispatcherMetrics returns a new registered DispatchMetrics.

type Limits

Limits describes limits used by Dispatcher.

type Limits interface {
    // MaxNumberOfAggregationGroups returns max number of aggregation groups that dispatcher can have.
    // 0 or negative value = unlimited.
    // If dispatcher hits this limit, it will not create additional groups, but will log an error instead.
    MaxNumberOfAggregationGroups() int
}

type Route

A Route is a node that contains definitions of how to handle alerts.

type Route struct {

    // The configuration parameters for matches of this route.
    RouteOpts RouteOpts

    // Matchers an alert has to fulfill to match
    // this route.
    Matchers labels.Matchers

    // If true, an alert matches further routes on the same level.
    Continue bool

    // Children routes of this route.
    Routes []*Route
    // contains filtered or unexported fields
}

func NewRoute

func NewRoute(cr *config.Route, parent *Route) *Route

NewRoute returns a new route.

func NewRoutes

func NewRoutes(croutes []*config.Route, parent *Route) []*Route

NewRoutes returns a slice of routes.

func (*Route) Key

func (r *Route) Key() string

Key returns a key for the route. It does not uniquely identify the route in general.

func (*Route) Match

func (r *Route) Match(lset model.LabelSet) []*Route

Match does a depth-first left-to-right search through the route tree and returns the matching routing nodes.

func (*Route) Walk

func (r *Route) Walk(visit func(*Route))

Walk traverses the route tree in depth-first order.

type RouteOpts

RouteOpts holds various routing options necessary for processing alerts that match a given route.

type RouteOpts struct {
    // The identifier of the associated notification configuration.
    Receiver string

    // What labels to group alerts by for notifications.
    GroupBy map[model.LabelName]struct{}

    // Use all alert labels to group.
    GroupByAll bool

    // How long to wait to group matching alerts before sending
    // a notification.
    GroupWait      time.Duration
    GroupInterval  time.Duration
    RepeatInterval time.Duration

    // A list of time intervals for which the route is muted.
    MuteTimeIntervals []string

    // A list of time intervals for which the route is active.
    ActiveTimeIntervals []string
}

func (*RouteOpts) MarshalJSON

func (ro *RouteOpts) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation of the routing options.

func (*RouteOpts) String

func (ro *RouteOpts) String() string