alerting

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID          string                 `json:"id"`
	Type        AlertType              `json:"type"`
	Severity    AlertSeverity          `json:"severity"`
	Title       string                 `json:"title"`
	Message     string                 `json:"message"`
	Details     map[string]interface{} `json:"details"`
	Source      string                 `json:"source"`
	Service     string                 `json:"service"`
	Timestamp   time.Time              `json:"timestamp"`
	Resolved    bool                   `json:"resolved"`
	ResolvedAt  *time.Time             `json:"resolved_at,omitempty"`
	Tags        map[string]string      `json:"tags"`
	Metadata    map[string]interface{} `json:"metadata"`
	Fingerprint string                 `json:"fingerprint"`
}

Alert represents an alert notification

func NewAlert

func NewAlert(alertType AlertType, severity AlertSeverity, title, message string) *Alert

NewAlert creates a new alert

func (*Alert) GetFingerprint

func (a *Alert) GetFingerprint() string

GetFingerprint returns the alert fingerprint for deduplication

func (*Alert) IsResolved

func (a *Alert) IsResolved() bool

IsResolved returns true if the alert is resolved

func (*Alert) Resolve

func (a *Alert) Resolve() *Alert

Resolve marks the alert as resolved

func (*Alert) WithDetail

func (a *Alert) WithDetail(key string, value interface{}) *Alert

WithDetail adds a single detail to the alert

func (*Alert) WithDetails

func (a *Alert) WithDetails(details map[string]interface{}) *Alert

WithDetails adds details to the alert

func (*Alert) WithFingerprint

func (a *Alert) WithFingerprint(fingerprint string) *Alert

WithFingerprint sets the alert fingerprint

func (*Alert) WithMetadata

func (a *Alert) WithMetadata(metadata map[string]interface{}) *Alert

WithMetadata adds metadata to the alert

func (*Alert) WithService

func (a *Alert) WithService(service string) *Alert

WithService sets the alert service

func (*Alert) WithSource

func (a *Alert) WithSource(source string) *Alert

WithSource sets the alert source

func (*Alert) WithTag

func (a *Alert) WithTag(key, value string) *Alert

WithTag adds a single tag to the alert

func (*Alert) WithTags

func (a *Alert) WithTags(tags map[string]string) *Alert

WithTags adds tags to the alert

type AlertAction

type AlertAction struct {
	Type       string                 `json:"type"`
	Notifier   string                 `json:"notifier"`
	Template   string                 `json:"template"`
	Parameters map[string]interface{} `json:"parameters"`
}

AlertAction defines an action to take when an alert is triggered

type AlertCondition

type AlertCondition struct {
	Field    string      `json:"field"`
	Operator string      `json:"operator"`
	Value    interface{} `json:"value"`
}

AlertCondition defines a condition for alert rules

type AlertManager

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

AlertManager manages alert notifications and rules

func NewAlertManager

func NewAlertManager(config *AlertManagerConfig, logger logger.Logger, metrics shared.Metrics) *AlertManager

NewAlertManager creates a new alert manager

func (*AlertManager) AddNotifier

func (am *AlertManager) AddNotifier(name string, notifier AlertNotifier) error

AddNotifier adds a notifier to the alert manager

func (*AlertManager) AddRule

func (am *AlertManager) AddRule(rule *AlertRule) error

AddRule adds an alert rule

func (*AlertManager) GetActiveAlerts

func (am *AlertManager) GetActiveAlerts() []*Alert

GetActiveAlerts returns all active alerts

func (*AlertManager) GetNotifiers

func (am *AlertManager) GetNotifiers() map[string]AlertNotifier

GetNotifiers returns all registered notifiers

func (*AlertManager) GetRules

func (am *AlertManager) GetRules() []*AlertRule

GetRules returns all alert rules

func (*AlertManager) ProcessHealthResults

func (am *AlertManager) ProcessHealthResults(ctx context.Context, results []*health.HealthResult) error

ProcessHealthResults processes health results and triggers alerts

func (*AlertManager) RemoveNotifier

func (am *AlertManager) RemoveNotifier(name string) error

RemoveNotifier removes a notifier from the alert manager

func (*AlertManager) RemoveRule

func (am *AlertManager) RemoveRule(name string) error

RemoveRule removes an alert rule

func (*AlertManager) SendAlert

func (am *AlertManager) SendAlert(ctx context.Context, alert *Alert) error

