Documentation ¶
Index ¶
- Constants
- func NewNotifier(configs []*pb.NotificationConfig) *notifier
- type AggregationRule
- type AggregationRules
- type Alert
- type AlertAggregate
- type AlertAggregates
- type AlertFingerprint
- type AlertLabelSet
- type AlertLabelSets
- type AlertManager
- type AlertPayload
- type Alerts
- type ApiSilence
- type Filter
- type Filters
- type InhibitRule
- type InhibitRules
- type Inhibitor
- type IsSilencedInterrogator
- type MemoryAlertManagerOptions
- type Notifier
- type Silence
- type SilenceID
- type Silencer
- func (s *Silencer) AddSilence(sc *Silence) SilenceID
- func (s *Silencer) Close()
- func (s *Silencer) DelSilence(id SilenceID) error
- func (s *Silencer) Filter(l AlertLabelSets) AlertLabelSets
- func (s *Silencer) GetSilence(id SilenceID) (*Silence, error)
- func (s *Silencer) HasChanged() bool
- func (s *Silencer) IsSilenced(l AlertLabelSet) (bool, *Silence)
- func (s *Silencer) LoadFromFile(fileName string) error
- func (s *Silencer) SaveToFile(fileName string) error
- func (s *Silencer) SilenceSummary() Silences
- func (s *Silencer) UpdateSilence(sc *Silence) error
- type Silences
Constants ¶
const AlertNameLabel = "alertname"
Variables ¶
This section is empty.
Functions ¶
func NewNotifier ¶
func NewNotifier(configs []*pb.NotificationConfig) *notifier
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 // Long description of alert. Description string // Label value pairs for purpose of aggregation, matching, and disposition // dispatching. This must minimally include an "alertname" label. Labels AlertLabelSet // Extra key/value information which is not used for aggregation. Payload AlertPayload }
Alert models an action triggered by Prometheus.
func (*Alert) Fingerprint ¶
func (a *Alert) Fingerprint() AlertFingerprint
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
type AlertLabelSet ¶
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 ApiSilence ¶
type Filter ¶
type Filter struct { Name *regexp.Regexp Value *regexp.Regexp NamePattern string ValuePattern string // contains filtered or unexported fields }
func (*Filter) Handles ¶
func (f *Filter) Handles(l AlertLabelSet) bool
type Filters ¶
type Filters []*Filter
func (Filters) Filter ¶
func (f Filters) Filter(l AlertLabelSets) AlertLabelSets
func (Filters) Handles ¶
func (f Filters) Handles(l AlertLabelSet) bool
type InhibitRule ¶
func (*InhibitRule) Filter ¶
func (i *InhibitRule) Filter(s AlertLabelSets, t AlertLabelSets) AlertLabelSets
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 ¶
func (i *Inhibitor) Filter(l AlertLabelSets) AlertLabelSets
Returns those AlertLabelSets which are not inhibited by any other AlertLabelSet in the provided list.
func (*Inhibitor) HasChanged ¶
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, 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 (Silence) Matches ¶
func (s Silence) Matches(l AlertLabelSet) bool
func (*Silence) UnmarshalJSON ¶
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 (*Silencer) DelSilence ¶
func (*Silencer) Filter ¶
func (s *Silencer) Filter(l AlertLabelSets) AlertLabelSets
Returns only those AlertLabelSets which are not matched by any silence.
func (*Silencer) HasChanged ¶
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 ¶
Loads a JSON representation of silences from a file.
func (*Silencer) SaveToFile ¶
Saves a JSON representation of silences to a file.