From f6fbcf9aa26c4dbeb1f217f10e75c5bf0fb436c3 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Thu, 22 Sep 2016 15:01:23 +0200 Subject: [PATCH] Expose ec2_instance_state --- retrieval/discovery/ec2.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/retrieval/discovery/ec2.go b/retrieval/discovery/ec2.go index 6d6e340ac..1c376b5e3 100644 --- a/retrieval/discovery/ec2.go +++ b/retrieval/discovery/ec2.go @@ -32,16 +32,17 @@ import ( ) const ( - ec2Label = model.MetaLabelPrefix + "ec2_" - ec2LabelAZ = ec2Label + "availability_zone" - ec2LabelInstanceID = ec2Label + "instance_id" - ec2LabelPublicDNS = ec2Label + "public_dns_name" - ec2LabelPublicIP = ec2Label + "public_ip" - ec2LabelPrivateIP = ec2Label + "private_ip" - ec2LabelSubnetID = ec2Label + "subnet_id" - ec2LabelTag = ec2Label + "tag_" - ec2LabelVPCID = ec2Label + "vpc_id" - subnetSeparator = "," + ec2Label = model.MetaLabelPrefix + "ec2_" + ec2LabelAZ = ec2Label + "availability_zone" + ec2LabelInstanceID = ec2Label + "instance_id" + ec2LabelInstanceState = ec2Label + "instance_state" + ec2LabelPublicDNS = ec2Label + "public_dns_name" + ec2LabelPublicIP = ec2Label + "public_ip" + ec2LabelPrivateIP = ec2Label + "private_ip" + ec2LabelSubnetID = ec2Label + "subnet_id" + ec2LabelTag = ec2Label + "tag_" + ec2LabelVPCID = ec2Label + "vpc_id" + subnetSeparator = "," ) // EC2Discovery periodically performs EC2-SD requests. It implements @@ -122,6 +123,7 @@ func (ed *EC2Discovery) refresh() (*config.TargetGroup, error) { } labels[ec2LabelAZ] = model.LabelValue(*inst.Placement.AvailabilityZone) + labels[ec2LabelInstanceState] = model.LabelValue(*inst.State.Name) if inst.VpcId != nil { labels[ec2LabelVPCID] = model.LabelValue(*inst.VpcId)