SendAlert sends an alert notification

func (*AlertManager) Start

func (am *AlertManager) Start(ctx context.Context) error

Start starts the alert manager

func (*AlertManager) Stop

func (am *AlertManager) Stop(ctx context.Context) error

Stop stops the alert manager

func (*AlertManager) Test

func (am *AlertManager) Test(ctx context.Context) error

Test tests all notifiers

type AlertManagerConfig

type AlertManagerConfig struct {
	Enabled             bool              `yaml:"enabled" json:"enabled"`
	DefaultSeverity     AlertSeverity     `yaml:"default_severity" json:"default_severity"`
	BatchSize           int               `yaml:"batch_size" json:"batch_size"`
	BatchTimeout        time.Duration     `yaml:"batch_timeout" json:"batch_timeout"`
	RetryAttempts       int               `yaml:"retry_attempts" json:"retry_attempts"`
	RetryDelay          time.Duration     `yaml:"retry_delay" json:"retry_delay"`
	DeduplicationWindow time.Duration     `yaml:"deduplication_window" json:"deduplication_window"`
	GlobalTags          map[string]string `yaml:"global_tags" json:"global_tags"`
	Templates           map[string]string `yaml:"templates" json:"templates"`
}

AlertManagerConfig contains configuration for the alert manager

func DefaultAlertManagerConfig

func DefaultAlertManagerConfig() *AlertManagerConfig

DefaultAlertManagerConfig returns default configuration

type AlertNotifier

type AlertNotifier interface {
	// Name returns the name of the notifier
	Name() string

	// Send sends an alert notification
	Send(ctx context.Context, alert *Alert) error

	// SendBatch sends multiple alerts in a batch
	SendBatch(ctx context.Context, alerts []*Alert) error

	// Test tests the notification system
	Test(ctx context.Context) error

	// Close closes the notifier
	Close() error
}

AlertNotifier defines the interface for alert notification systems

type AlertRule

type AlertRule struct {
	Name       string                 `json:"name"`
	Enabled    bool                   `json:"enabled"`
	Services   []string               `json:"services"`
	Statuses   []health.HealthStatus  `json:"statuses"`
	Severity   AlertSeverity          `json:"severity"`
	Threshold  int                    `json:"threshold"` // Number of failures
	Duration   time.Duration          `json:"duration"`  // Time window
	Cooldown   time.Duration          `json:"cooldown"`  // Cooldown period
	Template   string                 `json:"template"`  // Message template
	Tags       map[string]string      `json:"tags"`
	Metadata   map[string]interface{} `json:"metadata"`
	Conditions []AlertCondition       `json:"conditions"`
	Actions    []AlertAction          `json:"actions"`
	LastFired  time.Time              `json:"last_fired"`
	FireCount  int                    `json:"fire_count"`
	// contains filtered or unexported fields
}

AlertRule defines conditions for triggering alerts

func (*AlertRule) Fire

func (ar *AlertRule) Fire()

Fire marks the rule as fired

func (*AlertRule) ShouldFire

func (ar *AlertRule) ShouldFire(results []*health.HealthResult) bool

ShouldFire determines if the rule should fire based on health results

type AlertSeverity

type AlertSeverity string

AlertSeverity represents the severity of an alert

const (
	AlertSeverityInfo     AlertSeverity = "info"
	AlertSeverityWarning  AlertSeverity = "warning"
	AlertSeverityError    AlertSeverity = "error"
	AlertSeverityCritical AlertSeverity = "critical"
)

func (AlertSeverity) String

func (as AlertSeverity) String() string

String returns the string representation of alert severity

type AlertType

type AlertType string

AlertType represents the type of alert

const (
	AlertTypeServiceDown     AlertType = "service_down"
	AlertTypeServiceUp       AlertType = "service_up"
	AlertTypeServiceDegraded AlertType = "service_degraded"
	AlertTypeHealthCheck     AlertType = "health_check"
	AlertTypeSystemError     AlertType = "system_error"
	AlertTypeThreshold       AlertType = "threshold"
)

func (AlertType) String

func (at AlertType) String() string

String returns the string representation of alert type

type EmailConfig

