manager

package
v0.0.0-...-e00f5b1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2015 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const AlertNameLabel = "alertname"

Variables

This section is empty.

Functions

func NewNotifier

func NewNotifier(configs []*pb.NotificationConfig, amURL string) *notifier

NewNotifier construct a new notifier.

Types

type AggregationRule

type AggregationRule struct {
	Filters                Filters
	RepeatRate             time.Duration
	NotificationConfigName string
}

AggregationRule creates and manages the scope for received events.

func (*AggregationRule) Handles

func (r *AggregationRule) Handles(l *Alert) bool

Returns whether a given AggregationRule matches an Alert.

type AggregationRules

type AggregationRules []*AggregationRule

type Alert

type Alert struct {
	// Short summary of alert.
	Summary string `json:"summary"`
	// Long description of alert.
	Description string `json:"description"`
	// Runbook link or reference for the alert.
	Runbook string `json:"runbook"`
	// Label value pairs for purpose of aggregation, matching, and disposition
	// dispatching. This must minimally include an "alertname" label.
	Labels AlertLabelSet `json:"labels"`
	// Extra key/value information which is not used for aggregation.
	Payload AlertPayload `json:"payload"`
}

Alert models an action triggered by Prometheus.

func (*Alert) Fingerprint

func (a *Alert) Fingerprint() AlertFingerprint

func (*Alert) Name

func (a *Alert) Name() string

type AlertAggregate

type AlertAggregate struct {
	Alert *Alert
	Rule  *AggregationRule

	// When was this AggregationInstance created?
	Created time.Time
	// When was the last refresh received into this AlertAggregate?
	LastRefreshed time.Time
	// When was the last notification sent out for this AlertAggregate?
	LastNotification time.Time
	// When should the next notification be sent according to the current Rule's
	// RepeatRate?
	NextNotification time.Time
}

An AlertAggregate tracks the latest alert received for a given alert fingerprint and some metadata about the alert.

func (*AlertAggregate) Ingest

func (agg *AlertAggregate) Ingest(a *Alert)

Ingests a received Alert into this AlertAggregate and updates metadata.

type AlertAggregates

type AlertAggregates []*AlertAggregate

func (AlertAggregates) Len

func (aggs AlertAggregates) Len() int

Methods implementing heap.Interface.

func (*AlertAggregates) Pop

func (aggs *AlertAggregates) Pop() interface{}

func (*AlertAggregates) Push

func (aggs *AlertAggregates) Push(agg interface{})

func (AlertAggregates) Swap

func (aggs AlertAggregates) Swap(i, j int)

type AlertFingerprint

type AlertFingerprint uint64

func (AlertFingerprint) String

func (fp AlertFingerprint) String() string

type AlertLabelSet

type AlertLabelSet map[string]string

func (AlertLabelSet) Equal

func (l AlertLabelSet) Equal(o AlertLabelSet) bool

func (AlertLabelSet) Fingerprint

func (l AlertLabelSet) Fingerprint() AlertFingerprint

func (AlertLabelSet) MatchOnLabels

func (l AlertLabelSet) MatchOnLabels(o AlertLabelSet, labels []string) bool

type AlertLabelSets

type AlertLabelSets []AlertLabelSet

type AlertManager

type AlertManager interface {
	// Ingests a new alert entry into the store. If an alert with the same
	// fingerprint already exists, it only updates the existing entry's metadata.
	Receive(Alerts)
	// Retrieves all alerts from the store that match the provided Filters.
	GetAll(Filters) AlertAggregates
	// Sets the AggregationRules to associate with alerts.
	SetAggregationRules(AggregationRules)
	// Runs the AlertManager dispatcher loop.
	Run()
}

AlertManager stores Alerts and removes them upon expiry.

func NewMemoryAlertManager

func NewMemoryAlertManager(o *MemoryAlertManagerOptions) AlertManager

Constructs a new memoryAlertManager.

type AlertPayload

type AlertPayload map[string]string

type Alerts

type Alerts []*Alert

type ApiSilence

type ApiSilence struct {
	ID               SilenceID
	CreatedBy        string
	CreatedAtSeconds int64
	EndsAtSeconds    int64
	Comment          string
	Filters          map[string]string
}

type Filter

