Merge pull request #78 from wrouesnel/master

Add a GET api to /api/alerts which pulls JSON formatted AlertAggregates.
This commit is contained in:
Julius Volz 2015-06-16 15:52:04 +02:00
commit 8d455091fc
2 changed files with 7 additions and 0 deletions

View File

@ -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 {

View File

@ -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)