Added metric for DNS failures

Signed-off-by: Chris Green <34572557+cgreen12@users.noreply.github.com>
This commit is contained in:
Chris Green
2019-07-04 03:06:29 -04:00
parent dc3864f170
commit 192fc433a2
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -61,6 +61,7 @@ func checkDNS() *models.DNSResults {
_, err := net.LookupIP(host)
if err != nil {
dnsResult.Error = err.Error()
CountDnsError(host)
}
dnsResult.ResponseTimeMs = time.Since(start).Nanoseconds() / int64(time.Millisecond)
results[host] = dnsResult
+19
View File
@@ -82,6 +82,16 @@ var (
"type",
},
)
goldpingerDnsErrorsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "goldpinger_dns_errors_total",
Help: "Statistics of DNS errors per instance",
},
[]string{
"goldpinger_instance",
"host",
},
)
bootTime = time.Now()
)
@@ -92,6 +102,7 @@ func init() {
prometheus.MustRegister(goldpingerResponseTimePeersHistogram)
prometheus.MustRegister(goldpingerResponseTimeKubernetesHistogram)
prometheus.MustRegister(goldpingerErrorsCounter)
prometheus.MustRegister(goldpingerDnsErrorsCounter)
log.Println("Metrics setup - see /metrics")
}
@@ -131,6 +142,14 @@ func CountError(errorType string) {
).Inc()
}
// counts instances of dns errors
func CountDnsError(host string) {
goldpingerDnsErrorsCounter.WithLabelValues(
GoldpingerConfig.Hostname,
host,
).Inc()
}
// returns a timer for easy observing of the durations of calls to kubernetes API
func GetLabeledKubernetesCallsTimer() *prometheus.Timer {
return prometheus.NewTimer(