From 23069b87dc2b4cf6b3ae8c294825ed3c60a89cc0 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Fri, 15 Mar 2019 13:02:16 +0100 Subject: [PATCH] scrape: fallback to hostname if lookup fails (#5366) Signed-off-by: Simon Pasquier --- scrape/manager.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scrape/manager.go b/scrape/manager.go index 1af9141077..163d7ed14d 100644 --- a/scrape/manager.go +++ b/scrape/manager.go @@ -241,7 +241,7 @@ func (m *Manager) TargetsDropped() map[string][]*Target { return targets } -// getFqdn returns a fqdn if it's possible, otherwise falls back a hostname. +// getFqdn returns a FQDN if it's possible, otherwise falls back to hostname. func getFqdn() (string, error) { hostname, err := os.Hostname() if err != nil { @@ -250,7 +250,8 @@ func getFqdn() (string, error) { ips, err := net.LookupIP(hostname) if err != nil { - return hostname, err + // Return the system hostname if we can't look up the IP address. + return hostname, nil } lookup := func(ipStr encoding.TextMarshaler) (string, error) {