Documentation
¶
Index ¶
- type Alert
- func (a *Alert) GetFingerprint() string
- func (a *Alert) IsResolved() bool
- func (a *Alert) Resolve() *Alert
- func (a *Alert) WithDetail(key string, value any) *Alert
- func (a *Alert) WithDetails(details map[string]any) *Alert
- func (a *Alert) WithFingerprint(fingerprint string) *Alert
- func (a *Alert) WithMetadata(metadata map[string]any) *Alert
- func (a *Alert) WithService(service string) *Alert
- func (a *Alert) WithSource(source string) *Alert
- func (a *Alert) WithTag(key, value string) *Alert
- func (a *Alert) WithTags(tags map[string]string) *Alert
- type AlertAction
- type AlertCondition
- type AlertManager
- func (am *AlertManager) AddNotifier(name string, notifier AlertNotifier) error
- func (am *AlertManager) AddRule(rule *AlertRule) error
- func (am *AlertManager) GetActiveAlerts() []*Alert
- func (am *AlertManager) GetNotifiers() map[string]AlertNotifier
- func (am *AlertManager) GetRules() []*AlertRule
- func (am *AlertManager) ProcessHealthResults(ctx context.Context, results []*health.HealthResult) error
- func (am *AlertManager) RemoveNotifier(name string) error
- func (am *AlertManager) RemoveRule(name string) error
- func (am *AlertManager) SendAlert(ctx context.Context, alert *Alert) error
- func (am *AlertManager) Start(ctx context.Context) error
- func (am *AlertManager) Stop(ctx context.Context) error
- func (am *AlertManager) Test(ctx context.Context) error
- type AlertManagerConfig
- type AlertNotifier
- type AlertRule
- type AlertSeverity
- type AlertType
- type EmailConfig
- type EmailNotifier
- func NewEmailNotifier(name string, config *EmailConfig, logger logger.Logger, metrics shared.Metrics) (*EmailNotifier, error)
- func NewGmailNotifier(name, username, password, from string, to []string, logger logger.Logger, ...) (*EmailNotifier, error)
- func NewOutlookNotifier(name, username, password, from string, to []string, logger logger.Logger, ...) (*EmailNotifier, error)
- func NewSMTPNotifier(name, host string, port int, username, password, from string, to []string, ...) (*EmailNotifier, error)
- type EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) Build() (*EmailNotifier, error)
- func (enb *EmailNotifierBuilder) WithAuth(username, password string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithAuthType(authType string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithBCC(bcc ...string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithBodyTemplate(template string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithCC(cc ...string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithFrom(from string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithHTMLTemplate(template string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithHeader(key, value string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithHeaders(headers map[string]string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithInsecureSkipVerify(skip bool) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithLogger(logger logger.Logger) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithMetrics(metrics shared.Metrics) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithSMTP(host string, port int) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithStartTLS(useStartTLS bool) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithSubject(subject string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithSubjectTemplate(template string) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithTLS(useTLS bool) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithTimeout(timeout time.Duration) *EmailNotifierBuilder
- func (enb *EmailNotifierBuilder) WithTo(to ...string) *EmailNotifierBuilder
- type SlackConfig
- type SlackNotifier
- func NewSlackBotNotifier(name, botToken, channel string, logger logger.Logger, metrics shared.Metrics) *SlackNotifier
- func NewSlackNotifier(name string, config *SlackConfig, logger logger.Logger, metrics shared.Metrics) *SlackNotifier
- func NewSlackNotifierWithMentions(name, webhookURL string, mentionUsers, mentionChannels []string, ...) *SlackNotifier
- func NewSlackWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *SlackNotifier
- type SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) Build() *SlackNotifier
- func (snb *SlackNotifierBuilder) WithAttachments(enabled bool) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithBlocks(enabled bool) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithBotToken(token string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithChannel(channel string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithColors(colors map[AlertSeverity]string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithIconEmoji(emoji string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithIconURL(url string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithLogger(logger logger.Logger) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithMentionChannels(channels ...string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithMentionUsers(users ...string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithMetrics(metrics shared.Metrics) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithRateLimit(enabled bool, window time.Duration, maxCount int) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithRetry(maxRetries int, retryDelay time.Duration) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithTemplate(template string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithThreading(enabled bool) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithTimeout(timeout time.Duration) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithUsername(username string) *SlackNotifierBuilder
- func (snb *SlackNotifierBuilder) WithWebhookURL(url string) *SlackNotifierBuilder
- type WebhookConfig
- type WebhookNotifier
- func NewDiscordWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier
- func NewMSTeamsWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier
- func NewPureSlackWebhookNotifier(name, webhookURL string, logger logger.Logger, metrics shared.Metrics) *WebhookNotifier
- func NewWebhookNotifier(name string, config *WebhookConfig, logger logger.Logger, ...) *WebhookNotifier
- type WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) Build() *WebhookNotifier
- func (wnb *WebhookNotifierBuilder) WithBasicAuth(username, password string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithContentType(contentType string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithHeader(key, value string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithHeaders(headers map[string]string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithInsecureSkipVerify(skip bool) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithLogger(logger logger.Logger) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithMethod(method string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithMetrics(metrics shared.Metrics) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithProxy(proxyURL string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithRetry(maxRetries int, retryDelay time.Duration) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithSecret(secret string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithSignatureHeader(header string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithTemplate(template string) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithTimeout(timeout time.Duration) *WebhookNotifierBuilder
- func (wnb *WebhookNotifierBuilder) WithURL(url string) *WebhookNotifierBuilder
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]any `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]any `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 ¶
GetFingerprint returns the alert fingerprint for deduplication.
func (*Alert) IsResolved ¶
IsResolved returns true if the alert is resolved.
func (*Alert) WithDetail ¶
WithDetail adds a single detail to the alert.
func (*Alert) WithDetails ¶
WithDetails adds details to the alert.
func (*Alert) WithFingerprint ¶
WithFingerprint sets the alert fingerprint.
func (*Alert) WithMetadata ¶
WithMetadata adds metadata to the alert.
func (*Alert) WithService ¶
WithService sets the alert service.
func (*Alert) WithSource ¶
WithSource sets the alert source.
type AlertAction ¶
type AlertAction struct {
Type string `json:"type"`
Notifier string `json:"notifier"`
Template string `json:"template"`
Parameters map[string]any `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 any `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.
type AlertManagerConfig ¶
type AlertManagerConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
DefaultSeverity AlertSeverity `json:"default_severity" yaml:"default_severity"`
BatchSize int `json:"batch_size" yaml:"batch_size"`
BatchTimeout time.Duration `json:"batch_timeout" yaml:"batch_timeout"`
RetryAttempts int `json:"retry_attempts" yaml:"retry_attempts"`
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
DeduplicationWindow time.Duration `json:"deduplication_window" yaml:"deduplication_window"`
GlobalTags map[string]string `json:"global_tags" yaml:"global_tags"`
Templates map[string]string `json:"templates" yaml:"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]any `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) 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 EmailConfig ¶
type EmailConfig struct {
SMTPHost string `json:"smtp_host" yaml:"smtp_host"`
SMTPPort int `json:"smtp_port" yaml:"smtp_port"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
From string `json:"from" yaml:"from"`
To []string `json:"to" yaml:"to"`
CC []string `json:"cc" yaml:"cc"`
BCC []string `json:"bcc" yaml:"bcc"`
Subject string `json:"subject" yaml:"subject"`
SubjectTemplate string `json:"subject_template" yaml:"subject_template"`
BodyTemplate string `json:"body_template" yaml:"body_template"`
HTMLTemplate string `json:"html_template" yaml:"html_template"`
UseTLS bool `json:"use_tls" yaml:"use_tls"`
UseStartTLS bool `json:"use_starttls" yaml:"use_starttls"`
InsecureSkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
Headers map[string]string `json:"headers" yaml:"headers"`
AuthType string `json:"auth_type" yaml:"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.
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 `json:"webhook_url" yaml:"webhook_url"`
// Bot Token for Slack Bot API (alternative to webhook)
BotToken string `json:"bot_token" yaml:"bot_token"`
// Channel to send notifications to (for Bot API)
Channel string `json:"channel" yaml:"channel"`
// Username for the bot (webhook only)
Username string `json:"username" yaml:"username"`
// Icon emoji for the bot (webhook only)
IconEmoji string `json:"icon_emoji" yaml:"icon_emoji"`
// Icon URL for the bot (webhook only)
IconURL string `json:"icon_url" yaml:"icon_url"`
// Template for custom message formatting
Template string `json:"template" yaml:"template"`
// Timeout for HTTP requests
Timeout time.Duration `json:"timeout" yaml:"timeout"`
// Enable threaded messages
EnableThreading bool `json:"enable_threading" yaml:"enable_threading"`
// Thread timestamp for replies
ThreadTS string `json:"thread_ts" yaml:"thread_ts"`
// Color coding for different severity levels
Colors map[AlertSeverity]string `json:"colors" yaml:"colors"`
// Mention users on critical alerts
MentionUsers []string `json:"mention_users" yaml:"mention_users"`
// Mention channels on critical alerts
MentionChannels []string `json:"mention_channels" yaml:"mention_channels"`
// Enable attachment formatting
EnableAttachments bool `json:"enable_attachments" yaml:"enable_attachments"`
// Enable blocks formatting (modern Slack UI)
EnableBlocks bool `json:"enable_blocks" yaml:"enable_blocks"`
// Maximum message length (Slack limit is 4000 characters)
MaxMessageLength int `json:"max_message_length" yaml:"max_message_length"`
// Retry configuration
MaxRetries int `json:"max_retries" yaml:"max_retries"`
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
// Rate limiting
RateLimitEnabled bool `json:"rate_limit_enabled" yaml:"rate_limit_enabled"`
RateLimitWindow time.Duration `json:"rate_limit_window" yaml:"rate_limit_window"`
RateLimitMax int `json:"rate_limit_max" yaml:"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.
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, maxCount 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 `json:"url" yaml:"url"`
Method string `json:"method" yaml:"method"`
Headers map[string]string `json:"headers" yaml:"headers"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
Secret string `json:"secret" yaml:"secret"`
SignatureHeader string `json:"signature_header" yaml:"signature_header"`
ContentType string `json:"content_type" yaml:"content_type"`
Template string `json:"template" yaml:"template"`
MaxRetries int `json:"max_retries" yaml:"max_retries"`
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
InsecureSkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify"`
ProxyURL string `json:"proxy_url" yaml:"proxy_url"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
CustomPayload bool `json:"custom_payload" yaml:"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.
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 ¶
func (wnb *WebhookNotifierBuilder) Build() *WebhookNotifier
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 ¶
func (wnb *WebhookNotifierBuilder) WithLogger(logger logger.Logger) *WebhookNotifierBuilder
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 ¶
func (wnb *WebhookNotifierBuilder) WithURL(url string) *WebhookNotifierBuilder
WithURL sets the webhook URL.