types

package
v0.15.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: Apache-2.0 Imports: 8 Imported by: 829

Documentation

Index

Constants

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

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.

Types

type Alert

type Alert struct {
	model.Alert

	// The authoritative timestamp.
	UpdatedAt time.Time
	Timeout   bool
}

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 (*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.

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

type AlertStatus added in v0.6.1

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

AlertStatus stores the state and values associated with an Alert.

type Marker

type Marker interface {
	SetActive(alert model.Fingerprint)
	SetInhibited(alert model.Fingerprint, ids ...string)
	SetSilenced(alert model.Fingerprint, ids ...string)

	Count(...AlertState) int

	Status(model.Fingerprint) AlertStatus
	Delete(model.Fingerprint)

	Unprocessed(model.Fingerprint) bool
	Active(model.Fingerprint) bool
	Silenced(model.Fingerprint) ([]string, bool)
	Inhibited(model.Fingerprint) ([]string, bool)
}

Marker helps to mark alerts as silenced and/or inhibited. All methods are goroutine-safe.

func NewMarker

func NewMarker() Marker

NewMarker returns an instance of a Marker implementation.

type Matcher

type Matcher struct {
	Name    string `json:"name"`
	Value   string `json:"value"`
	IsRegex bool   `json:"isRegex"`
	// contains filtered or unexported fields
}

Matcher defines a matching rule for the value of a given label.

func NewMatcher

func NewMatcher(name model.LabelName, value string) *Matcher

NewMatcher returns a new matcher that compares against equality of the given value.

func NewRegexMatcher

func NewRegexMatcher(name model.LabelName, re *regexp.Regexp) *Matcher

NewRegexMatcher returns a new matcher that compares values against a regular expression. The matcher is already initialized.

TODO(fabxc): refactor usage.

func (*Matcher) Init added in v0.5.0

func (m *Matcher) Init() error

Init internals of the Matcher. Must be called before using Match.

func (*Matcher) Match

func (m *Matcher) Match(lset model.LabelSet) bool

Match checks whether the label of the matcher has the specified matching value.

func (*Matcher) String

func (m *Matcher) String() string

func (*Matcher) Validate added in v0.5.0

func (m *Matcher) Validate() error

Validate returns true iff all fields of the matcher have valid values.

type Matchers

type Matchers []*Matcher

Matchers provides the Match and Fingerprint methods for a slice of Matchers. Matchers must always be sorted.

func NewMatchers added in v0.5.0

func NewMatchers(ms ...*Matcher) Matchers

NewMatchers returns the given Matchers sorted.

func (Matchers) Equal added in v0.5.0

func (ms Matchers) Equal(o Matchers) bool

Equal returns whether both Matchers are equal.

func (Matchers) Len added in v0.5.0

func (ms Matchers) Len() int

func (Matchers) Less added in v0.5.0

func (ms Matchers) Less(i, j int) bool

func (Matchers) Match

func (ms Matchers) Match(lset model.LabelSet) bool

Match checks whether all matchers are fulfilled against the given label set.

func (Matchers) String added in v0.6.0

func (ms Matchers) String() string

func (Matchers) Swap added in v0.5.0

func (ms Matchers) Swap(i, j int)

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

func (e *MultiError) Add(err error)

Add adds an error to the MultiError.

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 MuteFunc

type MuteFunc func(model.LabelSet) bool

A MuteFunc is a function that implements the Muter interface.

func (MuteFunc) Mutes

func (f MuteFunc) Mutes(lset model.LabelSet) bool

Mutes implements the Muter interface.

type Muter

type Muter interface {
	Mutes(model.LabelSet) bool
}

A Muter determines whether a given label set is muted.

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 affect
	// by the silence.
	Matchers 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"`
	// contains filtered or unexported fields
}

A Silence determines whether a given label set is muted.

func (*Silence) Expired added in v0.14.0

func (s *Silence) Expired() bool

Expired return if the silence is expired meaning that both StartsAt and EndsAt are equal

type SilenceState added in v0.7.0

type SilenceState string
const (
	SilenceStateExpired SilenceState = "expired"
	SilenceStateActive  SilenceState = "active"
	SilenceStatePending SilenceState = "pending"
)

func CalcSilenceState added in v0.7.0

func CalcSilenceState(start, end time.Time) SilenceState

type SilenceStatus added in v0.7.0

type SilenceStatus struct {
	State SilenceState `json:"state"`
}

Jump to

Keyboard shortcuts

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