mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
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:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user