alerting

package
v0.9.19 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrometheusAlert

func GetPrometheusAlert(a *model.Alert) *model.PrometheusAlert

func HandleAlerts

func HandleAlerts(databaseContext *model.DatabaseContext) func(item model.PharosImageMeta) model.PharosImageMeta

Types

type AlertGroup

type AlertGroup struct {
	GroupLabels     map[string]string
	Logger          *zerolog.Logger
	Alerts          []*model.Alert
	GroupInfo       map[string]*GroupInfo
	DatabaseContext *model.DatabaseContext
	AlertsUpdated   bool
}

A grouped alert is dependend on a route.

func NewAlertGroup

func NewAlertGroup(routeConfig *model.RouteConfig, groupLabels map[string]string, databaseContext *model.DatabaseContext) *AlertGroup

func (*AlertGroup) GetAlertPayload

func (ag *AlertGroup) GetAlertPayload(receiverName string) (*model.AlertPayload, error)

func (*AlertGroup) GetHash

func (ag *AlertGroup) GetHash() string

return a hash of this AlertGroup, to see if it has changed

func (*AlertGroup) GetWebhookPayload

func (ag *AlertGroup) GetWebhookPayload(webhook *WebHook, receiverName string) (*model.WebHookPayload, error)

func (*AlertGroup) SendWebhookAlerts

func (ag *AlertGroup) SendWebhookAlerts(webhook *WebHook, route *Route) error

func (*AlertGroup) String

func (ag *AlertGroup) String() string

type Alerter

type Alerter struct {
	AlertingConfig  *model.AlertingConfig
	Logger          *zerolog.Logger
	DatabaseContext *model.DatabaseContext
	RootRoute       *Route
}

func NewAlerter

func NewAlerter(databaseContext *model.DatabaseContext, config *model.AlertingConfig) *Alerter

func (*Alerter) Run

func (al *Alerter) Run()

type GroupInfo

type GroupInfo struct {
	LastSentAt     time.Time
	LastSentHash   string // Hash of the last sent alert payload, so we know it has changed.
	ResolutionSent bool
}

type Matcher

type Matcher struct {
	MatcherString string
	Label         string
	Operator      string
	Value         string
}

func NewMatcher

func NewMatcher(matcherString string) (*Matcher, error)

func (*Matcher) Matches

func (m *Matcher) Matches(alert model.Alert) bool

type Receiver

type Receiver struct {
	Config   *model.ReceiverConfig
	WebHooks []*WebHook
	Logging  *zerolog.Logger
}

func NewReceiver

func NewReceiver(config *model.ReceiverConfig) *Receiver

func (*Receiver) SendAlerts

func (r *Receiver) SendAlerts(alertGroup *AlertGroup, route *Route) error

type Route

type Route struct {
	RouteConfig    *model.RouteConfig
	Receiver       *Receiver
	Alerts         []*model.Alert
	AlertGroups    map[string]*AlertGroup
	Logger         *zerolog.Logger
	RepeatInterval time.Duration
	Path           string // Path to the route, used for storing data about when an alert was sent the last time.
	// B-Tree structure
	FirstChild      *Route
	NextSibling     *Route
	DatabaseContext *model.DatabaseContext
}

func NewRoute

func NewRoute(routeConfig *model.RouteConfig, alertingConfig *model.AlertingConfig, path string, databaseContext *model.DatabaseContext) *Route

func (*Route) GetMatchedAlerts

func (r *Route) GetMatchedAlerts(alerts []*model.Alert) []*model.Alert

func (*Route) GetRouteConfigForChild

func (r *Route) GetRouteConfigForChild(childRouteconfig model.RouteConfig) *model.RouteConfig

func (*Route) GetSiblingAlerts

func (r *Route) GetSiblingAlerts(alerts []*model.Alert) []*model.Alert

func (*Route) GetUnmatchedAlerts

func (r *Route) GetUnmatchedAlerts(alerts []*model.Alert) []*model.Alert

func (*Route) SendAlerts

func (r *Route) SendAlerts(alerts []*model.Alert)

func (*Route) String

func (r *Route) String() string

func (*Route) UpdateAlertGroups

func (r *Route) UpdateAlertGroups()

type WebHook

type WebHook struct {
	WebHookConfig *model.WebhookConfig
	Logger        *zerolog.Logger
}

func NewWebHook

func NewWebHook(webHookConfig *model.WebhookConfig) *WebHook

func (*WebHook) String

func (wh *WebHook) String() string

Jump to

Keyboard shortcuts

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