diff --git a/cmd/karma/views.go b/cmd/karma/views.go index 41cb905e3..57e8e1b09 100644 --- a/cmd/karma/views.go +++ b/cmd/karma/views.go @@ -346,10 +346,17 @@ func alerts(c *gin.Context) { LabelName: gridLabel, LabelValue: gridLabelValue, AlertGroups: []models.APIAlertGroup{}, + StateCount: map[string]int{}, + } + for _, s := range models.AlertStateList { + grid.StateCount[s] = 0 } grids[gridLabelValue] = grid } grid.AlertGroups = append(grid.AlertGroups, apiAG) + for k, v := range apiAG.StateCount { + grid.StateCount[k] += v + } grids[gridLabelValue] = grid } } diff --git a/internal/models/api.go b/internal/models/api.go index e7a2fdef2..cf6122170 100644 --- a/internal/models/api.go +++ b/internal/models/api.go @@ -304,6 +304,7 @@ type APIGrid struct { LabelName string `json:"labelName"` LabelValue string `json:"labelValue"` AlertGroups []APIAlertGroup `json:"alertGroups"` + StateCount map[string]int `json:"stateCount"` } // AlertsResponse is the structure of JSON response UI will use to get alert data