Add alert archiving
Release / build (amd64, darwin) (push) Failing after 2m46s
Release / build (amd64, linux) (push) Failing after 2m26s
Release / build (arm64, darwin) (push) Failing after 1m40s
Release / build (arm64, linux) (push) Failing after 10s
Release / release (push) Has been skipped
Release / chart (push) Failing after 11s
Release / docker (push) Failing after 19s

Alerts can be manually archived (POST /api/alerts/{id}/archive) or
unarchived (DELETE /api/alerts/{id}/archive). A background goroutine
auto-archives resolved alerts older than TERDUT_ARCHIVE_AFTER (default 7d).
GET /api/alerts hides archived alerts by default; ?archived=true shows them.
This commit is contained in:
Niklas Ye
2026-05-22 13:22:45 +02:00
parent 36468a68ed
commit debc4bf78c
8 changed files with 178 additions and 6 deletions
+14 -4
View File
@@ -1,10 +1,14 @@
package config
import "os"
import (
"os"
"time"
)
type Config struct {
Addr string
DBPath string
Addr string
DBPath string
ArchiveAfter time.Duration
}
func Load() Config {
@@ -16,5 +20,11 @@ func Load() Config {
if dbPath == "" {
dbPath = "terdut.db"
}
return Config{Addr: addr, DBPath: dbPath}
archiveAfter := 7 * 24 * time.Hour
if s := os.Getenv("TERDUT_ARCHIVE_AFTER"); s != "" {
if d, err := time.ParseDuration(s); err == nil {
archiveAfter = d
}
}
return Config{Addr: addr, DBPath: dbPath, ArchiveAfter: archiveAfter}
}