alerts

package
v0.14.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 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 {
	// contains filtered or unexported fields
}

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(opts ...AlertOption) *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) SetGeneratorURL added in v0.14.0

func (a *Alert) SetGeneratorURL(value string)

SetGeneratorURL sets a generator URL. It overwrites the previous value if exists.

func (*Alert) SetLabel

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

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

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 AlertOption added in v0.13.0

type AlertOption func(*Alert)

AlertOption is a type for constructor options.

func WithAnnotation added in v0.13.0

func WithAnnotation(key, value string) AlertOption

WithAnnotation is an option function for constructor.

func WithGeneratorURL added in v0.14.0

func WithGeneratorURL(value string) AlertOption

WithGeneratorURL is an option function for constructor.

func WithLabel added in v0.13.0

func WithLabel(key, value string) AlertOption

WithLabel is an option function for constructor.

func WithName added in v0.13.0

func WithName(name string) AlertOption

WithName is an option function for constructor.

func WithSeverity added in v0.13.0

func WithSeverity(severity string) AlertOption

WithSeverity is an option function for constructor.

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