mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-08-23 21:36:25 +00:00
Added metric for DNS failures
Signed-off-by: Chris Green <34572557+cgreen12@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user