From 24be9d9ab3402795be715f3f7897ed3e70ac8a76 Mon Sep 17 00:00:00 2001 From: frh-td <73470898+frh-td@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:37:15 +0200 Subject: [PATCH] Fix when multiple label names normalize to the same string Signed-off-by: frh-td <73470898+frh-td@users.noreply.github.com> --- .../io/prometheus/cloudwatch/CloudWatchCollector.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/prometheus/cloudwatch/CloudWatchCollector.java b/src/main/java/io/prometheus/cloudwatch/CloudWatchCollector.java index 71ff755c..f5ea9a79 100644 --- a/src/main/java/io/prometheus/cloudwatch/CloudWatchCollector.java +++ b/src/main/java/io/prometheus/cloudwatch/CloudWatchCollector.java @@ -639,8 +639,12 @@ private void scrape(List mfs) { // "tag_" prefix // The AWS tags are case sensitive, so to avoid loosing information and label // collisions, tag keys are not snaked cased - labelNames.add("tag_" + safeLabelName(tag.key())); - labelValues.add(tag.value()); + String labelName = "tag_" + safeLabelName(tag.key()); + // If multiple labels end up with the same safe label name, use only the first + if (!labelNames.contains(labelName)) { + labelNames.add(labelName); + labelValues.add(tag.value()); + } } infoSamples.add(