type EmailConfig struct {
	SMTPHost           string            `yaml:"smtp_host" json:"smtp_host"`
	SMTPPort           int               `yaml:"smtp_port" json:"smtp_port"`
	Username           string            `yaml:"username" json:"username"`
	Password           string            `yaml:"password" json:"password"`
	From               string            `yaml:"from" json:"from"`
	To                 []string          `yaml:"to" json:"to"`
	CC                 []string          `yaml:"cc" json:"cc"`
	BCC                []string          `yaml:"bcc" json:"bcc"`
	Subject            string            `yaml:"subject" json:"subject"`
	SubjectTemplate    string            `yaml:"subject_template" json:"subject_template"`
	BodyTemplate       string            `yaml:"body_template" json:"body_template"`
	HTMLTemplate       string            `yaml:"html_template" json:"html_template"`
	UseTLS             bool              `yaml:"use_tls" json:"use_tls"`
	UseStartTLS        bool              `yaml:"use_starttls" json:"use_starttls"`
	InsecureSkipVerify bool              `yaml:"insecure_skip_verify" json:"insecure_skip_verify"`
	Timeout            time.Duration     `yaml:"timeout" json:"timeout"`
	Headers            map[string]string `yaml:"headers" json:"headers"`
	AuthType           string            `yaml:"auth_type" json:"auth_type"` // plain, login, crammd5
}

EmailConfig contains configuration for email notifications

func DefaultEmailConfig

func DefaultEmailConfig() *EmailConfig

DefaultEmailConfig returns default configuration for email notifications

type EmailNotifier

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

EmailNotifier implements AlertNotifier for email notifications

func NewEmailNotifier

func NewEmailNotifier(name string, config *EmailConfig, logger logger.Logger, metrics shared.Metrics) (*EmailNotifier, error)

NewEmailNotifier creates a new email notifier

func NewGmailNotifier

func NewGmailNotifier(name, username, password, from string, to []string, logger logger.Logger, metrics shared.Metrics) (*EmailNotifier, error)

NewGmailNotifier creates an email notifier configured for Gmail

func NewOutlookNotifier

func NewOutlookNotifier(name, username, password, from string, to []string, logger logger.Logger, metrics shared.Metrics) (*EmailNotifier, error)

NewOutlookNotifier creates an email notifier configured for Outlook

func NewSMTPNotifier

func NewSMTPNotifier(name, host string, port int, username, password, from string, to []string, logger logger.Logger, metrics shared.Metrics) (*EmailNotifier, error)

NewSMTPNotifier creates a generic SMTP email notifier

func (*EmailNotifier) Close

func (en *EmailNotifier) Close() error

Close closes the email notifier

func (*EmailNotifier) Name

func (en *EmailNotifier) Name() string

Name returns the name of the notifier

func (*EmailNotifier) Send

func (en *EmailNotifier) Send(ctx context.Context, alert *Alert) error

Send sends an alert via email

func (*EmailNotifier) SendBatch

func (en *EmailNotifier) SendBatch(ctx context.Context, alerts []*Alert) error

SendBatch sends multiple alerts in a single email

func (*EmailNotifier) Test

func (en *EmailNotifier) Test(ctx context.Context) error

Test sends a test email

type EmailNotifierBuilder

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

EmailNotifierBuilder helps build email notifiers with fluent interface

func NewEmailNotifierBuilder

func NewEmailNotifierBuilder(name string) *EmailNotifierBuilder

NewEmailNotifierBuilder creates a new email notifier builder

func (*EmailNotifierBuilder) Build

func (enb *EmailNotifierBuilder) Build() (*EmailNotifier, error)

Build creates the email notifier

func (*EmailNotifierBuilder) WithAuth

func (enb *EmailNotifierBuilder) WithAuth(username, password string) *EmailNotifierBuilder

WithAuth sets authentication credentials

func (*EmailNotifierBuilder) WithAuthType

func (enb *EmailNotifierBuilder) WithAuthType(authType string) *EmailNotifierBuilder

WithAuthType sets authentication type

func (*EmailNotifierBuilder) WithBCC

func (enb *EmailNotifierBuilder) WithBCC(bcc ...string) *EmailNotifierBuilder

WithBCC sets the BCC addresses

func (*EmailNotifierBuilder) WithBodyTemplate

func (enb *EmailNotifierBuilder) WithBodyTemplate(template string) *EmailNotifierBuilder

WithBodyTemplate sets the body template

func (*EmailNotifierBuilder) WithCC

func (enb *EmailNotifierBuilder) WithCC(cc ...string) *EmailNotifierBuilder

