Dont log per qtype - fun and all, but not really useful
This commit is contained in:
parent
12b304d981
commit
49f994fa80
4 changed files with 16 additions and 16 deletions
|
@ -38,7 +38,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||
answer.SetRcode(r, rcode)
|
||||
state.SizeAndDo(answer)
|
||||
|
||||
metrics.Report(metrics.Dropped, state.Type(), rc, answer.Len(), time.Now())
|
||||
metrics.Report(metrics.Dropped, state.Proto(), rc, answer.Len(), time.Now())
|
||||
w.WriteMsg(answer)
|
||||
}
|
||||
rcode = 0
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||
state := middleware.State{W: w, Req: r}
|
||||
qname := state.Name()
|
||||
qtype := state.Type()
|
||||
net := state.Proto()
|
||||
zone := middleware.Zones(m.ZoneNames).Matches(qname)
|
||||
if zone == "" {
|
||||
zone = "."
|
||||
|
@ -22,21 +22,21 @@ func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||
rw := middleware.NewResponseRecorder(w)
|
||||
status, err := m.Next.ServeDNS(ctx, rw, r)
|
||||
|
||||
Report(zone, qtype, rw.Rcode(), rw.Size(), rw.Start())
|
||||
Report(zone, net, rw.Rcode(), rw.Size(), rw.Start())
|
||||
|
||||
return status, err
|
||||
}
|
||||
|
||||
// Report is a plain reporting function that the server can use for REFUSED and other
|
||||
// queries that are turned down because they don't match any middleware.
|
||||
func Report(zone, qtype, rcode string, size int, start time.Time) {
|
||||
func Report(zone, net, rcode string, size int, start time.Time) {
|
||||
if requestCount == nil {
|
||||
// no metrics are enabled
|
||||
return
|
||||
}
|
||||
|
||||
requestCount.WithLabelValues(zone, qtype).Inc()
|
||||
requestDuration.WithLabelValues(zone, qtype).Observe(float64(time.Since(start) / time.Second))
|
||||
responseSize.WithLabelValues(zone, qtype).Observe(float64(size))
|
||||
responseRcode.WithLabelValues(zone, rcode, qtype).Inc()
|
||||
requestCount.WithLabelValues(zone, net).Inc()
|
||||
requestDuration.WithLabelValues(zone).Observe(float64(time.Since(start) / time.Second))
|
||||
responseSize.WithLabelValues(zone).Observe(float64(size))
|
||||
responseRcode.WithLabelValues(zone, rcode).Inc()
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ func define(subsystem string) {
|
|||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "request_count_total",
|
||||
Help: "Counter of DNS requests made per zone and type and opcode.",
|
||||
}, []string{"zone", "qtype"})
|
||||
Help: "Counter of DNS requests made per zone and protocol.",
|
||||
}, []string{"zone", "proto"})
|
||||
|
||||
requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
|
@ -64,7 +64,7 @@ func define(subsystem string) {
|
|||
Name: "request_duration_seconds",
|
||||
Buckets: append([]float64{.0001, .0005, .001, .0025}, prometheus.DefBuckets...),
|
||||
Help: "Histogram of the time (in seconds) each request took.",
|
||||
}, []string{"zone", "qtype"})
|
||||
}, []string{"zone"})
|
||||
|
||||
responseSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
|
@ -72,14 +72,14 @@ func define(subsystem string) {
|
|||
Name: "response_size_bytes",
|
||||
Help: "Size of the returns response in bytes.",
|
||||
Buckets: []float64{0, 100, 200, 300, 400, 511, 1023, 2047, 4095, 8291, 16e3, 32e3, 48e3, 64e3},
|
||||
}, []string{"zone", "qtype"})
|
||||
}, []string{"zone"})
|
||||
|
||||
responseRcode = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "response_rcode_count_total",
|
||||
Help: "Counter of response status codes.",
|
||||
}, []string{"zone", "rcode", "qtype"})
|
||||
}, []string{"zone", "rcode"})
|
||||
}
|
||||
|
||||
// Dropped indicates we dropped the query before any handling. It has no closing dot, so it can not be a valid zone.
|
||||
|
|
|
@ -280,9 +280,9 @@ func (s *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||
}()
|
||||
|
||||
if m, err := middleware.Edns0Version(r); err != nil { // Wrong EDNS version, return at once.
|
||||
qtype := dns.Type(r.Question[0].Qtype).String()
|
||||
rc := middleware.RcodeToString(dns.RcodeBadVers)
|
||||
metrics.Report(metrics.Dropped, qtype, rc, m.Len(), time.Now())
|
||||
// TODO(miek): hardcoded "udp" here.
|
||||
metrics.Report(metrics.Dropped, "udp", rc, m.Len(), time.Now())
|
||||
w.WriteMsg(m)
|
||||
return
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rcode int) {
|
|||
answer.SetRcode(r, rcode)
|
||||
state.SizeAndDo(answer)
|
||||
|
||||
metrics.Report(metrics.Dropped, state.Type(), rc, answer.Len(), time.Now())
|
||||
metrics.Report(metrics.Dropped, state.Proto(), rc, answer.Len(), time.Now())
|
||||
w.WriteMsg(answer)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue