Merge pull request #422 from prymitive/fix-alertmanager-colors

fix(api): apply colors to the @alertmanager label
This commit is contained in:
Łukasz Mierzwa
2019-02-06 17:46:47 +00:00
committed by GitHub
3 changed files with 16 additions and 0 deletions

View File

@@ -324,6 +324,8 @@ for `warning` and blue for `info`:
labels:
color:
custom:
"@alertmanager":
prod: "#e6e"
severity:
info: "#87c4e0"
warning: "#ffae42"

View File

@@ -322,6 +322,9 @@ func (am *Alertmanager) pullAlerts(version string) error {
}
transform.ColorLabel(colors, "@receiver", alert.Receiver)
for _, am := range alert.Alertmanager {
transform.ColorLabel(colors, "@alertmanager", am.Name)
}
for k, v := range alert.Labels {
transform.ColorLabel(colors, k, v)
}

View File

@@ -162,6 +162,17 @@ func alerts(c *gin.Context) {
}
}
if ck, foundKey := dedupedColors["@alertmanager"]; foundKey {
for _, am := range alert.Alertmanager {
if cv, foundVal := ck[am.Name]; foundVal {
if _, found := colors["@alertmanager"]; !found {
colors["@alertmanager"] = map[string]models.LabelColors{}
}
colors["@alertmanager"][am.Name] = cv
}
}
}
agCopy.StateCount[alert.State]++
for _, am := range alert.Alertmanager {