Merge pull request #78 from wrouesnel/master
Add a GET api to /api/alerts which pulls JSON formatted AlertAggregates.
This commit is contained in:
commit
8d455091fc
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue