introduce metric naming test (#3789)

* introduce metric naming test

Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>

* Update metrics.go

Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
This commit is contained in:
Zou Nengren
2020-03-31 14:07:36 +08:00
committed by GitHub
parent 10d176b811
commit 87214a4c5c
18 changed files with 297 additions and 97 deletions

View File

@@ -53,7 +53,7 @@ used (See [bugs](#bugs)).
If monitoring is enabled (via the *prometheus* plugin) then the following metrics are exported:
* `coredns_dnssec_cache_size{server, type}` - total elements in the cache, type is "signature".
* `coredns_dnssec_cache_entries{server, type}` - total elements in the cache, type is "signature".
* `coredns_dnssec_cache_hits_total{server}` - Counter of cache hits.
* `coredns_dnssec_cache_misses_total{server}` - Counter of cache misses.

View File

@@ -8,7 +8,6 @@ import (
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus"
)
// ServeDNS implements the plugin.Handler interface.
@@ -47,28 +46,5 @@ func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
return plugin.NextOrFailure(d.Name(), d.Next, ctx, w, r)
}
var (
cacheSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_size",
Help: "The number of elements in the dnssec cache.",
}, []string{"server", "type"})
cacheHits = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_hits_total",
Help: "The count of cache hits.",
}, []string{"server"})
cacheMisses = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_misses_total",
Help: "The count of cache misses.",
}, []string{"server"})
)
// Name implements the Handler interface.
func (d Dnssec) Name() string { return "dnssec" }

31
plugin/dnssec/metrics.go Normal file
View File

@@ -0,0 +1,31 @@
package dnssec
import (
"github.com/coredns/coredns/plugin"
"github.com/prometheus/client_golang/prometheus"
)
var (
// cacheSize is the number of elements in the dnssec cache.
cacheSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_entries",
Help: "The number of elements in the dnssec cache.",
}, []string{"server", "type"})
// cacheHits is the count of cache hits.
cacheHits = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_hits_total",
Help: "The count of cache hits.",
}, []string{"server"})
// cacheMisses is the count of cache misses.
cacheMisses = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace,
Subsystem: "dnssec",
Name: "cache_misses_total",
Help: "The count of cache misses.",
}, []string{"server"})
)