mirror of
https://github.com/prymitive/karma
synced 2026-05-17 04:16:42 +00:00
refactor(api): return alert groups as a mapping id->group
This commit is contained in:
@@ -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"`
|
||||
|
||||
4
views.go
4
views.go
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user