func Alerts(alerts ...*Alert) model.Alerts
Alerts turns a sequence of internal alerts into a list of exposable model.Alert structures.
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 Alert struct { model.Alert // The authoritative timestamp. UpdatedAt time.Time Timeout bool }
func (a *Alert) Merge(o *Alert) *Alert
Merge merges the timespan of two alerts based and overwrites annotations based on the authoritative timestamp. A new alert is returned, the labels are assumed to be equal.
AlertSlice is a sortable slice of Alerts.
type AlertSlice []*Alert
func (as AlertSlice) Len() int
func (as AlertSlice) Less(i, j int) bool
func (as AlertSlice) Swap(i, j int)
AlertState is used as part of AlertStatus.
type AlertState string
Possible values for AlertState.
const ( AlertStateUnprocessed AlertState = "unprocessed" AlertStateActive AlertState = "active" AlertStateSuppressed AlertState = "suppressed" )
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 AlertStatus struct { State AlertState `json:"state"` SilencedBy []string `json:"silencedBy"` InhibitedBy []string `json:"inhibitedBy"` // contains filtered or unexported fields }
Marker helps to mark alerts as silenced and/or inhibited. All methods are goroutine-safe.
type Marker 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) }
func NewMarker(r prometheus.Registerer) Marker
NewMarker returns an instance of a Marker implementation.
MultiError contains multiple errors and implements the error interface. Its zero value is ready to use. All its methods are goroutine safe.
type MultiError struct {
// contains filtered or unexported fields
}
func (e *MultiError) Add(err error)
Add adds an error to the MultiError.
func (e *MultiError) Error() string
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 (e *MultiError) Len() int
Len returns the number of errors added to the MultiError.
A MuteFunc is a function that implements the Muter interface.
type MuteFunc func(model.LabelSet) bool
func (f MuteFunc) Mutes(lset model.LabelSet) bool
Mutes implements the Muter interface.
A Muter determines whether a given label set is muted. Implementers that maintain an underlying Marker are expected to update it during a call of Mutes.
type Muter interface { Mutes(model.LabelSet) bool }
A Silence determines whether a given label set is muted.
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"` }
func (s *Silence) Expired() bool
Expired return if the silence is expired meaning that both StartsAt and EndsAt are equal
SilenceState is used as part of SilenceStatus.
type SilenceState string
Possible values for SilenceState.
const ( SilenceStateExpired SilenceState = "expired" SilenceStateActive SilenceState = "active" SilenceStatePending SilenceState = "pending" )
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.
SilenceStatus stores the state of a silence.
type SilenceStatus struct { State SilenceState `json:"state"` }