WithCC sets the CC addresses

func (*EmailNotifierBuilder) WithFrom

func (enb *EmailNotifierBuilder) WithFrom(from string) *EmailNotifierBuilder

WithFrom sets the sender address

func (*EmailNotifierBuilder) WithHTMLTemplate

func (enb *EmailNotifierBuilder) WithHTMLTemplate(template string) *EmailNotifierBuilder

WithHTMLTemplate sets the HTML template

func (*EmailNotifierBuilder) WithHeader

func (enb *EmailNotifierBuilder) WithHeader(key, value string) *EmailNotifierBuilder

WithHeader adds a custom header

func (*EmailNotifierBuilder) WithHeaders

func (enb *EmailNotifierBuilder) WithHeaders(headers map[string]string) *EmailNotifierBuilder

WithHeaders sets custom headers

func (*EmailNotifierBuilder) WithInsecureSkipVerify

func (enb *EmailNotifierBuilder) WithInsecureSkipVerify(skip bool) *EmailNotifierBuilder

WithInsecureSkipVerify sets TLS verification skip

func (*EmailNotifierBuilder) WithLogger

func (enb *EmailNotifierBuilder) WithLogger(logger logger.Logger) *EmailNotifierBuilder

WithLogger sets the logger

func (*EmailNotifierBuilder) WithMetrics

func (enb *EmailNotifierBuilder) WithMetrics(metrics shared.Metrics) *EmailNotifierBuilder

WithMetrics sets the metrics collector

func (*EmailNotifierBuilder) WithSMTP

func (enb *EmailNotifierBuilder) WithSMTP(host string, port int) *EmailNotifierBuilder

WithSMTP sets SMTP server configuration

func (*EmailNotifierBuilder) WithStartTLS

func (enb *EmailNotifierBuilder) WithStartTLS(useStartTLS bool) *EmailNotifierBuilder

WithStartTLS sets STARTTLS configuration

func (*EmailNotifierBuilder) WithSubject

func (enb *EmailNotifierBuilder) WithSubject(subject string) *EmailNotifierBuilder

WithSubject sets the email subject

func (*EmailNotifierBuilder) WithSubjectTemplate

func (enb *EmailNotifierBuilder) WithSubjectTemplate(template string) *EmailNotifierBuilder

WithSubjectTemplate sets the subject template

func (*EmailNotifierBuilder) WithTLS

func (enb *EmailNotifierBuilder) WithTLS(useTLS bool) *EmailNotifierBuilder

WithTLS sets TLS configuration

func (*EmailNotifierBuilder) WithTimeout

func (enb *EmailNotifierBuilder) WithTimeout(timeout time.Duration) *EmailNotifierBuilder

WithTimeout sets the timeout

func (*EmailNotifierBuilder) WithTo

func (enb *EmailNotifierBuilder) WithTo(to ...string) *EmailNotifierBuilder

WithTo sets the recipient addresses

type SlackConfig

type SlackConfig struct {
	// Webhook URL for Slack incoming webhooks
	WebhookURL string `yaml:"webhook_url" json:"webhook_url"`

	// Bot Token for Slack Bot API (alternative to webhook)
	BotToken string `yaml:"bot_token" json:"bot_token"`

	// Channel to send notifications to (for Bot API)
	Channel string `yaml:"channel" json:"channel"`

	// Username for the bot (webhook only)
	Username string `yaml:"username" json:"username"`

	// Icon emoji for the bot (webhook only)
	IconEmoji string `yaml:"icon_emoji" json:"icon_emoji"`

	// Icon URL for the bot (webhook only)
	IconURL string `yaml:"icon_url" json:"icon_url"`

	// Template for custom message formatting
	Template string `yaml:"template" json:"template"`

	// Timeout for HTTP requests
	Timeout time.Duration `yaml:"timeout" json:"timeout"`

	// Enable threaded messages
	EnableThreading bool `yaml:"enable_threading" json:"enable_threading"`

	// Thread timestamp for replies
	ThreadTS string `yaml:"thread_ts" json:"thread_ts"`

	// Color coding for different severity levels
	Colors map[AlertSeverity]string `yaml:"colors" json:"colors"`

	// Mention users on critical alerts
	MentionUsers []string `yaml:"mention_users" json:"mention_users"`

	// Mention channels on critical alerts
	MentionChannels []string `yaml:"mention_channels" json:"mention_channels"`

	// Enable attachment formatting
	EnableAttachments bool `yaml:"enable_attachments" json:"enable_attachments"`

	// Enable blocks formatting (modern Slack UI)
	EnableBlocks bool `yaml:"enable_blocks" json:"enable_blocks"`

	// Maximum message length (Slack limit is 4000 characters)
	MaxMessageLength int `yaml:"max_message_length" json:"max_message_length"`

	// Retry configuration
	MaxRetries int           `yaml:"max_retries" json:"max_retries"`
	RetryDelay time.Duration `yaml:"retry_delay" json:"retry_delay"`

	// Rate limiting
	RateLimitEnabled bool          `yaml:"rate_limit_enabled" json:"rate_limit_enabled"`
	RateLimitWindow  time.Duration `yaml:"rate_limit_window" json:"rate_limit_window"`
	RateLimitMax     int           `yaml:"rate_limit_max" json:"rate_limit_max"`
}

