Documentation ¶
Index ¶
- func Alerts(alerts ...*Alert) model.Alerts
- type Alert
- type AlertMarker
- type AlertSlice
- type AlertState
- type AlertStatus
- type GroupMarker
- type MemMarker
- func (m *MemMarker) Active(alert model.Fingerprint) bool
- func (m *MemMarker) Count(states ...AlertState) int
- func (m *MemMarker) Delete(alert model.Fingerprint)
- func (m *MemMarker) DeleteByGroupKey(routeID, groupKey string)
- func (m *MemMarker) Inhibited(alert model.Fingerprint) ([]string, bool)
- func (m *MemMarker) Muted(routeID, groupKey string) ([]string, bool)
- func (m *MemMarker) SetActiveOrSilenced(alert model.Fingerprint, version int, activeIDs, pendingIDs []string)
- func (m *MemMarker) SetInhibited(alert model.Fingerprint, ids ...string)
- func (m *MemMarker) SetMuted(routeID, groupKey string, timeIntervalNames []string)
- func (m *MemMarker) Silenced(alert model.Fingerprint) (activeIDs, pendingIDs []string, version int, silenced bool)
- func (m *MemMarker) Status(alert model.Fingerprint) AlertStatus
- func (m *MemMarker) Unprocessed(alert model.Fingerprint) bool
- type MultiError
- type MuteFunc
- type Muter
- type Silence
- type SilenceState
- type SilenceStatus
- type TimeMuter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alert ¶
Alert wraps a model.Alert with additional information relevant to internal of the Alertmanager. The type is never exposed to external communication and the embedded alert has to be sanitized beforehand.
type AlertMarker ¶ added in v0.28.0
type AlertMarker interface { // SetActiveOrSilenced replaces the previous SilencedBy by the provided IDs of // active and pending silences, including the version number of the // silences state. The set of provided IDs is supposed to represent the // complete set of relevant silences. If no active silence IDs are provided and // InhibitedBy is already empty, it sets the provided alert to AlertStateActive. // Otherwise, it sets the provided alert to AlertStateSuppressed. SetActiveOrSilenced(alert model.Fingerprint, version int, activeSilenceIDs, pendingSilenceIDs []string) // SetInhibited replaces the previous InhibitedBy by the provided IDs of // alerts. In contrast to SetActiveOrSilenced, the set of provided IDs is not // expected to represent the complete set of inhibiting alerts. (In // practice, this method is only called with one or zero IDs. However, // this expectation might change in the future. If no IDs are provided // and InhibitedBy is already empty, it sets the provided alert to // AlertStateActive. Otherwise, it sets the provided alert to // AlertStateSuppressed. SetInhibited(alert model.Fingerprint, alertIDs ...string) // Count alerts of the given state(s). With no state provided, count all // alerts. Count(...AlertState) int // Status of the given alert. Status(model.Fingerprint) AlertStatus // Delete the given alert. Delete(model.Fingerprint) // Various methods to inquire if the given alert is in a certain // AlertState. Silenced also returns all the active and pending // silences, while Inhibited may return only a subset of inhibiting // alerts. Silenced also returns the version of the silences state the // result is based on. Unprocessed(model.Fingerprint) bool Active(model.Fingerprint) bool Silenced(model.Fingerprint) (activeIDs, pendingIDs []string, version int, silenced bool) Inhibited(model.Fingerprint) ([]string, bool) }
AlertMarker helps to mark alerts as silenced and/or inhibited. All methods are goroutine-safe.
type AlertSlice ¶
type AlertSlice []*Alert
AlertSlice is a sortable slice of Alerts.
func (AlertSlice) Len ¶
func (as AlertSlice) Len() int
func (AlertSlice) Less ¶
func (as AlertSlice) Less(i, j int) bool
func (AlertSlice) Swap ¶
func (as AlertSlice) Swap(i, j int)
type AlertState ¶ added in v0.6.1
type AlertState string
AlertState is used as part of AlertStatus.
const ( AlertStateUnprocessed AlertState = "unprocessed" AlertStateActive AlertState = "active" AlertStateSuppressed AlertState = "suppressed" )
Possible values for AlertState.
type AlertStatus ¶ added in v0.6.1
type AlertStatus struct { State AlertState `json:"state"` SilencedBy []string `json:"silencedBy"` InhibitedBy []string `json:"inhibitedBy"` // contains filtered or unexported fields }
AlertStatus stores the state of an alert and, as applicable, the IDs of silences silencing the alert and of other alerts inhibiting the alert. Note that currently, SilencedBy is supposed to be the complete set of the relevant silences while InhibitedBy may contain only a subset of the inhibiting alerts – in practice exactly one ID. (This somewhat confusing semantics might change in the future.)
type GroupMarker ¶ added in v0.28.0
type GroupMarker interface { // Muted returns true if the group is muted, otherwise false. If the group // is muted then it also returns the names of the time intervals that muted // it. Muted(routeID, groupKey string) ([]string, bool) // SetMuted marks the group as muted, and sets the names of the time // intervals that mute it. If the list of names is nil or the empty slice // then the muted marker is removed. SetMuted(routeID, groupKey string, timeIntervalNames []string) // DeleteByGroupKey removes all markers for the GroupKey. DeleteByGroupKey(routeID, groupKey string) }
GroupMarker helps to mark groups as active or muted. All methods are goroutine-safe.
TODO(grobinson): routeID is used in Muted and SetMuted because groupKey is not unique (see #3817). Once groupKey uniqueness is fixed routeID can be removed from the GroupMarker interface.
type MemMarker ¶ added in v0.28.0
type MemMarker struct {
// contains filtered or unexported fields
}
func NewMarker ¶
func NewMarker(r prometheus.Registerer) *MemMarker
NewMarker returns an instance of a AlertMarker implementation.
func (*MemMarker) Active ¶ added in v0.28.0
func (m *MemMarker) Active(alert model.Fingerprint) bool
Active implements AlertMarker.
func (*MemMarker) Count ¶ added in v0.28.0
func (m *MemMarker) Count(states ...AlertState) int
Count implements AlertMarker.
func (*MemMarker) Delete ¶ added in v0.28.0
func (m *MemMarker) Delete(alert model.Fingerprint)
Delete implements AlertMarker.
func (*MemMarker) DeleteByGroupKey ¶ added in v0.28.0
func (*MemMarker) Inhibited ¶ added in v0.28.0
func (m *MemMarker) Inhibited(alert model.Fingerprint) ([]string, bool)
Inhibited implements AlertMarker.
func (*MemMarker) SetActiveOrSilenced ¶ added in v0.28.0
func (m *MemMarker) SetActiveOrSilenced(alert model.Fingerprint, version int, activeIDs, pendingIDs []string)
SetActiveOrSilenced implements AlertMarker.
func (*MemMarker) SetInhibited ¶ added in v0.28.0
func (m *MemMarker) SetInhibited(alert model.Fingerprint, ids ...string)
SetInhibited implements AlertMarker.
func (*MemMarker) Silenced ¶ added in v0.28.0
func (m *MemMarker) Silenced(alert model.Fingerprint) (activeIDs, pendingIDs []string, version int, silenced bool)
Silenced returns whether the alert for the given Fingerprint is in the Silenced state, any associated silence IDs, and the silences state version the result is based on.
func (*MemMarker) Status ¶ added in v0.28.0
func (m *MemMarker) Status(alert model.Fingerprint) AlertStatus
Status implements AlertMarker.
func (*MemMarker) Unprocessed ¶ added in v0.28.0
func (m *MemMarker) Unprocessed(alert model.Fingerprint) bool
Unprocessed implements AlertMarker.
type MultiError ¶
type MultiError struct {
// contains filtered or unexported fields
}
MultiError contains multiple errors and implements the error interface. Its zero value is ready to use. All its methods are goroutine safe.
func (*MultiError) Error ¶
func (e *MultiError) Error() string
func (*MultiError) Errors ¶
func (e *MultiError) Errors() []error
Errors returns the errors added to the MuliError. The returned slice is a copy of the internal slice of errors.
func (*MultiError) Len ¶
func (e *MultiError) Len() int
Len returns the number of errors added to the MultiError.
type Muter ¶
A Muter determines whether a given label set is muted. Implementers that maintain an underlying AlertMarker are expected to update it during a call of Mutes.
type Silence ¶
type Silence struct { // A unique identifier across all connected instances. ID string `json:"id"` // A set of matchers determining if a label set is affected // by the silence. Matchers labels.Matchers `json:"matchers"` // Time range of the silence. // // * StartsAt must not be before creation time // * EndsAt must be after StartsAt // * Deleting a silence means to set EndsAt to now // * Time range must not be modified in different ways // // TODO(fabxc): this may potentially be extended by // creation and update timestamps. StartsAt time.Time `json:"startsAt"` EndsAt time.Time `json:"endsAt"` // The last time the silence was updated. UpdatedAt time.Time `json:"updatedAt"` // Information about who created the silence for which reason. CreatedBy string `json:"createdBy"` Comment string `json:"comment,omitempty"` Status SilenceStatus `json:"status"` }
A Silence determines whether a given label set is muted.
type SilenceState ¶ added in v0.7.0
type SilenceState string
SilenceState is used as part of SilenceStatus.
const ( SilenceStateExpired SilenceState = "expired" SilenceStateActive SilenceState = "active" SilenceStatePending SilenceState = "pending" )
Possible values for SilenceState.
func CalcSilenceState ¶ added in v0.7.0
func CalcSilenceState(start, end time.Time) SilenceState
CalcSilenceState returns the SilenceState that a silence with the given start and end time would have right now.
type SilenceStatus ¶ added in v0.7.0
type SilenceStatus struct {
State SilenceState `json:"state"`
}
SilenceStatus stores the state of a silence.
type TimeMuter ¶ added in v0.27.0
type TimeMuter interface {
Mutes(timeIntervalNames []string, now time.Time) (bool, []string, error)
}
A TimeMuter determines if the time is muted by one or more active or mute time intervals. If the time is muted, it returns true and the names of the time intervals that muted it. Otherwise, it returns false and a nil slice.