From 52f398e7f794215375c767b87149951297287d23 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 17 Oct 2018 10:58:06 +0200 Subject: [PATCH] cloudwatch: return a distinct list of regions --- pkg/tsdb/cloudwatch/metric_find_query.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/cloudwatch/metric_find_query.go b/pkg/tsdb/cloudwatch/metric_find_query.go index f2633bd6be6..b74af76f09a 100644 --- a/pkg/tsdb/cloudwatch/metric_find_query.go +++ b/pkg/tsdb/cloudwatch/metric_find_query.go @@ -249,7 +249,18 @@ func (e *CloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *s plog.Error("Failed to get regions", "error", err) } else { for _, region := range r.Regions { - regions = append(regions, *region.RegionName) + exists := false + + for _, existingRegion := range regions { + if existingRegion == *region.RegionName { + exists = true + break + } + } + + if !exists { + regions = append(regions, *region.RegionName) + } } } sort.Strings(regions)