type Filter struct {
	Name         *regexp.Regexp
	Value        *regexp.Regexp
	NamePattern  string
	ValuePattern string
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(namePattern string, valuePattern string) *Filter

func (*Filter) Handles

func (f *Filter) Handles(l AlertLabelSet) bool

type Filters

type Filters []*Filter

func (Filters) Filter

func (Filters) Handles

func (f Filters) Handles(l AlertLabelSet) bool

type InhibitRule

type InhibitRule struct {
	SourceFilters Filters
	TargetFilters Filters
	MatchOn       []string
}

func (*InhibitRule) Filter

Returns those target AlertLabelSets which are not inhibited by any of the source AlertLabelSets.

type InhibitRules

type InhibitRules []*InhibitRule

type Inhibitor

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

Inhibitor calculates inhibition rules between its labelset inputs and only emits uninhibited alert labelsets.

func (*Inhibitor) Filter

Returns those AlertLabelSets which are not inhibited by any other AlertLabelSet in the provided list.

func (*Inhibitor) HasChanged

func (i *Inhibitor) HasChanged() bool

Returns whether inhibits have changed since the last call to HasChanged.

func (*Inhibitor) IsInhibited

func (i *Inhibitor) IsInhibited(t AlertLabelSet, l AlertLabelSets) bool

Returns whether a given AlertLabelSet is inhibited by a group of other AlertLabelSets.

func (*Inhibitor) SetInhibitRules

func (i *Inhibitor) SetInhibitRules(r InhibitRules)

Replaces the current InhibitRules with a new set.

type IsSilencedInterrogator

type IsSilencedInterrogator interface {
	IsSilenced(AlertLabelSet) (bool, *Silence)
}

type MemoryAlertManagerOptions

type MemoryAlertManagerOptions struct {
	// Inhibitor for filtering out inhibited alerts.
	Inhibitor *Inhibitor
	// Silencer for filtering out silenced alerts.
	Silencer *Silencer
	// Notifier for dispatching notifications.
	Notifier Notifier
	// The minimum interval for alert refreshes before being purged.
	MinRefreshInterval time.Duration
}

Options for constructing a memoryAlertManager.

type Notifier

type Notifier interface {
	// Queue a notification for asynchronous dispatching.
	QueueNotification(a *Alert, op notificationOp, configName string) error
	// Replace current notification configs. Already enqueued messages will remain
	// unaffected.
	SetNotificationConfigs([]*pb.NotificationConfig)
	// Start alert notification dispatch loop.
	Dispatch()
	// Stop the alert notification dispatch loop.
	Close()
}

A Notifier is responsible for sending notifications for alerts according to a provided notification configuration.

type Silence

type Silence struct {
	// The numeric ID of the silence.
	ID SilenceID
	// Name/email of the silence creator.
	CreatedBy string
	// When the silence was first created (Unix timestamp).
	CreatedAt time.Time
	// When the silence expires (Unix timestamp).
	EndsAt time.Time
	// Additional comment about the silence.
	Comment string
	// Filters that determine which alerts are silenced.
	Filters Filters
	// contains filtered or unexported fields
}

func (*Silence) MarshalJSON

func (s *Silence) MarshalJSON() ([]byte, error)

func (Silence) Matches

func (s Silence) Matches(l AlertLabelSet) bool

func (*Silence) UnmarshalJSON

func (s *Silence) UnmarshalJSON(data []byte) error

type SilenceID

type SilenceID uint

type Silencer

type Silencer struct {
	// Silences managed by this Silencer.
	Silences map[SilenceID]*Silence
	// contains filtered or unexported fields
}

func NewSilencer

func NewSilencer() *Silencer

func (*Silencer) AddSilence

func (s *Silencer) AddSilence(sc *Silence) SilenceID

func (*Silencer) Close

func (s *Silencer) Close()

func (*Silencer) DelSilence

func (s *Silencer) DelSilence(id SilenceID) error

func (*Silencer) Filter

func (s *Silencer) Filter(l AlertLabelSets) AlertLabelSets

Returns only those AlertLabelSets which are not matched by any silence.

func (*Silencer) GetSilence

func (s *Silencer) GetSilence(id SilenceID) (*Silence, error)

func (*Silencer) HasChanged

func (s *Silencer) HasChanged() bool

Returns whether silences have been added/updated/removed since the last call to HasChanged.

func (*Silencer) IsSilenced

func (s *Silencer) IsSilenced(l AlertLabelSet) (bool, *Silence)

func (*Silencer) LoadFromFile

func (s *Silencer) LoadFromFile(fileName string) error

Loads a JSON representation of silences from a file.

func (*Silencer) SaveToFile

func (s *Silencer) SaveToFile(fileName string) error

Saves a JSON representation of silences to a file.

func (*Silencer) SilenceSummary

func (s *Silencer) SilenceSummary() Silences

func (*Silencer) UpdateSilence

func (s *Silencer) UpdateSilence(sc *Silence) error

type Silences

type Silences []*Silence

Jump to

Keyboard shortcuts

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