Documentation
¶
Overview ¶
Package notify is the alert engine (T-74): the leader evaluates AlertRules against metrics (TSDB/livestate) and cluster events, and delivers firing and resolved notifications to NotificationChannels (webhook, Slack, email) with per-rule dedupe. Notifier failures never stall evaluation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Store Store
Metrics MetricSource
Opener Opener
Clock clock.Clock
Logger *slog.Logger
HTTP *http.Client
EmitEvent func(kind, severity, message string)
}
Config wires an Engine.
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email delivers notifications over SMTP. It is intentionally best-effort — SMTP is the flakiest channel — and honors the caller's context deadline for the initial connection.
func NewEmail ¶
func NewEmail(cfg EmailConfig) *Email
NewEmail builds an SMTP notifier from a resolved config.
type EmailConfig ¶
type EmailConfig struct {
Host string
Port uint32
Username string
Password string
From string
To string
StartTLS bool
}
EmailConfig is a resolved (secrets already unsealed) SMTP target.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates alert rules and delivers notifications (T-74).
type MetricSource ¶
MetricSource resolves the current value of a metric for a scope ("node:<id>" | "env:<id>" | "cluster"). ok is false when no data is available.
type Notification ¶
type Notification struct {
Rule string // rule name
Firing bool // true = firing, false = resolved
Severity string // "info" | "warning" | "error"
Scope string // "node:<id>" | "env:<id>" | "cluster" | event scope
Summary string // human-readable one-liner
At time.Time // when the engine decided this
// Metric rules only:
Metric string
Value float64
Threshold float64
Op string
// Event rules only:
EventKind string
}
Notification is one alert delivery — a rule firing or resolving.
type Notifier ¶
type Notifier interface {
Send(ctx context.Context, n Notification) error
}
Notifier delivers a Notification to one channel type.
type Opener ¶
type Opener interface {
Open(*zatterav1.EncryptedValue) ([]byte, error)
}
Opener decrypts a channel's sealed secret values.
type Slack ¶
type Slack struct {
// contains filtered or unexported fields
}
Slack posts a notification to a Slack Incoming Webhook URL as a simple text message. The URL itself is the secret and is never echoed into the payload.
type Store ¶
type Store interface {
ListAlertRules() []*zatterav1.AlertRule
ListNotificationChannels() []*zatterav1.NotificationChannel
ListEvents(limit int) []*zatterav1.Event
}
Store is the read side the engine needs (the leader's replicated state).
type Telegram ¶
type Telegram struct {
// contains filtered or unexported fields
}
Telegram delivers notifications via the Telegram Bot API sendMessage method. The bot token is the secret and is never echoed into the message body.
func NewTelegram ¶
NewTelegram builds a Telegram notifier for a bot token + target chat id.
type Webhook ¶
type Webhook struct {
// contains filtered or unexported fields
}
Webhook posts a JSON notification to a URL, optionally HMAC-signing the body. The payload never contains secret values.
func NewWebhook ¶
NewWebhook builds a webhook notifier. secret may be nil (unsigned).