alerts

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlertsFxTag = config.NameTag("AlertsFx")

AlertsFxTag - name tag for alerter in fx.

Functions

func Module added in v0.11.0

func Module() fx.Option

Module is a fx module that constructs annotated instance of alerts.Alerter.

Types

type Alert

type Alert struct {
	models.PostableAlert
}

Alert is a wrapper around models.PostableAlert with handy transform methods.

func AlertsFromLogs

func AlertsFromLogs(ld plog.Logs) []*Alert

AlertsFromLogs gets slice of alerts from OTEL Logs.

func NewAlert

func NewAlert() *Alert

NewAlert created new instance of Alert with StartsAt set to now.

func (*Alert) AsLogs

func (a *Alert) AsLogs() plog.Logs

AsLogs returns alert as OTEL Logs.

func (*Alert) Name

func (a *Alert) Name() string

Name gets the alert name from labels. Returns empty string if label not found.

func (*Alert) SetAnnotation

func (a *Alert) SetAnnotation(key, value string)

SetAnnotation sets a single annotation. It overwrites the previous value if exists.

func (*Alert) SetAnnotations

func (a *Alert) SetAnnotations(annotations map[string]string)

SetAnnotations overwrites all the current annotations with the one provided.

func (*Alert) SetLabel

func (a *Alert) SetLabel(key, value string)

SetLabel sets a single label. It overwrites the previous value if exists.

func (*Alert) SetLabels

func (a *Alert) SetLabels(labels map[string]string)

SetLabels overwrites all the current labels with the one provided. Caution: this will overwrite also name and severity!

func (*Alert) SetName

func (a *Alert) SetName(name string)

SetName sets the alert name in labels. Overwrites previous value if exists.

func (*Alert) SetSeverity

func (a *Alert) SetSeverity(severity string)

SetSeverity sets the alert severity in labels. Overwrites previous value if exists.

func (*Alert) Severity

func (a *Alert) Severity() string

Severity gets the alert severity from labels. Returns empty string if label not found.

type Alerter

type Alerter interface {
	AddAlert(*Alert)
	AlertsChan() <-chan *Alert
}

Alerter is responsible for receiving alerts and propagating them to the channel returned by AlertsChan().

func NewSimpleAlerter

func NewSimpleAlerter(channelSize int) Alerter

NewSimpleAlerter returns new instance of SimpleAlerter with channel of given size.

func ProvideAlerter

func ProvideAlerter(unmarshaller config.Unmarshaller) (Alerter, error)

ProvideAlerter creates an alerter.

type AlerterConfig

type AlerterConfig struct {
	// ChannelSize size of the alerts channel in the alerter. Alerts should be
	// consument from it quickly, so no big sizes are needed.
	ChannelSize int `json:"channel_size" validate:"gt=0" default:"100"`
}

AlerterConfig for alerter. swagger:model +kubebuilder:object:generate=true

func (*AlerterConfig) DeepCopy

func (in *AlerterConfig) DeepCopy() *AlerterConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlerterConfig.

func (*AlerterConfig) DeepCopyInto

func (in *AlerterConfig) DeepCopyInto(out *AlerterConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SimpleAlerter

type SimpleAlerter struct {
	// contains filtered or unexported fields
}

SimpleAlerter implements Alerter interface. It just simple propagates alerts to the channel.

func (*SimpleAlerter) AddAlert

func (a *SimpleAlerter) AddAlert(alert *Alert)

AddAlert adds alert to the channel.

func (*SimpleAlerter) AlertsChan

func (a *SimpleAlerter) AlertsChan() <-chan *Alert

AlertsChan returns the alerts channel.

Jump to

Keyboard shortcuts

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