alert

package
v1.43.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const JITTER_FACTOR = 7000

7 seconds jitter factor for evaluation among different rules

Variables

This section is empty.

Functions

func SendAlert

func SendAlert(ctx context.Context, alertManagerURL string, alerts []config.PostableAlert) error

Types

type AlertEvaluator

type AlertEvaluator struct {
	DB    *metrics.TimeSeriesDB
	Rules []config.AlertRule
	// contains filtered or unexported fields
}

AlertEvaluator send new or resolved alerts to alertmanager use alertmanager to implement deduplication, notification it connect TSDB, evaluate all rules to with its own interval for each rule, the query result should contains fields that can be compared with threshold, and other fields which are used to generate alert labelSet and description The query and description can use Go templates with the rule data and query results

func NewAlertEvaluator

func NewAlertEvaluator(ctx context.Context, db *metrics.TimeSeriesDB, rules []config.AlertRule, alertManagerURL string) *AlertEvaluator

func (*AlertEvaluator) StartEvaluate

func (e *AlertEvaluator) StartEvaluate() error

func (*AlertEvaluator) StopEvaluate

func (e *AlertEvaluator) StopEvaluate() error

func (*AlertEvaluator) UpdateAlertRules

func (e *AlertEvaluator) UpdateAlertRules(rules []config.AlertRule) error

type AlertStatus

type AlertStatus struct {
	State       string   `json:"state"`
	SilencedBy  []string `json:"silencedBy"`
	InhibitedBy []string `json:"inhibitedBy"`
	MutedBy     []string `json:"mutedBy"`
}

type GettableAlert

type GettableAlert struct {
	config.Alert
	Annotations LabelSet    `json:"annotations"`
	Receivers   []Receiver  `json:"receivers"`
	Fingerprint string      `json:"fingerprint"`
	StartsAt    time.Time   `json:"startsAt"`
	UpdatedAt   time.Time   `json:"updatedAt"`
	EndsAt      time.Time   `json:"endsAt"`
	Status      AlertStatus `json:"status"`
}

type LabelSet

type LabelSet map[string]string

type Matcher

type Matcher struct {
	Name    string `json:"name"`
	Value   string `json:"value"`
	IsRegex bool   `json:"isRegex"`
	IsEqual bool   `json:"isEqual,omitempty"`
}

type Receiver

type Receiver struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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