Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
49f994fa
Commit
49f994fa
authored
Apr 09, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont log per qtype - fun and all, but not really useful
parent
12b304d9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
middleware/log/log.go
middleware/log/log.go
+1
-1
middleware/metrics/handler.go
middleware/metrics/handler.go
+7
-7
middleware/metrics/metrics.go
middleware/metrics/metrics.go
+5
-5
server/server.go
server/server.go
+3
-3
No files found.
middleware/log/log.go
View file @
49f994fa
...
@@ -38,7 +38,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -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
...
...
middleware/metrics/handler.go
View file @
49f994fa
...
@@ -12,7 +12,7 @@ import (
...
@@ -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)
...
@@ -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
()
}
}
middleware/metrics/metrics.go
View file @
49f994fa
...
@@ -55,8 +55,8 @@ func define(subsystem string) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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.
...
...
server/server.go
View file @
49f994fa
...
@@ -280,9 +280,9 @@ func (s *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
...
@@ -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) {
...
@@ -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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment