Strip labels in dedup, not on pull

Strippling labels should be done after alerts are deduplicated, when user requests some alerts with a filter, not during data collection from Alertmanager. When labels are stripped before dedup then they are merged into one, because labels are needed to calculate uniqueness, which means we will return wrong data
This commit is contained in:
Łukasz Mierzwa
2017-08-10 22:23:47 -07:00
parent d1d4a85409
commit 3608ccba21
2 changed files with 4 additions and 2 deletions

View File

@@ -3,8 +3,10 @@ package alertmanager
import (
"sort"
"github.com/cloudflare/unsee/internal/config"
"github.com/cloudflare/unsee/internal/models"
"github.com/cloudflare/unsee/internal/slices"
"github.com/cloudflare/unsee/internal/transform"
)
// DedupAlerts will collect alert groups from all defined Alertmanager
@@ -61,6 +63,8 @@ func DedupAlerts() []models.AlertGroup {
ag := models.AlertGroup(agList[0])
ag.Alerts = models.AlertList{}
for _, alert := range alerts {
// strip labels user doesn't want to see in the UI
alert.Labels = transform.StripLables(config.Config.KeepLabels, config.Config.StripLabels, alert.Labels)
// calculate final alert state based on the most important value found
// in the list of states from all instances
alertLFP := alert.LabelsFingerprint()

View File

@@ -6,7 +6,6 @@ import (
"sync"
"time"
"github.com/cloudflare/unsee/internal/config"
"github.com/cloudflare/unsee/internal/mapper"
"github.com/cloudflare/unsee/internal/models"
"github.com/cloudflare/unsee/internal/transform"
@@ -174,7 +173,6 @@ func (am *Alertmanager) pullAlerts(version string) error {
}
alert.Annotations, alert.Links = transform.DetectLinks(alert.Annotations)
alert.Labels = transform.StripLables(config.Config.KeepLabels, config.Config.StripLabels, alert.Labels)
transform.ColorLabel(colors, "@receiver", alert.Receiver)
for k, v := range alert.Labels {