alerts

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertNotification added in v1.2.0

type AlertNotification struct {
	AlertID        models.AlertID
	AlertName      string
	Description    string
	Status         models.AlertStatus
	Severity       models.AlertSeverity
	TeamID         models.TeamID
	TeamName       string
	SourceID       models.SourceID
	SourceName     string
	Value          float64
	ThresholdOp    models.AlertThresholdOperator
	ThresholdValue float64
	FrequencySecs  int
	LookbackSecs   int
	Query          string
	ConditionJSON  string
	Labels         map[string]string
	Annotations    map[string]string
	TriggeredAt    time.Time
	ResolvedAt     *time.Time
	GeneratorURL   string
	Message        string

	RecipientUserIDs        []models.UserID
	RecipientEmails         []string
	MissingRecipientUserIDs []models.UserID
	RecipientResolutionErr  string
	WebhookURLs             []string
}

AlertNotification represents a fully resolved notification payload ready for delivery.

type AlertSender

type AlertSender interface {
	Send(ctx context.Context, notification AlertNotification) error
}

AlertSender abstracts the delivery mechanism for alert notifications.

func NewMultiSender added in v1.2.0

func NewMultiSender(senders ...AlertSender) AlertSender

type DynamicEmailSender added in v1.2.0

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

func NewDynamicEmailSender added in v1.2.0

func NewDynamicEmailSender(settings SettingsReader, logger *slog.Logger) *DynamicEmailSender

func (*DynamicEmailSender) Send added in v1.2.0

func (d *DynamicEmailSender) Send(ctx context.Context, notification AlertNotification) error

type DynamicWebhookSender added in v1.2.0

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

func NewDynamicWebhookSender added in v1.2.0

func NewDynamicWebhookSender(settings SettingsReader, logger *slog.Logger) *DynamicWebhookSender

func (*DynamicWebhookSender) Send added in v1.2.0

func (d *DynamicWebhookSender) Send(ctx context.Context, notification AlertNotification) error

type EmailSender added in v1.2.0

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

func NewEmailSender added in v1.2.0

func NewEmailSender(opts EmailSenderOptions) *EmailSender

func (*EmailSender) Send added in v1.2.0

func (s *EmailSender) Send(ctx context.Context, notification AlertNotification) error

type EmailSenderOptions added in v1.2.0

type EmailSenderOptions struct {
	Host          string
	Port          int
	Username      string
	Password      string
	From          string
	ReplyTo       string
	Security      string
	Timeout       time.Duration
	SkipTLSVerify bool
	Logger        *slog.Logger
}

type Manager

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

Manager coordinates alert evaluation and dispatches notifications when thresholds are met.

func NewManager

func NewManager(opts Options) *Manager

NewManager constructs a new alert manager instance.

func (*Manager) ManualResolve

func (m *Manager) ManualResolve(ctx context.Context, alertID models.AlertID, message string) error

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start launches the evaluation loop. It is a no-op when alerting is disabled.

func (*Manager) Stop

func (m *Manager) Stop()

Stop signals the manager to stop evaluating alerts.

type MultiSender added in v1.2.0

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

func (MultiSender) Send added in v1.2.0

func (m MultiSender) Send(ctx context.Context, notification AlertNotification) error

type Options

type Options struct {
	Config     config.AlertsConfig
	DB         *sqlite.DB
	ClickHouse *clickhouse.Manager
	Logger     *slog.Logger
	Sender     AlertSender
}

Options encapsulates the dependencies required to run the alerting manager.

type SettingsReader added in v1.2.0

type SettingsReader interface {
	GetSettingWithDefault(ctx context.Context, key, defaultValue string) string
	GetIntSetting(ctx context.Context, key string, defaultValue int) int
	GetBoolSetting(ctx context.Context, key string, defaultValue bool) bool
	GetDurationSetting(ctx context.Context, key string, defaultValue time.Duration) time.Duration
}

type WebhookSender added in v1.2.0

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

func NewWebhookSender added in v1.2.0

func NewWebhookSender(opts WebhookSenderOptions) *WebhookSender

func (*WebhookSender) Send added in v1.2.0

func (s *WebhookSender) Send(ctx context.Context, notification AlertNotification) error

type WebhookSenderOptions added in v1.2.0

type WebhookSenderOptions struct {
	Timeout       time.Duration
	SkipTLSVerify bool
	Logger        *slog.Logger
}

Jump to

Keyboard shortcuts

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