Documentation
¶
Overview ¶
Package alerting is the RuneSight alerter: it evaluates stored alert rules against the cluster's LogStore on a rolling cadence, drives the ok → pending → firing → resolved state machine, and notifies on transitions (a Rune event always; the rule's channels on firing/resolved).
Rules are Core-tier by construction — a LogQL log selector counted over a window and compared to a threshold — so alerting behaves identically on the embedded, Loki, and ClickHouse backends. Absence/heartbeat alerts are the `== 0` (or `< 1`) case of the same shape.
Status is held in memory: a restart re-evaluates every rule within one interval, which is the operationally correct recovery anyway. Transitions are also recorded as Rune events, so history survives in the event log.
Index ¶
Constants ¶
const ( // DefaultInterval is the evaluation cadence for rules that don't set one. DefaultInterval = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alerter ¶
type Alerter struct {
// contains filtered or unexported fields
}
Alerter evaluates rules and dispatches notifications.
func New ¶
New constructs an Alerter. Call Start to begin the loop; Tick is exposed for tests and embedded callers.
type ChannelSource ¶
ChannelSource resolves channel names (implemented by repos.ChannelRepo).
type Options ¶
type Options struct {
Store observe.LogStore
Rules RuleSource
Channels ChannelSource
Events EventSink
Secrets SecretLookup
Logger log.Logger
// Now lets tests inject a clock.
Now func() time.Time
}
Options configures the Alerter. Store and Rules are required; the rest are optional (nil EventSink/SecretLookup degrade gracefully).
type RuleSource ¶
RuleSource lists the alert rules to evaluate (implemented by repos.AlertRuleRepo).
type SecretLookup ¶
SecretLookup resolves ${secret:namespace/name/key} references in channel URLs and headers at send time. Mirrors driverparams.SecretLookup.
type Status ¶
type Status struct {
Rule string
State string // ok | pending | firing
// Value is the last evaluated windowed count.
Value float64
// Since is when the current State began.
Since time.Time
// LastEval is the last evaluation time.
LastEval time.Time
// LastError is the last evaluation or delivery error ("" when healthy).
LastError string
}
Status is a rule's live evaluation state.