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=8E=E0=B9=8E=E0=B9=8E=E0=B9=8E=E0=B9=8E=E0=B9=8E=E0=B9=8E?= =?UTF-8?q?=E0=B9=8E=E0=B9=8E=E0=B9=8E=E0=B9=8E?= Date: Tue, 2 Oct 2018 12:48:31 +0200 Subject: [PATCH] [FIX] EC2 DS: Check for existence of OwnerID (#4672) Commit 1c89984 introduced the ability to expose the owner of the instance. However, this breaks Prometheus if there is no OwnerID in the reservation (Eg. if you are using a private EC2-API introduced by #4333) Signed-off-by: Jannick Fahlbusch --- discovery/ec2/ec2.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discovery/ec2/ec2.go b/discovery/ec2/ec2.go index d984fd3c6..a4f09cf06 100644 --- a/discovery/ec2/ec2.go +++ b/discovery/ec2/ec2.go @@ -241,9 +241,13 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) { continue } labels := model.LabelSet{ - ec2LabelOwnerID: model.LabelValue(*r.OwnerId), ec2LabelInstanceID: model.LabelValue(*inst.InstanceId), } + + if r.OwnerId != nil { + labels[ec2LabelOwnerID] = model.LabelValue(*r.OwnerId) + } + labels[ec2LabelPrivateIP] = model.LabelValue(*inst.PrivateIpAddress) addr := net.JoinHostPort(*inst.PrivateIpAddress, fmt.Sprintf("%d", d.port)) labels[model.AddressLabel] = model.LabelValue(addr)