mirror of https://github.com/prometheus/prometheus
discovery/ec2: Maintain order of subnet_id label
Signed-off-by: José Martínez <xosemp@gmail.com>pull/4415/head
parent
286a8e0554
commit
5e4a33c890
|
@ -257,13 +257,14 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) {
|
||||||
if inst.VpcId != nil {
|
if inst.VpcId != nil {
|
||||||
labels[ec2LabelVPCID] = model.LabelValue(*inst.VpcId)
|
labels[ec2LabelVPCID] = model.LabelValue(*inst.VpcId)
|
||||||
|
|
||||||
|
// Deduplicate VPC Subnet IDs maintaining the order of the network interfaces returned by EC2.
|
||||||
|
var subnets []string
|
||||||
subnetsMap := make(map[string]struct{})
|
subnetsMap := make(map[string]struct{})
|
||||||
for _, eni := range inst.NetworkInterfaces {
|
for _, eni := range inst.NetworkInterfaces {
|
||||||
subnetsMap[*eni.SubnetId] = struct{}{}
|
if _, ok := subnetsMap[*eni.SubnetId]; !ok {
|
||||||
}
|
subnetsMap[*eni.SubnetId] = struct{}{}
|
||||||
subnets := []string{}
|
subnets = append(subnets, *eni.SubnetId)
|
||||||
for k := range subnetsMap {
|
}
|
||||||
subnets = append(subnets, k)
|
|
||||||
}
|
}
|
||||||
labels[ec2LabelSubnetID] = model.LabelValue(
|
labels[ec2LabelSubnetID] = model.LabelValue(
|
||||||
subnetSeparator +
|
subnetSeparator +
|
||||||
|
|
Loading…
Reference in New Issue