Skip to content

Commit 24be9d9

Browse files
committed
Fix when multiple label names normalize to the same string
Signed-off-by: frh-td <73470898+frh-td@users.noreply.github.com>
1 parent f1ca94b commit 24be9d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/io/prometheus/cloudwatch/CloudWatchCollector.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,12 @@ private void scrape(List<MetricFamilySamples> mfs) {
639639
// "tag_" prefix
640640
// The AWS tags are case sensitive, so to avoid loosing information and label
641641
// collisions, tag keys are not snaked cased
642-
labelNames.add("tag_" + safeLabelName(tag.key()));
643-
labelValues.add(tag.value());
642+
String labelName = "tag_" + safeLabelName(tag.key());
643+
// If multiple labels end up with the same safe label name, use only the first
644+
if (!labelNames.contains(labelName)) {
645+
labelNames.add(labelName);
646+
labelValues.add(tag.value());
647+
}
644648
}
645649

646650
infoSamples.add(

0 commit comments

Comments
 (0)