model

package
v0.0.0-...-8ca999e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TIMEOUT_INTERVAL = 12 * time.Hour

DEFAULT_TIMEOUT_INTERVAL is the length of time after first seeing an alert that we time out the alert if we haven't seen any other information about it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	// ID is the unique ID of the alert.
	ID string `json:"id,omitempty"`

	// Labels defines the metadata on the alert that is used for deduplication purposes.
	Labels Labels `json:"labels"`

	// Annotations defines them metadata on the alert that _isn't_ used for deduplication. This can be links etc.
	Annotations map[string]string `json:"annotations"`

	// Status is the status of the alert in the system.
	Status AlertStatus `json:"status"`

	// Acknowledgement is the details if this alert has fired and been acknowledged.
	Acknowledgement *AlertAcknowledgement `json:"acknowledgement,omitempty"`

	// StartTime is when the alert first started firing.
	StartTime time.Time `json:"startsAt"`

	// EndTime is when the alert ended (either timed out or resolved).
	EndTime time.Time `json:"endsAt"`

	// TimeOutDeadline is when the alert should be marked as timed out, assuming no further messages come in.
	TimeOutDeadline time.Time `json:"timeOutDeadline,omitempty"`

	// LastNotifyTime is the time that a notification for this alert was last sent.
	LastNotifyTime time.Time `json:"-"`
}

Alert is the _operational state_ of the alert. As opposed to the protobuf structs that are the values being transmitted, this struct contains all the state that might be ascertained by Kiora through interactions with other models (e.g. silences).

func (*Alert) Acknowledge

func (a *Alert) Acknowledge(ack *AlertAcknowledgement) error

Acknowledge marks this alert as Acknowledged with the given metadata.

func (*Alert) Field

func (a *Alert) Field(name string) (any, error)

func (*Alert) Fields

func (a *Alert) Fields() map[string]any

func (*Alert) Materialise

func (a *Alert) Materialise() error

Materialise fills in any missing fields in the alert with sensible defaults.

func (*Alert) UnmarshalJSON

func (a *Alert) UnmarshalJSON(b []byte) error

type AlertAcknowledgement

type AlertAcknowledgement struct {
	Creator string `json:"creator"`
	Comment string `json:"comment"`
}

AlertAcknowledgement is the metadata provided when an operator acknowledges an alert.

func (*AlertAcknowledgement) Field

func (a *AlertAcknowledgement) Field(name string) (any, error)

func (*AlertAcknowledgement) Fields

func (a *AlertAcknowledgement) Fields() map[string]any

type AlertStatus

type AlertStatus string

AlertStatus is the current status of an alert in Kiora.

const (
	// AlertStatusFiring marks alerts that are currently active.
	AlertStatusFiring AlertStatus = "firing"

	// AlertStatusAcked marks alerts that are firing, but have been acknowledged by a human.
	AlertStatusAcked AlertStatus = "acked"

	// AlertStatusResolved marks alerts that were firing but have now been resolved.
	AlertStatusResolved AlertStatus = "resolved"

	// AlertStatusTimedOut marks alerts that we never got a resolved notification for, but hit their expiry times.
	AlertStatusTimedOut AlertStatus = "timed out"

	// AlertStatusSilenced marks alerts that have been silenced by one or more silences.
	AlertStatusSilenced AlertStatus = "silenced"
)

type Labels

type Labels map[string]string

Labels is a utility type encapsulating a map[string]string that can be hashed.

func (Labels) Bytes

func (s Labels) Bytes() []byte

func (Labels) Equal

func (s Labels) Equal(other Labels) bool

func (Labels) Hash

func (s Labels) Hash() LabelsHash

Hash takes an xxhash64 across all the labels in the map.

func (Labels) Subset

func (s Labels) Subset(labelNames ...string) Labels

Subset returns a new Labels object with only the keys specified in labelNames.

type LabelsHash

type LabelsHash = uint64

type Matcher

type Matcher struct {
	Label      string `json:"label"`
	Value      string `json:"value"`
	IsRegex    bool   `json:"isRegex"`
	IsNegative bool   `json:"isNegative"`
	// contains filtered or unexported fields
}

func LabelValueEqualMatcher

func LabelValueEqualMatcher(label, value string) Matcher

func LabelValueRegexMatcher

func LabelValueRegexMatcher(label, regex string) (Matcher, error)

func (*Matcher) Matches

func (m *Matcher) Matches(labels Labels) bool

func (*Matcher) Negate

func (m *Matcher) Negate() *Matcher

func (*Matcher) UnmarshalJSON

func (m *Matcher) UnmarshalJSON(b []byte) error

func (*Matcher) UnmarshalText

func (m *Matcher) UnmarshalText(raw string) error

type Silence

type Silence struct {
	// ID is the unique identifier of the silence.
	ID string `json:"id"`

	// By is the user that created the silence.
	Creator string `json:"creator"`

	// Comment is a comment about the silence.
	Comment string `json:"comment"`

	// StartTime is the time at which the silence starts.
	StartTime time.Time `json:"startsAt"`

	// EndTime is the time at which the silence ends.
	EndTime time.Time `json:"endsAt"`

	// Matchers is a list of matchers that must all match an alert for it to be silenced.
	Matchers []Matcher `json:"matchers"`
}

func NewSilence

func NewSilence(creator, comment string, matchers []Matcher, startTime, endTime time.Time) (Silence, error)

func (*Silence) Field

func (s *Silence) Field(name string) (any, error)

func (*Silence) Fields

func (s *Silence) Fields() map[string]any

func (*Silence) IsActive

func (s *Silence) IsActive() bool

func (*Silence) Matches

func (s *Silence) Matches(l Labels) bool

Jump to

Keyboard shortcuts

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