SlackConfig contains configuration for Slack notifications

func DefaultSlackConfig

func DefaultSlackConfig() *SlackConfig

DefaultSlackConfig returns default configuration for Slack notifications

type SlackNotifier

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

SlackNotifier implements AlertNotifier for Slack notifications

func NewSlackBotNotifier

func NewSlackBotNotifier(name, botToken, channel string, logger logger.Logger, metrics shared.Metrics) *SlackNotifier

NewSlackBotNotifier creates a bot-based Slack notifier

func NewSlackNotifier

func NewSlackNotifier(name string, config *SlackConfig, logger logger.Logger, metrics shared.Metrics) *SlackNotifier

NewSlackNotifier creates a new Slack notifier

func NewSlackNotifierWithMentions

func NewSlackNotifierWithMentions(name, webhookURL string, mentionUsers, mentionChannels []string, logger logger.Logger, metrics shared.Metrics) *SlackNotifier

NewSlackNotifierWithMentions creates a Slack notifier with mention capabilities

func NewSlackWebhookNotifier

func NewSlackWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *SlackNotifier

NewSlackWebhookNotifier creates a simple webhook-based Slack notifier

func (*SlackNotifier) Close

func (sn *SlackNotifier) Close() error

Close closes the Slack notifier

func (*SlackNotifier) Name

func (sn *SlackNotifier) Name() string

Name returns the name of the notifier

func (*SlackNotifier) Send

func (sn *SlackNotifier) Send(ctx context.Context, alert *Alert) error

Send sends an alert to Slack

func (*SlackNotifier) SendBatch

func (sn *SlackNotifier) SendBatch(ctx context.Context, alerts []*Alert) error

SendBatch sends multiple alerts in a batch

func (*SlackNotifier) Test

func (sn *SlackNotifier) Test(ctx context.Context) error

Test tests the Slack notification

type SlackNotifierBuilder

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

SlackNotifierBuilder helps build Slack notifiers with fluent interface

func NewSlackNotifierBuilder

func NewSlackNotifierBuilder(name string) *SlackNotifierBuilder

NewSlackNotifierBuilder creates a new Slack notifier builder

func (*SlackNotifierBuilder) Build

func (snb *SlackNotifierBuilder) Build() *SlackNotifier

Build creates the Slack notifier

func (*SlackNotifierBuilder) WithAttachments

func (snb *SlackNotifierBuilder) WithAttachments(enabled bool) *SlackNotifierBuilder

WithAttachments enables attachments

func (*SlackNotifierBuilder) WithBlocks

func (snb *SlackNotifierBuilder) WithBlocks(enabled bool) *SlackNotifierBuilder

WithBlocks enables blocks

func (*SlackNotifierBuilder) WithBotToken

func (snb *SlackNotifierBuilder) WithBotToken(token string) *SlackNotifierBuilder

WithBotToken sets the bot token

func (*SlackNotifierBuilder) WithChannel

func (snb *SlackNotifierBuilder) WithChannel(channel string) *SlackNotifierBuilder

WithChannel sets the channel

func (*SlackNotifierBuilder) WithColors

func (snb *SlackNotifierBuilder) WithColors(colors map[AlertSeverity]string) *SlackNotifierBuilder

WithColors sets severity colors

func (*SlackNotifierBuilder) WithIconEmoji

func (snb *SlackNotifierBuilder) WithIconEmoji(emoji string) *SlackNotifierBuilder

