Versions in this module Expand all Collapse all v0 v0.5.81 Sep 5, 2026 v0.5.9 Sep 8, 2026 Changes in this version type Worker + func (w *Worker) MetricsSnapshot() WorkerSnapshot + type WorkerSnapshot struct + Collapsed uint64 + Dispatched uint64 + Dropped uint64 + Failed uint64 + Matched uint64 + QueueCapacity int + QueueDepth int v0.5.8 Sep 3, 2026 Changes in this version + const ChannelEmail + const ChannelWebhook + const DefaultCooldown + const FieldBoolean + const FieldInteger + const FieldSecret + const FieldString + const MatchTypeRegex + const MatchTypeSubstring + const MaxNodeUUIDLen + const MaxPatternLen + const MaxRulesPerEnv + const NoEnvironmentID + const SignatureHeader + const SourceNodeInactive + const SourceNodeRecovered + const SourceQueryLog + const SourceResultLog + const SourceStatusLog + const TestSendTimeout + var ChannelRegistry = map[string]ChannelSpec + var ErrChannelDisabled = errors.New("alert channel disabled") + var ErrChannelExists = errors.New("alert channel already exists") + var ErrChannelNotFound = errors.New("alert channel not found") + var ErrInvalidChannelConfig = fmt.Errorf("invalid channel configuration") + var ErrInvalidChannelType = fmt.Errorf("invalid channel type") + var ErrInvalidRule = errors.New("invalid alert rule") + var ErrInvalidSource = errors.New("invalid alert source") + var ErrRuleExists = errors.New("alert rule already exists") + var ErrRuleNotFound = errors.New("alert rule not found") + var ErrTooManyRules = fmt.Errorf("too many alert rules for one environment (max %d)", MaxRulesPerEnv) + func CompileRule(rule AlertRule) (compiledRule, error) + func DecodeChannelIDs(raw string) ([]uint, error) + func DecodeChannelIDsOrEmpty(raw string) []uint + func EncodeChannelIDs(ids []uint) string + func MergeChannelSecrets(typ, prevCfgJSON, newCfgJSON string) (string, error) + func RedactedChannelConfig(typ, cfgJSON string) string + func RegisterWorkerMetrics(reg prometheus.Registerer, w *Worker) + func SupportedChannelTypes() []string + func TestSend(typ, cfgJSON string) error + func ValidateChannelConfig(typ, cfgJSON string) error + func ValidateChannelType(typ string) bool + func ValidateRule(rule AlertRule) error + type AlertChannel struct + Config string + Enabled bool + EnvironmentID uint + Info string + Name string + Type string + func (AlertChannel) TableName() string + type AlertHistory struct + ChannelID uint + ChannelName string + CreatedAt time.Time + Detail string + Entity string + Environment string + ID uint + NodeUUID string + RuleID uint + RuleName string + func (AlertHistory) TableName() string + type AlertRule struct + ChannelIDs string + CooldownMinutes int + Enabled bool + EnvironmentID uint + Info string + MatchField string + MatchType string + MatchValue string + Name string + NodeUUID string + Source string + StatusSeverity string + func (AlertRule) TableName() string + type ChannelSender interface + Name func() string + Send func(h Hit) error + type ChannelSpec struct + Build func(any) (ChannelSender, error) + Decode func(json.RawMessage) (any, error) + Description string + Fields []FieldSpec + HasSecret bool + SecretFields []string + Type string + type DispatchSink interface + Dispatch func(ctx context.Context, h Hit) error + type Dispatcher struct + func NewDispatcher(mgr *Manager) *Dispatcher + func (d *Dispatcher) Dispatch(ctx context.Context, h Hit) error + func (d *Dispatcher) RefreshChannel(id uint) + func (d *Dispatcher) Reset() + type EmailConfig struct + From string + Host string + Password string + Port int + StartTLS bool + To string + Username string + type FieldSpec struct + Default any + Help string + Label string + Name string + Placeholder string + Required bool + Type string + type Hit struct + Channels []uint + CooldownMinutes int + Detail string + Entity string + Environment string + EnvironmentID uint + NodeUUID string + RuleID uint + RuleName string + func TestHit() Hit + type InactiveWatcher struct + func NewInactiveWatcher(source NodeSource, store *Store, worker *Worker, client *redis.Client) *InactiveWatcher + func (w *InactiveWatcher) Run(stop <-chan struct{}, interval time.Duration) + func (w *InactiveWatcher) Sweep(ctx context.Context) + type IngestMatcher struct + func NewIngestMatcher(store *Store, worker *Worker) *IngestMatcher + func (m *IngestMatcher) MatchQueryResult(envID uint, environment, queryName string, result json.RawMessage, status int, ...) + func (m *IngestMatcher) MatchResultLogs(envID uint, environment string, logs []types.LogResultData) + func (m *IngestMatcher) MatchStatusLogs(envID uint, environment string, logs []types.LogStatusData) + type Manager struct + DB *gorm.DB + func NewManager(backend *gorm.DB) *Manager + func (m *Manager) CreateChannel(ch AlertChannel) (AlertChannel, error) + func (m *Manager) CreateRule(rule AlertRule) (AlertRule, error) + func (m *Manager) DeleteChannel(id uint) error + func (m *Manager) DeleteRule(id uint) error + func (m *Manager) GetChannel(id uint) (AlertChannel, error) + func (m *Manager) GetRule(id uint) (AlertRule, error) + func (m *Manager) ListChannels(envID *uint) ([]AlertChannel, error) + func (m *Manager) ListRules(envID *uint) ([]AlertRule, error) + func (m *Manager) LoadSnapshot(store *Store) error + func (m *Manager) PruneHistory(olderThan interface{}) (int64, error) + func (m *Manager) PruneHistoryWithRetention(retentionDays int64, now time.Time) (int64, error) + func (m *Manager) RecentHistory(limit int) ([]AlertHistory, error) + func (m *Manager) RecordHistory(h AlertHistory) error + func (m *Manager) UpdateChannel(id uint, ch AlertChannel) (AlertChannel, error) + func (m *Manager) UpdateRule(id uint, rule AlertRule) (AlertRule, error) + type NodeSnapshot struct + Active bool + Environment string + EnvironmentID uint + Hostname string + LastSeen time.Time + UUID string + type NodeSource interface + ActiveNodes func(ctx context.Context) ([]NodeSnapshot, error) + InactiveNodes func(ctx context.Context) ([]NodeSnapshot, error) + type RuleSet struct + func (rs *RuleSet) MatchQueryResult(envID uint, environment, queryName string, result json.RawMessage, status int, ...) []Hit + func (rs *RuleSet) MatchResultLogs(envID uint, environment string, logs []types.LogResultData) []Hit + func (rs *RuleSet) MatchStatusLogs(envID uint, environment string, logs []types.LogStatusData) []Hit + type State struct + func NewState(client *redis.Client) *State + func (s *State) Claim(ctx context.Context, h Hit) (bool, error) + func (s *State) Release(ctx context.Context, h Hit) + type Store struct + func NewStore() *Store + func (s *Store) Publish(rs *RuleSet) + func (s *Store) Snapshot() *RuleSet + type WebhookConfig struct + AllowPrivateTargets bool + InsecureSkipVerify bool + Secret string + TimeoutSeconds int + URL string + type Worker struct + func NewSyncWorker(store *Store, state claimGate, manager *Manager, sink DispatchSink) *Worker + func NewWorker(store *Store, state claimGate, manager *Manager, sink DispatchSink, ...) *Worker + func (w *Worker) Close() + func (w *Worker) Enqueue(hits []Hit) + func (w *Worker) QueueDepth() int + type WorkerMetrics struct + Collapsed atomic.Uint64 + Dispatched atomic.Uint64 + Dropped atomic.Uint64 + Failed atomic.Uint64 + Matched atomic.Uint64