Help us shape the future of Go! Take the 2026 Go Developer Survey

alerts

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichEvent

func EnrichEvent(event *AlertEvent)

Types

type AlertEvent

type AlertEvent struct {
	AppName          string
	AppSlug          string
	Metric           string
	MetricDisplay    string // human-friendly metric name
	Value            float64
	ValueDisplay     string // human-friendly value (e.g. "26.3 GB")
	Threshold        float64
	ThresholdDisplay string // human-friendly threshold
	Operator         string
	Status           string // "firing", "resolved"
	FiredAt          time.Time
}

type AlertStoreReader

type AlertStoreReader interface {
	ListActiveAlertRules() ([]store.AlertRule, error)
	GetActiveAlert(ruleID int64) (*store.AlertHistory, error)
	CreateAlertHistory(ruleID int64, value float64, rule *store.AlertRule) (*store.AlertHistory, error)
	ResolveAlert(historyID int64) error
	GetWebhook(id int64) (*store.Webhook, error)
}

type AppLookup

type AppLookup interface {
	GetAppByID(id int64) (*store.App, error)
}

type BackupAlertEvent

type BackupAlertEvent struct {
	AppID     int64
	AppName   string
	Strategy  string
	Message   string
	EventType string // "backup_failed", "backup_success" or "backup_missed"
	FiredAt   time.Time
}

BackupAlertEvent represents a backup-related alert.

func (BackupAlertEvent) ToAlertEvent

func (b BackupAlertEvent) ToAlertEvent() AlertEvent

ToAlertEvent converts b for webhook delivery. Status is always "firing": the matching rule fired, whatever the backup outcome.

type Evaluator

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

func NewEvaluator

func NewEvaluator(s AlertStoreReader, appLookup AppLookup, mq MetricQuerier, dispatcher *WebhookDispatcher) *Evaluator

func (*Evaluator) DispatchBackupAlert

func (e *Evaluator) DispatchBackupAlert(event BackupAlertEvent)

DispatchBackupAlert sends a backup alert to all matching webhooks. A rule scoped to an app fires only for that app's events; a global rule fires for every app.

func (*Evaluator) EvaluateOnce

func (e *Evaluator) EvaluateOnce(ctx context.Context) error

func (*Evaluator) Run

func (e *Evaluator) Run(ctx context.Context, interval time.Duration)

type MetricQuerier

type MetricQuerier interface {
	QueryMetrics(appID *int64, rangeStr string) ([]metrics.MetricPoint, int, error)
}

type WebhookDispatcher

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

func NewWebhookDispatcher

func NewWebhookDispatcher() *WebhookDispatcher

func NewWebhookDispatcherAllowPrivate

func NewWebhookDispatcherAllowPrivate() *WebhookDispatcher

NewWebhookDispatcherAllowPrivate creates a dispatcher that skips SSRF checks (for testing).

func (*WebhookDispatcher) Send

func (d *WebhookDispatcher) Send(webhook store.Webhook, event AlertEvent) error

Jump to

Keyboard shortcuts

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