feat(api): expose per grid state count

This commit is contained in:
Łukasz Mierzwa
2020-03-31 09:16:55 +01:00
parent 0efd3a9d3c
commit f41066b6ba
2 changed files with 8 additions and 0 deletions
+7
View File
@@ -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
}
}
+1
View File
@@ -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