summaryrefslogtreecommitdiff
path: root/internal/config.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-21 23:40:14 +0200
committerPaul Buetow <paul@buetow.org>2026-01-21 23:40:14 +0200
commit4e3459bee4ecc8ceef33b0a876e584b494ad4e4a (patch)
tree3cd76c41bef90f8ccc9d5fda8b8031b0f9281c03 /internal/config.go
parent64c4f058e6f9975effb38e952531458054f512c3 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/config.go')
-rw-r--r--internal/config.go12
1 files changed, 9 insertions, 3 deletions
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)