Dont log per qtype - fun and all, but not really useful

This commit is contained in:
Miek Gieben 2016-04-09 17:42:31 +01:00
parent 12b304d981
commit 49f994fa80
4 changed files with 16 additions and 16 deletions

View file

@ -38,7 +38,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
answer.SetRcode(r, rcode) answer.SetRcode(r, rcode)
state.SizeAndDo(answer) 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) w.WriteMsg(answer)
} }
rcode = 0 rcode = 0

View file

@ -12,7 +12,7 @@ import (
func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
state := middleware.State{W: w, Req: r} state := middleware.State{W: w, Req: r}
qname := state.Name() qname := state.Name()
qtype := state.Type() net := state.Proto()
zone := middleware.Zones(m.ZoneNames).Matches(qname) zone := middleware.Zones(m.ZoneNames).Matches(qname)
if zone == "" { if zone == "" {
zone = "." zone = "."
@ -22,21 +22,21 @@ func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
rw := middleware.NewResponseRecorder(w) rw := middleware.NewResponseRecorder(w)
status, err := m.Next.ServeDNS(ctx, rw, r) 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 return status, err
} }
// Report is a plain reporting function that the server can use for REFUSED and other // 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. // 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 { if requestCount == nil {
// no metrics are enabled // no metrics are enabled
return return
} }
requestCount.WithLabelValues(zone, qtype).Inc() requestCount.WithLabelValues(zone, net).Inc()
requestDuration.WithLabelValues(zone, qtype).Observe(float64(time.Since(start) / time.Second)) requestDuration.WithLabelValues(zone).Observe(float64(time.Since(start) / time.Second))
responseSize.WithLabelValues(zone, qtype).Observe(float64(size)) responseSize.WithLabelValues(zone).Observe(float64(size))
responseRcode.WithLabelValues(zone, rcode, qtype).Inc() responseRcode.WithLabelValues(zone, rcode).Inc()
} }

View file

@ -55,8 +55,8 @@ func define(subsystem string) {
Namespace: namespace, Namespace: namespace,
Subsystem: subsystem, Subsystem: subsystem,
Name: "request_count_total", Name: "request_count_total",
Help: "Counter of DNS requests made per zone and type and opcode.", Help: "Counter of DNS requests made per zone and protocol.",
}, []string{"zone", "qtype"}) }, []string{"zone", "proto"})
requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace, Namespace: namespace,
@ -64,7 +64,7 @@ func define(subsystem string) {
Name: "request_duration_seconds", Name: "request_duration_seconds",
Buckets: append([]float64{.0001, .0005, .001, .0025}, prometheus.DefBuckets...), Buckets: append([]float64{.0001, .0005, .001, .0025}, prometheus.DefBuckets...),
Help: "Histogram of the time (in seconds) each request took.", Help: "Histogram of the time (in seconds) each request took.",
}, []string{"zone", "qtype"}) }, []string{"zone"})
responseSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{ responseSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace, Namespace: namespace,
@ -72,14 +72,14 @@ func define(subsystem string) {
Name: "response_size_bytes", Name: "response_size_bytes",
Help: "Size of the returns response in 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}, 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{ responseRcode = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Subsystem: subsystem, Subsystem: subsystem,
Name: "response_rcode_count_total", Name: "response_rcode_count_total",
Help: "Counter of response status codes.", 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. // Dropped indicates we dropped the query before any handling. It has no closing dot, so it can not be a valid zone.

View file

@ -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. 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) 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) w.WriteMsg(m)
return return
} }
@ -345,7 +345,7 @@ func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rcode int) {
answer.SetRcode(r, rcode) answer.SetRcode(r, rcode)
state.SizeAndDo(answer) 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) w.WriteMsg(answer)
} }