alert

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alerts

func Alerts(alerts ...*Alert) model.Alerts

Alerts turns a sequence of internal alerts into a list of exposable model.Alert structures.

func Validate added in v0.35.0

func Validate(a *model.Alert) error

Validate checks a model.Alert like model.Alert.Validate, but validates label names according to the matcher compatibility mode selected by the feature flags: classic mode rejects UTF-8 names, the other modes allow them. model.Alert.Validate follows the deprecated process-wide model.NameValidationScheme instead, which Alertmanager does not set.

Types

type Alert

type Alert struct {
	model.Alert

	// The authoritative timestamp.
	UpdatedAt time.Time
	Timeout   bool
	// contains filtered or unexported fields
}

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.

func New added in v0.35.0

func New(a model.Alert, updatedAt time.Time, timeout bool) *Alert

New returns an Alert wrapping the given model.Alert. All Alerts must be created through New so that derived internal state can be computed here. The labels must not be modified afterwards.

func (*Alert) Fingerprint added in v0.35.0

func (a *Alert) Fingerprint() model.Fingerprint

Fingerprint returns the fingerprint of the alert's labels, computed at construction time.

func (*Alert) LabelSet added in v0.35.0

func (a *Alert) LabelSet() labelset.LabelSet

LabelSet returns the alert's labels together with its fingerprint, so that consumers which only need the labels do not hash them again.

func (*Alert) Merge

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.

func (*Alert) Validate

func (a *Alert) Validate() error

Validate overrides the same method in model.Alert so that label names are validated according to the configured matcher compatibility mode. See Validate.

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

func (as AlertSlice) LogValue() slog.Value

LogValue implements slog.LogValuer. It returns a summary of alert counts per alertname, e.g. "MyAlert: 3, OtherAlert: 1".

func (AlertSlice) Swap

func (as AlertSlice) Swap(i, j int)

type AlertState

type AlertState string

AlertState is used as part of AlertStatus.

const (
	AlertStateUnprocessed AlertState = "unprocessed"
	AlertStateActive      AlertState = "active"
	AlertStateSuppressed  AlertState = "suppressed"
)

Possible values for AlertState.

func (AlertState) Compare added in v0.33.0

func (s AlertState) Compare(other AlertState) int

Compare returns -1 if s has lower priority than other, 0 if equal, and 1 if higher. Priority order: suppressed > active > unprocessed.

type AlertStatus

type AlertStatus struct {
	State       AlertState `json:"state"`
	SilencedBy  []string   `json:"silencedBy"`
	InhibitedBy []string   `json:"inhibitedBy"`
}

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

Jump to

Keyboard shortcuts

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