If we only have silenced or inhibited alerts make the whole alert group green

This will make the UI present inhibited alerts same way as silenced. It also drops unused fields in the model, replacing SilencedCount & UnsilencedCount with only ActiveCount
This commit is contained in:
Łukasz Mierzwa
2017-04-19 15:43:13 -07:00
parent d91bf5e272
commit 5fe3f706af
4 changed files with 11 additions and 10 deletions

View File

@@ -186,7 +186,7 @@
<script type="application/json" id="alert-group">
<div class="incident" id="<%= group.id %>" data-hash="<%= group.hash %>">
<% var cls_panel = 'panel-success' %>
<% if (group.unsilencedCount > 0) { cls_panel = 'panel-danger' } %>
<% if (group.activeCount > 0) { cls_panel = 'panel-danger' } %>
<div class="panel <%= cls_panel %>">
<div class="panel-heading text-center">
<%= Templates.Render('alertGroupTitle', {group: group}) %>

File diff suppressed because one or more lines are too long

View File

@@ -67,12 +67,11 @@ func (a AlertList) Less(i, j int) bool {
// There is a hash computed from all alerts, it's used by UI to quickly tell
// if there was any change in a group and it needs to refresh it
type AlertGroup struct {
Labels map[string]string `json:"labels"`
Alerts AlertList `json:"alerts"`
ID string `json:"id"`
Hash string `json:"hash"`
SilencedCount int `json:"silencedCount"`
UnsilencedCount int `json:"unsilencedCount"`
Labels map[string]string `json:"labels"`
Alerts AlertList `json:"alerts"`
ID string `json:"id"`
Hash string `json:"hash"`
ActiveCount int `json:"activeCount"`
}
// Filter holds returned data on any filter passed by the user as part of the query

View File

@@ -159,15 +159,17 @@ func alerts(c *gin.Context) {
if silence := store.Store.GetSilence(alert.Silenced); silence != nil {
silences[alert.Silenced] = *silence
}
agCopy.SilencedCount++
countLabel(counters, "@silenced", "true")
} else {
agCopy.UnsilencedCount++
countLabel(counters, "@silenced", "false")
}
countLabel(counters, "@inhibited", strconv.FormatBool(alert.Inhibited))
if alert.Silenced == "" && !alert.Inhibited {
agCopy.ActiveCount++
}
for key, value := range alert.Labels {
if keyMap, foundKey := store.Store.Colors[key]; foundKey {
if color, foundColor := keyMap[value]; foundColor {