refactor(api): return alert groups as a mapping id->group

This commit is contained in:
Łukasz Mierzwa
2018-06-24 17:13:49 +02:00
parent 5a51898e43
commit b7d274c93b
2 changed files with 3 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ type AlertsResponse struct {
Timestamp string `json:"timestamp"`
Version string `json:"version"`
Upstreams AlertmanagerAPISummary `json:"upstreams"`
AlertGroups []AlertGroup `json:"groups"`
AlertGroups map[string]AlertGroup `json:"groups"`
Colors LabelsColorMap `json:"colors"`
Filters []Filter `json:"filters"`
Counters LabelsCountMap `json:"counters"`

View File

@@ -94,7 +94,7 @@ func alerts(c *gin.Context) {
matchFilters, validFilters := getFiltersFromQuery(c.Query("q"))
// set pointers for data store objects, need a lock until end of view is reached
alerts := []models.AlertGroup{}
alerts := map[string]models.AlertGroup{}
colors := models.LabelsColorMap{}
// used for top labels dropdown
counters := models.LabelsCountMap{}
@@ -164,7 +164,7 @@ func alerts(c *gin.Context) {
if len(agCopy.Alerts) > 0 {
agCopy.Hash = agCopy.ContentFingerprint()
alerts = append(alerts, agCopy)
alerts[agCopy.ID] = agCopy
}
}