From 4e3459bee4ecc8ceef33b0a876e584b494ad4e4a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 21 Jan 2026 23:40:14 +0200 Subject: add OnlyIfNotExists alert suppression feature Adds ability to suppress alerts during maintenance windows by checking for the existence of a file. When the file exists and is recent (within configured max age), matching alerts are excluded from email reports. Features: - Global PrometheusOnlyIfNotExists config for Prometheus alerts - Per-check OnlyIfNotExists config for individual checks - Configurable max age (default 86400s) for suppression file - New "Suppressed alerts" section in email and HTML reports - Suppressed checks excluded from counts and unhandled sections Co-Authored-By: Claude Opus 4.5 --- internal/config.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'internal/config.go') diff --git a/internal/config.go b/internal/config.go index 5d172d6..c3a0d5f 100644 --- a/internal/config.go +++ b/internal/config.go @@ -21,9 +21,11 @@ type config struct { CheckConcurrency int StaleThreshold int `json:"StaleThreshold,omitempty"` Federated []string `json:"Federated,omitempty"` // TODO: Document this option - PrometheusHosts []string `json:"PrometheusHosts,omitempty"` - PrometheusTimeoutS int `json:"PrometheusTimeoutS,omitempty"` - Checks map[string]check + PrometheusHosts []string `json:"PrometheusHosts,omitempty"` + PrometheusTimeoutS int `json:"PrometheusTimeoutS,omitempty"` + PrometheusOnlyIfNotExists string `json:"PrometheusOnlyIfNotExists,omitempty"` // Suppress Prometheus alerts if this file exists and is recent + PrometheusOnlyIfNotExistsMaxS int `json:"PrometheusOnlyIfNotExistsMaxS,omitempty"` // Max age in seconds for suppression file (default 86400) + Checks map[string]check } func newConfig(configFile string) (config, error) { @@ -67,6 +69,10 @@ func newConfig(configFile string) (config, error) { conf.PrometheusTimeoutS = 2 // Default to 2 seconds } + if conf.PrometheusOnlyIfNotExistsMaxS == 0 { + conf.PrometheusOnlyIfNotExistsMaxS = 86400 // Default to 24 hours + } + if !conf.HTMLDisable && conf.HTMLStatusFile == "" { conf.HTMLStatusFile = "/var/www/htdocs/buetow.org/self/gogios/index.html" log.Println("Set HTMLStatusFile to " + conf.HTMLStatusFile) -- cgit v1.2.3