WithIconEmoji sets the icon emoji

func (*SlackNotifierBuilder) WithIconURL

func (snb *SlackNotifierBuilder) WithIconURL(url string) *SlackNotifierBuilder

WithIconURL sets the icon URL

func (*SlackNotifierBuilder) WithLogger

func (snb *SlackNotifierBuilder) WithLogger(logger logger.Logger) *SlackNotifierBuilder

WithLogger sets the logger

func (*SlackNotifierBuilder) WithMentionChannels

func (snb *SlackNotifierBuilder) WithMentionChannels(channels ...string) *SlackNotifierBuilder

WithMentionChannels sets channels to mention on critical alerts

func (*SlackNotifierBuilder) WithMentionUsers

func (snb *SlackNotifierBuilder) WithMentionUsers(users ...string) *SlackNotifierBuilder

WithMentionUsers sets users to mention on critical alerts

func (*SlackNotifierBuilder) WithMetrics

func (snb *SlackNotifierBuilder) WithMetrics(metrics shared.Metrics) *SlackNotifierBuilder

WithMetrics sets the metrics collector

func (*SlackNotifierBuilder) WithRateLimit

func (snb *SlackNotifierBuilder) WithRateLimit(enabled bool, window time.Duration, max int) *SlackNotifierBuilder

WithRateLimit sets rate limiting

func (*SlackNotifierBuilder) WithRetry

func (snb *SlackNotifierBuilder) WithRetry(maxRetries int, retryDelay time.Duration) *SlackNotifierBuilder

WithRetry sets retry configuration

func (*SlackNotifierBuilder) WithTemplate

func (snb *SlackNotifierBuilder) WithTemplate(template string) *SlackNotifierBuilder

WithTemplate sets the custom template

func (*SlackNotifierBuilder) WithThreading

func (snb *SlackNotifierBuilder) WithThreading(enabled bool) *SlackNotifierBuilder

WithThreading enables threading

func (*SlackNotifierBuilder) WithTimeout

func (snb *SlackNotifierBuilder) WithTimeout(timeout time.Duration) *SlackNotifierBuilder

WithTimeout sets the timeout

func (*SlackNotifierBuilder) WithUsername

func (snb *SlackNotifierBuilder) WithUsername(username string) *SlackNotifierBuilder

WithUsername sets the username

func (*SlackNotifierBuilder) WithWebhookURL

func (snb *SlackNotifierBuilder) WithWebhookURL(url string) *SlackNotifierBuilder

WithWebhookURL sets the webhook URL

type WebhookConfig

type WebhookConfig struct {
	URL                string            `yaml:"url" json:"url"`
	Method             string            `yaml:"method" json:"method"`
	Headers            map[string]string `yaml:"headers" json:"headers"`
	Timeout            time.Duration     `yaml:"timeout" json:"timeout"`
	Secret             string            `yaml:"secret" json:"secret"`
	SignatureHeader    string            `yaml:"signature_header" json:"signature_header"`
	ContentType        string            `yaml:"content_type" json:"content_type"`
	Template           string            `yaml:"template" json:"template"`
	MaxRetries         int               `yaml:"max_retries" json:"max_retries"`
	RetryDelay         time.Duration     `yaml:"retry_delay" json:"retry_delay"`
	InsecureSkipVerify bool              `yaml:"insecure_skip_verify" json:"insecure_skip_verify"`
	ProxyURL           string            `yaml:"proxy_url" json:"proxy_url"`
	Username           string            `yaml:"username" json:"username"`
	Password           string            `yaml:"password" json:"password"`
	CustomPayload      bool              `yaml:"custom_payload" json:"custom_payload"`
}

WebhookConfig contains configuration for webhook notifications

func DefaultWebhookConfig

func DefaultWebhookConfig() *WebhookConfig

DefaultWebhookConfig returns default configuration for webhook notifications

type WebhookNotifier

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

WebhookNotifier implements AlertNotifier for webhook notifications

func NewDiscordWebhookNotifier

func NewDiscordWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier

NewDiscordWebhookNotifier creates a webhook notifier configured for Discord

func NewMSTeamsWebhookNotifier

func NewMSTeamsWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier

NewMSTeamsWebhookNotifier creates a webhook notifier configured for Microsoft Teams

func NewPureSlackWebhookNotifier

func NewPureSlackWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier

NewPureSlackWebhookNotifier creates a webhook notifier configured for Slack

func NewWebhookNotifier

func NewWebhookNotifier(name string, config *WebhookConfig, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier

NewWebhookNotifier creates a new webhook notifier

func (*WebhookNotifier) Close

func (wn *WebhookNotifier) Close() error

Close closes the webhook notifier

func (*WebhookNotifier) Name

func (wn *WebhookNotifier) Name() string

Name returns the name of the notifier

func (*WebhookNotifier) Send

func (wn *WebhookNotifier) Send(ctx context.Context, alert *Alert) error

Send sends an alert via webhook

func (*WebhookNotifier) SendBatch

func (wn *WebhookNotifier) SendBatch(ctx context.Context, alerts []*Alert) error

SendBatch sends multiple alerts in a batch

func (*WebhookNotifier) Test

func (wn *WebhookNotifier) Test(ctx context.Context) error

Test tests the webhook notification

type WebhookNotifierBuilder

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

WebhookNotifierBuilder helps build webhook notifiers with fluent interface

func NewWebhookNotifierBuilder

func NewWebhookNotifierBuilder(name string) *WebhookNotifierBuilder

NewWebhookNotifierBuilder creates a new webhook notifier builder

func (*WebhookNotifierBuilder) Build

Build creates the webhook notifier

func (*WebhookNotifierBuilder) WithBasicAuth

func (wnb *WebhookNotifierBuilder) WithBasicAuth(username, password string) *WebhookNotifierBuilder

WithBasicAuth sets basic authentication

func (*WebhookNotifierBuilder) WithContentType

func (wnb *WebhookNotifierBuilder) WithContentType(contentType string) *WebhookNotifierBuilder

WithContentType sets the content type

func (*WebhookNotifierBuilder) WithHeader

func (wnb *WebhookNotifierBuilder) WithHeader(key, value string) *WebhookNotifierBuilder

WithHeader adds a single HTTP header

func (*WebhookNotifierBuilder) WithHeaders

func (wnb *WebhookNotifierBuilder) WithHeaders(headers map[string]string) *WebhookNotifierBuilder

WithHeaders sets HTTP headers

func (*WebhookNotifierBuilder) WithInsecureSkipVerify

func (wnb *WebhookNotifierBuilder) WithInsecureSkipVerify(skip bool) *WebhookNotifierBuilder

WithInsecureSkipVerify sets TLS verification skip

func (*WebhookNotifierBuilder) WithLogger

WithLogger sets the logger

func (*WebhookNotifierBuilder) WithMethod

func (wnb *WebhookNotifierBuilder) WithMethod(method string) *WebhookNotifierBuilder

WithMethod sets the HTTP method

func (*WebhookNotifierBuilder) WithMetrics

func (wnb *WebhookNotifierBuilder) WithMetrics(metrics shared.Metrics) *WebhookNotifierBuilder

WithMetrics sets the metrics collector

func (*WebhookNotifierBuilder) WithProxy

func (wnb *WebhookNotifierBuilder) WithProxy(proxyURL string) *WebhookNotifierBuilder

WithProxy sets proxy URL

func (*WebhookNotifierBuilder) WithRetry

func (wnb *WebhookNotifierBuilder) WithRetry(maxRetries int, retryDelay time.Duration) *WebhookNotifierBuilder

WithRetry sets retry configuration

func (*WebhookNotifierBuilder) WithSecret

func (wnb *WebhookNotifierBuilder) WithSecret(secret string) *WebhookNotifierBuilder

WithSecret sets the signing secret

func (*WebhookNotifierBuilder) WithSignatureHeader

func (wnb *WebhookNotifierBuilder) WithSignatureHeader(header string) *WebhookNotifierBuilder

WithSignatureHeader sets the signature header name

func (*WebhookNotifierBuilder) WithTemplate

func (wnb *WebhookNotifierBuilder) WithTemplate(template string) *WebhookNotifierBuilder

WithTemplate sets the custom payload template

func (*WebhookNotifierBuilder) WithTimeout

func (wnb *WebhookNotifierBuilder) WithTimeout(timeout time.Duration) *WebhookNotifierBuilder

WithTimeout sets the request timeout

func (*WebhookNotifierBuilder) WithURL

WithURL sets the webhook URL

Jump to

Keyboard shortcuts

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