mirror of
https://github.com/prymitive/karma
synced 2026-08-28 11:17:28 +00:00
feat(api): expose per grid state count
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user