From c29cb2c0a9528088a965ed8f9850486939a66049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Fri, 30 Jun 2017 23:41:25 -0700 Subject: [PATCH] Sort alert groups so they are returned in a stable order --- alertmanager/dedup.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/alertmanager/dedup.go b/alertmanager/dedup.go index b5281df13..a6f7e03a6 100644 --- a/alertmanager/dedup.go +++ b/alertmanager/dedup.go @@ -50,6 +50,10 @@ func DedupAlerts() []models.AlertGroup { dedupedGroups = append(dedupedGroups, ag) } + // sort alert groups so they are always returned in the same order + // use group ID which is unique and immutable + sort.Slice(dedupedGroups, func(i, j int) bool { return dedupedGroups[i].ID < dedupedGroups[j].ID }) + return dedupedGroups }