Stage 6: alert statistics endpoints
- GET /api/stats/alerts — total/firing/resolved counts - GET /api/stats/alerts/top — most frequent alert names (?limit, default 10) - GET /api/stats/alerts/by-hour — counts for all 24 hours (zeros filled in) - GET /api/stats/alerts/by-day — counts for all 7 days with names (zeros filled in) - All endpoints accept optional ?from/?to (YYYY-MM-DD) to filter by received_at
This commit is contained in:
@@ -43,6 +43,11 @@ func NewRouter(db *sql.DB) http.Handler {
|
||||
r.Get("/api/schedule/current", handleCurrentSchedule(db)) // must be before /{id}
|
||||
r.Get("/api/schedule", handleListSchedule(db))
|
||||
r.Delete("/api/schedule/{id}", handleDeleteSchedule(db))
|
||||
|
||||
r.Get("/api/stats/alerts", handleStatsAlerts(db))
|
||||
r.Get("/api/stats/alerts/top", handleStatsTop(db))
|
||||
r.Get("/api/stats/alerts/by-hour", handleStatsByHour(db))
|
||||
r.Get("/api/stats/alerts/by-day", handleStatsByDay(db))
|
||||
})
|
||||
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user