mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
metrics: remove RR type (#4534)
To combat label cardinality explosions remove the type from metrics. This was most severe in the histogram for request duration, remove it there. It's also highlighted difference between grpc and forward code, where forward did use type and grpc didn't; getting rid of all that "fixes" that discrepancy Move monitor.go back into the vars directory and make it private again. Also name it slightly better Fixes: #4507 Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coredns/coredns/plugin/pkg/dnsutil"
|
|
||||||
"github.com/coredns/coredns/request"
|
"github.com/coredns/coredns/request"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@@ -130,11 +129,9 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
|
|||||||
rc = strconv.Itoa(ret.Rcode)
|
rc = strconv.Itoa(ret.Rcode)
|
||||||
}
|
}
|
||||||
|
|
||||||
qtype := dnsutil.QTypeMonitorLabel(state.QType())
|
|
||||||
|
|
||||||
RequestCount.WithLabelValues(p.addr).Add(1)
|
RequestCount.WithLabelValues(p.addr).Add(1)
|
||||||
RcodeCount.WithLabelValues(rc, p.addr).Add(1)
|
RcodeCount.WithLabelValues(rc, p.addr).Add(1)
|
||||||
RequestDuration.WithLabelValues(p.addr, rc, qtype).Observe(time.Since(start).Seconds())
|
RequestDuration.WithLabelValues(p.addr, rc).Observe(time.Since(start).Seconds())
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ var (
|
|||||||
Name: "request_duration_seconds",
|
Name: "request_duration_seconds",
|
||||||
Buckets: plugin.TimeBuckets,
|
Buckets: plugin.TimeBuckets,
|
||||||
Help: "Histogram of the time each request took.",
|
Help: "Histogram of the time each request took.",
|
||||||
}, []string{"to", "rcode", "type"})
|
}, []string{"to", "rcode"})
|
||||||
HealthcheckFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{
|
HealthcheckFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: plugin.Namespace,
|
Namespace: plugin.Namespace,
|
||||||
Subsystem: "forward",
|
Subsystem: "forward",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package dnsutil
|
package vars
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@@ -25,13 +25,11 @@ var monitorType = map[uint16]struct{}{
|
|||||||
dns.TypeANY: {},
|
dns.TypeANY: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
const other = "other"
|
// qTypeString returns the RR type based on monitorType. It returns the text representation
|
||||||
|
// of thosAe types. RR types not in that list will have "other" returned.
|
||||||
// QTypeMonitorLabel returns dns type label based on a list of monitored types.
|
func qTypeString(qtype uint16) string {
|
||||||
// Will return "other" for unmonitored ones.
|
|
||||||
func QTypeMonitorLabel(qtype uint16) string {
|
|
||||||
if _, known := monitorType[qtype]; known {
|
if _, known := monitorType[qtype]; known {
|
||||||
return dns.Type(qtype).String()
|
return dns.Type(qtype).String()
|
||||||
}
|
}
|
||||||
return other
|
return "other"
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package vars
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coredns/coredns/plugin/pkg/dnsutil"
|
|
||||||
"github.com/coredns/coredns/request"
|
"github.com/coredns/coredns/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,14 +17,14 @@ func Report(server string, req request.Request, zone, rcode string, size int, st
|
|||||||
fam = "2"
|
fam = "2"
|
||||||
}
|
}
|
||||||
|
|
||||||
qtype := dnsutil.QTypeMonitorLabel(req.QType())
|
|
||||||
|
|
||||||
if req.Do() {
|
if req.Do() {
|
||||||
RequestDo.WithLabelValues(server, zone).Inc()
|
RequestDo.WithLabelValues(server, zone).Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qtype := qTypeString(req.QType())
|
||||||
RequestCount.WithLabelValues(server, zone, net, fam, qtype).Inc()
|
RequestCount.WithLabelValues(server, zone, net, fam, qtype).Inc()
|
||||||
RequestDuration.WithLabelValues(server, zone, qtype).Observe(time.Since(start).Seconds())
|
|
||||||
|
RequestDuration.WithLabelValues(server, zone).Observe(time.Since(start).Seconds())
|
||||||
|
|
||||||
ResponseSize.WithLabelValues(server, zone, net).Observe(float64(size))
|
ResponseSize.WithLabelValues(server, zone, net).Observe(float64(size))
|
||||||
RequestSize.WithLabelValues(server, zone, net).Observe(float64(req.Len()))
|
RequestSize.WithLabelValues(server, zone, net).Observe(float64(req.Len()))
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ var (
|
|||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: "request_duration_seconds",
|
Name: "request_duration_seconds",
|
||||||
Buckets: plugin.TimeBuckets,
|
Buckets: plugin.TimeBuckets,
|
||||||
Help: "Histogram of the time (in seconds) each request took.",
|
Help: "Histogram of the time (in seconds) each request took per zone.",
|
||||||
}, []string{"server", "zone", "type"})
|
}, []string{"server", "zone"})
|
||||||
|
|
||||||
RequestSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
RequestSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||||
Namespace: plugin.Namespace,
|
Namespace: plugin.Namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: "request_size_bytes",
|
Name: "request_size_bytes",
|
||||||
Help: "Size of the EDNS0 UDP buffer in bytes (64K for TCP).",
|
Help: "Size of the EDNS0 UDP buffer in bytes (64K for TCP) per zone and protocol.",
|
||||||
Buckets: []float64{0, 100, 200, 300, 400, 511, 1023, 2047, 4095, 8291, 16e3, 32e3, 48e3, 64e3},
|
Buckets: []float64{0, 100, 200, 300, 400, 511, 1023, 2047, 4095, 8291, 16e3, 32e3, 48e3, 64e3},
|
||||||
}, []string{"server", "zone", "proto"})
|
}, []string{"server", "zone", "proto"})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user