Stage 3: Alertmanager webhook ingestion and alert query API

- Migration 003: alerts table with fingerprint UNIQUE, JSON label/annotation
  columns, nullable ends_at, and indexed status/name/received_at
- POST /api/alertmanager/webhook — upserts each alert by fingerprint;
  zero endsAt ("0001-01-01") stored as NULL (still firing)
- GET /api/alerts — filtered list (?status, ?name, ?from, ?to, ?limit)
- GET /api/alerts/{id} — single alert lookup
This commit is contained in:
Niklas Ye
2026-05-20 21:54:17 +02:00
parent 7c3c28b23c
commit 9b4ca1482f
5 changed files with 246 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
package models
import "time"
type Alert struct {
ID int64 `json:"id"`
Fingerprint string `json:"fingerprint"`
Name string `json:"name"`
Status string `json:"status"` // "firing" or "resolved"
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
StartsAt time.Time `json:"starts_at"`
EndsAt *time.Time `json:"ends_at,omitempty"`
GeneratorURL string `json:"generator_url"`
ReceivedAt time.Time `json:"received_at"`
}