From: aparcar Date: Thu, 2 Mar 2017 00:45:51 +0000 (+0100) Subject: add prober_dns_lookup_time_seconds metric to solve #60 (#118) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2fbdace1eb059c75d95fbf16d7b4d4322d9bba50;p=blackbox_exporter.git add prober_dns_lookup_time_seconds metric to solve #60 (#118) add probe_dns_lookup_time_seconds metric --- diff --git a/icmp.go b/icmp.go index 57fa0a1..0d5124a 100644 --- a/icmp.go +++ b/icmp.go @@ -73,10 +73,13 @@ func probeICMP(target string, w http.ResponseWriter, module Module) (success boo fallbackProtocol = "ip6" } + resolveStart := time.Now() ip, err := net.ResolveIPAddr(module.ICMP.PreferredIpProtocol, target) if err != nil && fallbackProtocol != "" { ip, err = net.ResolveIPAddr(fallbackProtocol, target) } + fmt.Fprintf(w, "probe_dns_lookup_time_seconds %f\n", float64(time.Since(resolveStart).Seconds())) + if err != nil { log.Errorf("Error resolving address %s: %s", target, err) return