Documentation
¶
Index ¶
- Constants
- Variables
- func Module() fx.Option
- func ParseSeverity(rawSeverity string) alertSeverity
- type Alert
- func (a *Alert) AlertChannels() []string
- func (a *Alert) AsLogs() plog.Logs
- func (a *Alert) Name() string
- func (a *Alert) PostableAlert() models.PostableAlert
- func (a *Alert) SetAlertChannels(alertChannels []string)
- func (a *Alert) SetAnnotation(key, value string)
- func (a *Alert) SetGeneratorURL(value string)
- func (a *Alert) SetLabel(key, value string)
- func (a *Alert) SetName(name string)
- func (a *Alert) SetResolveTimeout(t time.Duration)
- func (a *Alert) SetSeverity(severity alertSeverity)
- func (a *Alert) Severity() alertSeverity
- type AlertOption
- func WithAlertChannels(alertChannels []string) AlertOption
- func WithAnnotation(key, value string) AlertOption
- func WithGeneratorURL(value string) AlertOption
- func WithLabel(key, value string) AlertOption
- func WithName(name string) AlertOption
- func WithResolveTimeout(t time.Duration) AlertOption
- func WithSeverity(severity alertSeverity) AlertOption
- type Alerter
- type AlerterConfig
- type SimpleAlerter
Constants ¶
const (
// SeverityCrit describes an alert which requires immediate action.
SeverityCrit alertSeverity = "crit"
// SeverityWarn describes an alert which requires further observation.
SeverityWarn alertSeverity = "warn"
// SeverityInfo describes an alert which has informational purposes.
SeverityInfo alertSeverity = "info"
// SeverityUnknown describes an alert which does not have severity set.
SeverityUnknown alertSeverity = ""
)
Variables ¶
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.
func ParseSeverity ¶ added in v0.15.0
func ParseSeverity(rawSeverity string) alertSeverity
ParseSeverity returns alert severity parsed from string. Returns SeverityUnknown if parsing fails.
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 creates new instance of Alert with StartsAt set to now.
func NewAlertFromPostableAlert ¶ added in v0.15.0
func NewAlertFromPostableAlert(postabelAlert models.PostableAlert) *Alert
NewAlertFromPostableAlert creates new alert with given PostableAlert.
func (*Alert) AlertChannels ¶ added in v0.15.0
func (a *Alert) AlertChannels() []string
AlertChannels gets the alert channels from labels. Returns empty slice if label not found.
func (*Alert) Name ¶
func (a *Alert) Name() string
Name gets the alert name from labels. Returns empty string if label not found.
func (*Alert) PostableAlert ¶ added in v0.15.0
func (a *Alert) PostableAlert() models.PostableAlert
PostableAlert returns the underlying PostableAlert struct.
func (*Alert) SetAlertChannels ¶ added in v0.15.0
func (a *Alert) SetAlertChannels(alertChannels []string)
SetAlertChannels sets the alert channels in labels. Overwrites previous value if exists.
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) SetResolveTimeout ¶ added in v0.15.0
func (a *Alert) SetResolveTimeout(t time.Duration)
SetResolveTimeout sets a resolve timeout which says when given alert becomes resolved.
func (*Alert) SetSeverity ¶
func (a *Alert) SetSeverity(severity alertSeverity)
SetSeverity sets the alert severity in labels. Overwrites previous value if exists.
type AlertOption ¶ added in v0.13.0
type AlertOption func(*Alert)
AlertOption is a type for constructor options.
func WithAlertChannels ¶ added in v0.15.0
func WithAlertChannels(alertChannels []string) AlertOption
WithAlertChannels is an option function for constructor.
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 WithResolveTimeout ¶ added in v0.15.0
func WithResolveTimeout(t time.Duration) AlertOption
WithResolveTimeout is an option function for constructor.
func WithSeverity ¶ added in v0.13.0
func WithSeverity(severity alertSeverity) AlertOption
WithSeverity is an option function for constructor.
type Alerter ¶
type Alerter interface {
AddAlert(*Alert)
AlertsChan() <-chan *Alert
WithLabels(map[string]string) Alerter
}
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
// consumed 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.
func (*SimpleAlerter) WithLabels ¶ added in v0.22.0
func (a *SimpleAlerter) WithLabels(labels map[string]string) Alerter
WithLabels returns the alerter wrapper with specified labels.