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 interface{}) *Alert
- func (a *Alert) WithDetails(details map[string]interface{}) *Alert
- func (a *Alert) WithFingerprint(fingerprint string) *Alert
- func (a *Alert) WithMetadata(metadata map[string]interface{}) *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, max 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]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 ¶
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]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
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) 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 `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
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
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
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