mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
feat(api): expose all receivers in the API response
This commit is contained in:
committed by
Łukasz Mierzwa
parent
ba3005d47c
commit
4b927a3f92
@@ -1082,6 +1082,11 @@ func TestVerifyAllGroups(t *testing.T) {
|
||||
if !reflect.DeepEqual(ur.Filters, filtersExpected) {
|
||||
t.Errorf("[%s] Filters mismatch, expected %v but got %v", version, filtersExpected, ur.Filters)
|
||||
}
|
||||
|
||||
expectedReceivers := []string{"by-cluster-service", "by-name"}
|
||||
if diff := cmp.Diff(expectedReceivers, ur.Receivers); diff != "" {
|
||||
t.Errorf("Incorrect receivers list (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,12 +223,17 @@ func alerts(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
allReceivers := map[string]bool{}
|
||||
|
||||
var matches int
|
||||
for _, ag := range dedupedAlerts {
|
||||
perGridAlertGroup := map[string]*models.AlertGroup{}
|
||||
|
||||
for _, alert := range ag.Alerts {
|
||||
alert := alert // scopelint pin
|
||||
|
||||
allReceivers[alert.Receiver] = true
|
||||
|
||||
results := []bool{}
|
||||
if validFilters {
|
||||
for _, filter := range matchFilters {
|
||||
@@ -370,11 +375,19 @@ func alerts(c *gin.Context) {
|
||||
v, _ := c.GetQuery("gridSortReverse")
|
||||
gridSortReverse := v == "1"
|
||||
|
||||
receivers := []string{}
|
||||
for k := range allReceivers {
|
||||
k := k
|
||||
receivers = append(receivers, k)
|
||||
}
|
||||
sort.Strings(receivers)
|
||||
|
||||
resp.Grids = sortGrids(c, gridLabel, grids, gridSortReverse)
|
||||
resp.Silences = silences
|
||||
resp.Colors = colors
|
||||
resp.Counters = countersToLabelStats(counters)
|
||||
resp.Filters = populateAPIFilters(matchFilters)
|
||||
resp.Receivers = receivers
|
||||
|
||||
data, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
|
||||
@@ -321,6 +321,7 @@ type AlertsResponse struct {
|
||||
Counters LabelNameStatsList `json:"counters"`
|
||||
Settings Settings `json:"settings"`
|
||||
Authentication AuthenticationInfo `json:"authentication"`
|
||||
Receivers []string `json:"receivers"`
|
||||
}
|
||||
|
||||
// Autocomplete is the structure of autocomplete object for filter hints
|
||||
|
||||
Reference in New Issue
Block a user