fix(api): apply colors to the @alertmanager label

It's a fake label so it needs special code to inject the color information to the API response.

Fixes #421
This commit is contained in:
Łukasz Mierzwa
2019-02-06 17:11:25 +00:00
parent edfd5a9ac7
commit 22f719adc6
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 {