diff --git a/web/api/alert.go b/web/api/alert.go index ee875788..845414bf 100644 --- a/web/api/alert.go +++ b/web/api/alert.go @@ -22,6 +22,12 @@ import ( "github.com/prometheus/alertmanager/manager" ) +// Return all currently firing alerts as JSON. +func (s AlertManagerService) getAlerts(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + aggs := s.Manager.GetAll(nil) + respondJSON(w, aggs) +} + func (s AlertManagerService) addAlerts(w http.ResponseWriter, r *http.Request, p httprouter.Params) { alerts := manager.Alerts{} if err := parseJSON(w, r, &alerts); err != nil { diff --git a/web/api/api.go b/web/api/api.go index 8fb70592..5efc369d 100644 --- a/web/api/api.go +++ b/web/api/api.go @@ -32,6 +32,7 @@ type AlertManagerService struct { func (s AlertManagerService) Handler() http.Handler { r := httprouter.New() + r.GET(s.PathPrefix+"api/alerts", s.getAlerts) r.POST(s.PathPrefix+"api/alerts", s.addAlerts) r.GET(s.PathPrefix+"api/silences", s.silenceSummary) r.POST(s.PathPrefix+"api/silences", s.addSilence)