From c0fdb712764b62faf4e5cfc99a244301635de7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 24 Jun 2018 19:19:34 +0200 Subject: [PATCH] feat(api): expose total alerts counter in the api response --- internal/models/api.go | 1 + views.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/models/api.go b/internal/models/api.go index 381bfb628..c8057f6f9 100644 --- a/internal/models/api.go +++ b/internal/models/api.go @@ -35,6 +35,7 @@ type AlertsResponse struct { Version string `json:"version"` Upstreams AlertmanagerAPISummary `json:"upstreams"` AlertGroups map[string]AlertGroup `json:"groups"` + TotalAlerts int `json:"totalAlerts"` Colors LabelsColorMap `json:"colors"` Filters []Filter `json:"filters"` Counters LabelsCountMap `json:"counters"` diff --git a/views.go b/views.go index 5b1009c90..5231e7e7c 100644 --- a/views.go +++ b/views.go @@ -165,6 +165,7 @@ func alerts(c *gin.Context) { if len(agCopy.Alerts) > 0 { agCopy.Hash = agCopy.ContentFingerprint() alerts[agCopy.ID] = agCopy + resp.TotalAlerts += len(agCopy.Alerts) } }