From 8e659a51099fae08be3fb62f39fcef68ec6edec7 Mon Sep 17 00:00:00 2001 From: Serghei Anicheev Date: Fri, 30 Nov 2018 22:11:06 +1100 Subject: [PATCH] =?UTF-8?q?Adding=20private=5Fdns=5Fname=20to=20the=20list?= =?UTF-8?q?=20of=20ec2=20labels=20which=20can=20be=20used=20i=E2=80=A6=20(?= =?UTF-8?q?#4693)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding private_dns_name to the list of ec2 labels which can be used in node naming for dynamic environments Signed-off-by: Serghei Anicheev --- discovery/ec2/ec2.go | 4 ++++ docs/configuration/configuration.md | 1 + 2 files changed, 5 insertions(+) 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