dispatch

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRouteOpts = RouteOpts{
	GroupWait:      30 * time.Second,
	GroupInterval:  5 * time.Minute,
	RepeatInterval: 4 * time.Hour,
	GroupBy: map[model.LabelName]struct{}{
		model.AlertNameLabel: struct{}{},
	},
}

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

Functions

This section is empty.

Types

type APIAlert

type APIAlert struct {
	*model.Alert

	Inhibited bool   `json:"inhibited"`
	Silenced  string `json:"silenced,omitempty"`
}

APIAlert is the API representation of an alert, which is a regular alert annotated with silencing and inhibition info.

type AlertBlock

type AlertBlock struct {
	RouteOpts *RouteOpts  `json:"routeOpts"`
	Alerts    []*APIAlert `json:"alerts"`
}

AlertBlock contains a list of alerts associated with a set of routing options.

type AlertGroup

type AlertGroup struct {
	Labels model.LabelSet `json:"labels"`
	Blocks []*AlertBlock  `json:"blocks"`
}

AlertGroup is a list of alert blocks grouped by the same label set.

type AlertOverview

type AlertOverview []*AlertGroup

AlertOverview is a representation of all active alerts in the system.

func (AlertOverview) Len

func (ao AlertOverview) Len() int

func (AlertOverview) Less

func (ao AlertOverview) Less(i, j int) bool

func (AlertOverview) Swap

func (ao AlertOverview) Swap(i, j int)

type Dispatcher

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

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

func NewDispatcher

func NewDispatcher(
	ap provider.Alerts,
	r *Route,
	s notify.Stage,
	mk types.Marker,
	to func(time.Duration) time.Duration,
) *Dispatcher

NewDispatcher returns a new Dispatcher.

func (*Dispatcher) Groups

func (d *Dispatcher) Groups() AlertOverview

Groups populates an AlertOverview 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 Route

type Route struct {

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

	// Equality or regex matchers an alert has to fulfill to match
	// this route.
	Matchers types.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
}

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

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) Fingerprint

func (r *Route) Fingerprint() model.Fingerprint

Fingerprint returns a hash of the Route based on its grouping labels, routing options and the total set of matchers necessary to reach this route.

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) SquashMatchers

func (r *Route) SquashMatchers() types.Matchers

SquashMatchers returns the total set of matchers on the path of the tree that have to apply to reach the route.

type RouteOpts

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{}

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

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

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

Jump to

Keyboard shortcuts

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