alert

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertStorage

type AlertStorage interface {
	SaveChannel(channel *core.AlertChannel) error
	GetChannel(id string) (*core.AlertChannel, error)
	ListChannels() ([]*core.AlertChannel, error)
	DeleteChannel(id string) error

	SaveRule(rule *core.AlertRule) error
	GetRule(id string) (*core.AlertRule, error)
	ListRules() ([]*core.AlertRule, error)
	DeleteRule(id string) error

	SaveEvent(event *core.AlertEvent) error
	ListEvents(soulID string, limit int) ([]*core.AlertEvent, error)

	SaveIncident(incident *core.Incident) error
	GetIncident(id string) (*core.Incident, error)
	ListActiveIncidents() ([]*core.Incident, error)
}

AlertStorage persists alert data

type ChannelDispatcher

type ChannelDispatcher interface {
	Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error
	Validate(config map[string]any) error
}

ChannelDispatcher sends notifications to a specific channel type

type DiscordDispatcher

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

DiscordDispatcher sends alerts to Discord via webhooks

func (*DiscordDispatcher) Send

func (d *DiscordDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to Discord

func (*DiscordDispatcher) Validate

func (d *DiscordDispatcher) Validate(config map[string]any) error

Validate validates Discord configuration

type EmailDispatcher

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

EmailDispatcher sends alerts via SMTP

func (*EmailDispatcher) Send

func (d *EmailDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an email alert

func (*EmailDispatcher) Validate

func (d *EmailDispatcher) Validate(config map[string]any) error

Validate validates email configuration

type Manager

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

Manager handles alert routing and delivery The high priest who receives omens and dispatches messengers

func NewManager

func NewManager(storage AlertStorage, logger *slog.Logger) *Manager

NewManager creates a new alert manager

func (*Manager) AcknowledgeIncident

func (m *Manager) AcknowledgeIncident(incidentID, userID string) error

AcknowledgeIncident acknowledges an incident

func (*Manager) DeleteChannel

func (m *Manager) DeleteChannel(id string) error

DeleteChannel removes an alert channel

func (*Manager) DeleteRule

func (m *Manager) DeleteRule(id string) error

DeleteRule removes an alert rule

func (*Manager) GetChannel

func (m *Manager) GetChannel(id string) (*core.AlertChannel, error)

GetChannel returns a channel by ID

func (*Manager) GetRule

func (m *Manager) GetRule(id string) (*core.AlertRule, error)

GetRule returns a rule by ID

func (*Manager) GetStats

func (m *Manager) GetStats() core.AlertManagerStats

GetStats returns alert manager statistics

func (*Manager) ListActiveIncidents

func (m *Manager) ListActiveIncidents() []*core.Incident

ListActiveIncidents returns active incidents

func (*Manager) ListChannels

func (m *Manager) ListChannels() []*core.AlertChannel

ListChannels returns all registered channels

func (*Manager) ListRules

func (m *Manager) ListRules() []*core.AlertRule

ListRules returns all registered rules

func (*Manager) ProcessJudgment

func (m *Manager) ProcessJudgment(soul *core.Soul, prevStatus core.SoulStatus, judgment *core.Judgment)

ProcessJudgment evaluates a judgment against alert rules

func (*Manager) RegisterChannel

func (m *Manager) RegisterChannel(channel *core.AlertChannel) error

RegisterChannel adds or updates an alert channel

func (*Manager) RegisterRule

func (m *Manager) RegisterRule(rule *core.AlertRule) error

RegisterRule adds or updates an alert rule

func (*Manager) ResolveIncident

func (m *Manager) ResolveIncident(incidentID, userID string) error

ResolveIncident marks an incident as resolved

func (*Manager) Start

func (m *Manager) Start() error

Start starts the alert manager

func (*Manager) Stop

func (m *Manager) Stop() error

Stop stops the alert manager

type NtfyDispatcher

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

NtfyDispatcher sends alerts to Ntfy

func (*NtfyDispatcher) Send

func (d *NtfyDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to Ntfy

func (*NtfyDispatcher) Validate

func (d *NtfyDispatcher) Validate(config map[string]any) error

Validate validates Ntfy configuration

type OpsGenieDispatcher

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

OpsGenieDispatcher sends alerts to OpsGenie

func (*OpsGenieDispatcher) Send

func (d *OpsGenieDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to OpsGenie

func (*OpsGenieDispatcher) Validate

func (d *OpsGenieDispatcher) Validate(config map[string]any) error

Validate validates OpsGenie configuration

type PagerDutyDispatcher

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

PagerDutyDispatcher sends alerts to PagerDuty

func (*PagerDutyDispatcher) Send

func (d *PagerDutyDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to PagerDuty

func (*PagerDutyDispatcher) Validate

func (d *PagerDutyDispatcher) Validate(config map[string]any) error

Validate validates PagerDuty configuration

type SMSDispatcher

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

SMSDispatcher sends alerts via SMS (Twilio/Vonage)

func (*SMSDispatcher) Send

func (d *SMSDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an SMS alert

func (*SMSDispatcher) Validate

func (d *SMSDispatcher) Validate(config map[string]any) error

Validate validates SMS configuration

type SlackDispatcher

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

SlackDispatcher sends alerts to Slack via webhooks

func (*SlackDispatcher) Send

func (d *SlackDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to Slack

func (*SlackDispatcher) Validate

func (d *SlackDispatcher) Validate(config map[string]any) error

Validate validates Slack configuration

type TelegramDispatcher

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

TelegramDispatcher sends alerts to Telegram

func (*TelegramDispatcher) Send

func (d *TelegramDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to Telegram

func (*TelegramDispatcher) Validate

func (d *TelegramDispatcher) Validate(config map[string]any) error

Validate validates Telegram configuration

type WebHookDispatcher

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

WebHookDispatcher sends alerts to generic webhooks

func (*WebHookDispatcher) Send

func (d *WebHookDispatcher) Send(ctx context.Context, event *core.AlertEvent, channel *core.AlertChannel) error

Send sends an alert to a webhook

func (*WebHookDispatcher) Validate

func (d *WebHookDispatcher) Validate(config map[string]any) error

Validate validates webhook configuration

Jump to

Keyboard shortcuts

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