aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com> 2020-09-14 12:42:55 +0300
committerGravatar GitHub <noreply@github.com> 2020-09-14 11:42:55 +0200
commit30a4a87eaa3c4974cbfb7cc746b2d3f21842523a (patch)
tree8151d02dbbbd427df7e9ce13736f57fb0140e4d1
parent2fe5d684f9d9bf5691ef0bceb06d7838d66d3cd7 (diff)
downloadcoredns-30a4a87eaa3c4974cbfb7cc746b2d3f21842523a.tar.gz
coredns-30a4a87eaa3c4974cbfb7cc746b2d3f21842523a.tar.zst
coredns-30a4a87eaa3c4974cbfb7cc746b2d3f21842523a.zip
plugin/forward: add hit/miss metrics for connection cache (#4114)
Signed-off-by: Ruslan Drozhdzh <rdrozhdzh@infoblox.com>
-rw-r--r--plugin/forward/README.md6
-rw-r--r--plugin/forward/connect.go2
-rw-r--r--plugin/forward/metrics.go12
3 files changed, 18 insertions, 2 deletions
diff --git a/plugin/forward/README.md b/plugin/forward/README.md
index 46422b263..e7eb577d0 100644
--- a/plugin/forward/README.md
+++ b/plugin/forward/README.md
@@ -112,10 +112,12 @@ If monitoring is enabled (via the *prometheus* plugin) then the following metric
* `coredns_forward_healthcheck_failures_total{to}` - number of failed health checks per upstream.
* `coredns_forward_healthcheck_broken_total{}` - counter of when all upstreams are unhealthy,
and we are randomly (this always uses the `random` policy) spraying to an upstream.
-* `max_concurrent_rejects_total{}` - counter of the number of queries rejected because the
+* `coredns_forward_max_concurrent_rejects_total{}` - counter of the number of queries rejected because the
number of concurrent queries were at maximum.
+* `coredns_forward_conn_cache_hits_total{to, proto}` - counter of connection cache hits per upstream and protocol.
+* `coredns_forward_conn_cache_misses_total{to, proto}` - counter of connection cache misses per upstream and protocol.
Where `to` is one of the upstream servers (**TO** from the config), `rcode` is the returned RCODE
-from the upstream.
+from the upstream, `proto` is the transport protocol like `udp`, `tcp`, `tcp-tls`.
## Examples
diff --git a/plugin/forward/connect.go b/plugin/forward/connect.go
index 9ac1afe16..c181c98cb 100644
--- a/plugin/forward/connect.go
+++ b/plugin/forward/connect.go
@@ -54,8 +54,10 @@ func (t *Transport) Dial(proto string) (*persistConn, bool, error) {
pc := <-t.ret
if pc != nil {
+ ConnCacheHitsCount.WithLabelValues(t.addr, proto).Add(1)
return pc, true, nil
}
+ ConnCacheMissesCount.WithLabelValues(t.addr, proto).Add(1)
reqTime := time.Now()
timeout := t.dialTimeout()
diff --git a/plugin/forward/metrics.go b/plugin/forward/metrics.go
index 0b63ce1e7..98f2805c1 100644
--- a/plugin/forward/metrics.go
+++ b/plugin/forward/metrics.go
@@ -52,4 +52,16 @@ var (
Name: "max_concurrent_rejects_total",
Help: "Counter of the number of queries rejected because the concurrent queries were at maximum.",
})
+ ConnCacheHitsCount = promauto.NewCounterVec(prometheus.CounterOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "forward",
+ Name: "conn_cache_hits_total",
+ Help: "Counter of connection cache hits per upstream and protocol.",
+ }, []string{"to", "proto"})
+ ConnCacheMissesCount = promauto.NewCounterVec(prometheus.CounterOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "forward",
+ Name: "conn_cache_misses_total",
+ Help: "Counter of connection cache misses per upstream and protocol.",
+ }, []string{"to", "proto"})
)