mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
scrape: fallback to hostname if lookup fails (#5366)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
4397916cb2
commit
23069b87dc
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue