Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
# Default: (empty)
# FANOUT_AI_PROVIDER=

# FANOUT_ALERTS_EMAIL_DEFAULT_TO; string
# A comma-separated list of addresses that receive alerts from rules with no webhook and no email recipients of their own; requires SMTP.
# Default: (empty)
# FANOUT_ALERTS_EMAIL_DEFAULT_TO=

# FANOUT_ALERTS_EMAIL_HOURLY_LIMIT; integer
# Caps the alert emails sent to one address in any rolling hour, across all rules. Notifications over the limit are suppressed, not delayed, and shown on the rule; 0 suppresses all alert email.
# Default: 30
# FANOUT_ALERTS_EMAIL_HOURLY_LIMIT=

# FANOUT_ALERTS_ENABLED; boolean
# Runs the alert evaluation engine.
# Default: true
Expand Down
6 changes: 3 additions & 3 deletions cmd/fanout-docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ var groups = map[string]groupPage{
},
"alerts": {
Title: "Alert settings",
Description: "Whether the alert engine runs, how often it evaluates, and how long history is kept.",
Summary: "Settings for the alert evaluation loop.",
ReadWhen: []string{"Alerts are evaluating too slowly, or not at all."},
Description: "Whether the alert engine runs, how often it evaluates, how long history is kept, and how alert email is addressed and limited.",
Summary: "Settings for the alert evaluation loop and alert email.",
ReadWhen: []string{"Alerts are evaluating too slowly, or not at all.", "You are setting a default alert email destination or changing the per-address limit."},
},
"metrics": {
Title: "Metrics settings",
Expand Down
27 changes: 20 additions & 7 deletions cmd/fanout/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ func main() {
os.Exit(1)
}

smtpCfg := auth.SMTPConfig{
Host: cfg.SMTPHost,
Port: cfg.SMTPPort,
User: cfg.SMTPUser,
Pass: cfg.SMTPPass,
From: cfg.SMTPFrom,
}

// Start alert engine
var alertStore *alert.Store
var alertEngine *alert.Engine
Expand All @@ -204,6 +212,18 @@ func main() {
cfg.AlertEvaluationInterval,
cfg.AlertHistoryDays,
)
if cfg.SMTPConfigured() {
defaults, err := cfg.AlertEmailDefaults()
if err != nil {
slog.Error("alert email defaults invalid", "err", err)
os.Exit(1)
}
alertEngine.EnableEmail(alert.EmailConfig{
Send: func(ctx context.Context, mail auth.AlertMail) error { return auth.SendAlert(ctx, smtpCfg, mail) },
Defaults: defaults,
HourlyLimit: cfg.AlertEmailHourlyLimit,
})
}
go alertEngine.Run(ctx)
slog.Info("alert engine enabled", "interval", cfg.AlertEvaluationInterval)
}
Expand Down Expand Up @@ -299,13 +319,6 @@ func main() {
api.RegisterAlertRoutes(e, alertStore, alertEngine)

// Auth routes (web-only setup + email-code login)
smtpCfg := auth.SMTPConfig{
Host: cfg.SMTPHost,
Port: cfg.SMTPPort,
User: cfg.SMTPUser,
Pass: cfg.SMTPPass,
From: cfg.SMTPFrom,
}
codeStore := auth.NewCodeStore(sqlite.DB, cfg.AuthCodeSecret)
api.RegisterAuthRoutes(e, userStore, codeStore, setup, settingsStore, browserSessions, auditStore, smtpCfg, cfg)
oidcDiscovery, err := api.RegisterOIDCRoutes(ctx, e, cfg, userStore, identityStore, browserSessions, auditStore)
Expand Down
Loading
Loading