|
|
@ -353,11 +353,11 @@ func (n *Manager) Send(alerts ...*Alert) { |
|
|
|
for _, a := range alerts { |
|
|
|
for _, a := range alerts { |
|
|
|
lb := labels.NewBuilder(a.Labels) |
|
|
|
lb := labels.NewBuilder(a.Labels) |
|
|
|
|
|
|
|
|
|
|
|
for _, l := range n.opts.ExternalLabels { |
|
|
|
n.opts.ExternalLabels.Range(func(l labels.Label) { |
|
|
|
if a.Labels.Get(l.Name) == "" { |
|
|
|
if a.Labels.Get(l.Name) == "" { |
|
|
|
lb.Set(l.Name, l.Value) |
|
|
|
lb.Set(l.Name, l.Value) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
a.Labels = lb.Labels(a.Labels) |
|
|
|
a.Labels = lb.Labels(a.Labels) |
|
|
|
} |
|
|
|
} |
|
|
@ -394,8 +394,8 @@ func (n *Manager) relabelAlerts(alerts []*Alert) []*Alert { |
|
|
|
var relabeledAlerts []*Alert |
|
|
|
var relabeledAlerts []*Alert |
|
|
|
|
|
|
|
|
|
|
|
for _, alert := range alerts { |
|
|
|
for _, alert := range alerts { |
|
|
|
labels := relabel.Process(alert.Labels, n.opts.RelabelConfigs...) |
|
|
|
labels, keep := relabel.Process(alert.Labels, n.opts.RelabelConfigs...) |
|
|
|
if labels != nil { |
|
|
|
if keep { |
|
|
|
alert.Labels = labels |
|
|
|
alert.Labels = labels |
|
|
|
relabeledAlerts = append(relabeledAlerts, alert) |
|
|
|
relabeledAlerts = append(relabeledAlerts, alert) |
|
|
|
} |
|
|
|
} |
|
|
@ -570,9 +570,9 @@ func alertsToOpenAPIAlerts(alerts []*Alert) models.PostableAlerts { |
|
|
|
|
|
|
|
|
|
|
|
func labelsToOpenAPILabelSet(modelLabelSet labels.Labels) models.LabelSet { |
|
|
|
func labelsToOpenAPILabelSet(modelLabelSet labels.Labels) models.LabelSet { |
|
|
|
apiLabelSet := models.LabelSet{} |
|
|
|
apiLabelSet := models.LabelSet{} |
|
|
|
for _, label := range modelLabelSet { |
|
|
|
modelLabelSet.Range(func(label labels.Label) { |
|
|
|
apiLabelSet[label.Name] = label.Value |
|
|
|
apiLabelSet[label.Name] = label.Value |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return apiLabelSet |
|
|
|
return apiLabelSet |
|
|
|
} |
|
|
|
} |
|
|
@ -719,9 +719,9 @@ func AlertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lset := relabel.Process(labels.New(lbls...), cfg.RelabelConfigs...) |
|
|
|
lset, keep := relabel.Process(labels.New(lbls...), cfg.RelabelConfigs...) |
|
|
|
if lset == nil { |
|
|
|
if !keep { |
|
|
|
droppedAlertManagers = append(droppedAlertManagers, alertmanagerLabels{lbls}) |
|
|
|
droppedAlertManagers = append(droppedAlertManagers, alertmanagerLabels{labels.New(lbls...)}) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|