alerter

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(name string, coreOpts ...core.Option) (func(), error)

Run the alerter

Types

type Alerter

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

Alerter is the main alerter stuct

func New

func New(c *core.Core) *Alerter

New creates an alerter

func (*Alerter) AddConditon

func (a *Alerter) AddConditon(c Conditon) error

AddConditon add an alerting condition

func (*Alerter) AddDestination

func (a *Alerter) AddDestination(d *Destination) error

AddDestination adds a destination (mail group, chat root) to alerting

func (*Alerter) AddEngine

func (a *Alerter) AddEngine(e Engine, err error) error

AddEngine add an engine (mail, chat etc) to alerting

func (*Alerter) AddRule

func (a *Alerter) AddRule(r *Rule) error

AddRule adds an alerting Rule

func (*Alerter) Run

func (a *Alerter) Run() (ret error)

Run the alerter

type Conditon

type Conditon interface {
	Kind() string
	DoAlert(*msg.AlertMsg, *viper.Viper) error
	CheckConfig(*viper.Viper) error
}

Conditon is a check if a alerting rule is triggered

type Destination

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

Destination is a endpoint for alerting (e.g. mail to a group)

type Engine

type Engine interface {
	Kind() string
	Send(*msg.AlertMsg, *Rule, *Destination) error
	// contains filtered or unexported methods
}

Engine sends out alerts

func NewMailer

func NewMailer() (Engine, error)

NewMailer registers a mail alerter on the event bus

func NewTeams

func NewTeams() (Engine, error)

NewTeams registers a Teams alerter on the event bus

type Mail

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

Mail is a mail alerter

func (*Mail) Kind

func (alt *Mail) Kind() string

Kind returns what kind of alerter engine it is

func (*Mail) Send

func (alt *Mail) Send(e *msg.AlertMsg, r *Rule, d *Destination) error

Send the alert

type Rule

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

Rule a rule for alerting

func (*Rule) DoAlert

func (r *Rule) DoAlert(mgs *msg.AlertMsg) error

DoAlert checks if the condtions a matched

type StatusCond

type StatusCond struct{}

StatusCond is a filter condtion based on the status

func (StatusCond) CheckConfig

func (StatusCond) CheckConfig(cfg *viper.Viper) error

CheckConfig checks if the config is valid

func (StatusCond) DoAlert

func (StatusCond) DoAlert(msg *msg.AlertMsg, cfg *viper.Viper) error

DoAlert checks if an alert should be send and returns an error if not

func (StatusCond) Kind

func (StatusCond) Kind() string

Kind is the name

type SzenarioCond

type SzenarioCond struct{}

SzenarioCond is a filter condtion based on the szenario name

func (SzenarioCond) CheckConfig

func (SzenarioCond) CheckConfig(cfg *viper.Viper) error

CheckConfig checks if the config is valid

func (SzenarioCond) DoAlert

func (SzenarioCond) DoAlert(msg *msg.AlertMsg, cfg *viper.Viper) error

DoAlert checks if an alert should be send and returns an error if not

func (SzenarioCond) Kind

func (SzenarioCond) Kind() string

Kind is the name

type Teams

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

Teams alerter

func (*Teams) Kind

func (teams *Teams) Kind() string

Kind returns what kind of alerter engine it is

func (*Teams) Send

func (teams *Teams) Send(e *msg.AlertMsg, r *Rule, d *Destination) error

Send the alert

Jump to

Keyboard shortcuts

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