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 ParseSeverity ¶
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 ¶
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 ¶
func NewAlertFromPostableAlert(postabelAlert models.PostableAlert) *Alert
NewAlertFromPostableAlert creates new alert with given PostableAlert.
func (*Alert) AlertChannels ¶
AlertChannels gets the alert channels from labels. Returns empty slice if label not found.
func (*Alert) PostableAlert ¶
func (a *Alert) PostableAlert() models.PostableAlert
PostableAlert returns the underlying PostableAlert struct.
func (*Alert) SetAlertChannels ¶
SetAlertChannels sets the alert channels in labels. Overwrites previous value if exists.
func (*Alert) SetAnnotation ¶
SetAnnotation sets a single annotation. It overwrites the previous value if exists.
func (*Alert) SetGeneratorURL ¶
SetGeneratorURL sets a generator URL. It overwrites the previous value if exists.
func (*Alert) SetResolveTimeout ¶
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 ¶
type AlertOption func(*Alert)
AlertOption is a type for constructor options.
func WithAlertChannels ¶
func WithAlertChannels(alertChannels []string) AlertOption
WithAlertChannels is an option function for constructor.
func WithAnnotation ¶
func WithAnnotation(key, value string) AlertOption
WithAnnotation is an option function for constructor.
func WithGeneratorURL ¶
func WithGeneratorURL(value string) AlertOption
WithGeneratorURL is an option function for constructor.
func WithLabel ¶
func WithLabel(key, value string) AlertOption
WithLabel is an option function for constructor.
func WithName ¶
func WithName(name string) AlertOption
WithName is an option function for constructor.
func WithResolveTimeout ¶
func WithResolveTimeout(t time.Duration) AlertOption
WithResolveTimeout is an option function for constructor.
func WithSeverity ¶
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 ¶
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 ¶
func (a *SimpleAlerter) WithLabels(labels map[string]string) Alerter
WithLabels returns the alerter wrapper with specified labels.