Skip to content

Commit

Permalink
remove empty labels from fingerprint (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: Erez Levi <[email protected]>
  • Loading branch information
ErezLevip and Erez Levi authored Nov 6, 2024
1 parent af53e56 commit fbdbdfb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/services/ngalert/state/historian/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ func StatesToStream(rule history_model.RuleMeta, states []state.StateTransition,

func calculateFingerprint(labels data.Labels) string {
cpLabels := labels.Copy()
delete(cpLabels, "__alert_rule_namespace_uid__")
for k, v := range cpLabels {
// The Grafana Alertmanager skips empty and namespace UID labels.
// To get the same alert fingerprint we need to remove these labels too.
// https://github.com/grafana/alerting/blob/2dda1c67ec02625ac9fc8607157b3d5825d47919/notify/grafana_alertmanager.go#L722-L724
if len(v) == 0 || k == "__alert_rule_namespace_uid__" {
delete(cpLabels, k)
}
}
return labelFingerprint(cpLabels)
}

Expand Down

0 comments on commit fbdbdfb

Please sign in to comment.