diff --git a/discovery/ec2/ec2.go b/discovery/ec2/ec2.go index ca3f767eb..c4bc7f674 100644 --- a/discovery/ec2/ec2.go +++ b/discovery/ec2/ec2.go @@ -46,6 +46,7 @@ const ( ec2LabelPlatform = ec2Label + "platform" ec2LabelPublicDNS = ec2Label + "public_dns_name" ec2LabelPublicIP = ec2Label + "public_ip" + ec2LabelPrivateDNS = ec2Label + "private_dns_name" ec2LabelPrivateIP = ec2Label + "private_ip" ec2LabelPrimarySubnetID = ec2Label + "primary_subnet_id" ec2LabelSubnetID = ec2Label + "subnet_id" @@ -250,6 +251,9 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) { } labels[ec2LabelPrivateIP] = model.LabelValue(*inst.PrivateIpAddress) + if inst.PrivateDnsName != nil { + labels[ec2LabelPrivateDNS] = model.LabelValue(*inst.PrivateDnsName) + } addr := net.JoinHostPort(*inst.PrivateIpAddress, fmt.Sprintf("%d", d.port)) labels[model.AddressLabel] = model.LabelValue(addr) diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 83f4002dd..4e4c4a9b9 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -407,6 +407,7 @@ The following meta labels are available on targets during [relabeling](#relabel_ * `__meta_ec2_owner_id`: the ID of the AWS account that owns the EC2 instance * `__meta_ec2_platform`: the Operating System platform, set to 'windows' on Windows servers, absent otherwise * `__meta_ec2_primary_subnet_id`: the subnet ID of the primary network interface, if available +* `__meta_ec2_private_dns_name`: the private DNS name of the instance, if available * `__meta_ec2_private_ip`: the private IP address of the instance, if present * `__meta_ec2_public_dns_name`: the public DNS name of the instance, if available * `__meta_ec2_public_ip`: the public IP address of the instance, if available