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
dd537b16
Commit
dd537b16
authored
Apr 03, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document log replacements
Rename latency to duration.
parent
8d0d324f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
middleware/log/README.md
middleware/log/README.md
+20
-1
middleware/replacer.go
middleware/replacer.go
+4
-1
No files found.
middleware/log/README.md
View file @
dd537b16
...
@@ -33,7 +33,26 @@ CoreDNS will create it before appending to it.
...
@@ -33,7 +33,26 @@ CoreDNS will create it before appending to it.
## Log Format
## Log Format
You can specify a custom log format with any placeholder values. Log supports both request and response placeholders.
You can specify a custom log format with any placeholder values. Log supports both request and
response placeholders.
The following place holders are supported:
*
`{type}`
: qtype of the request.
*
`{name}`
: qname of the request.
*
`{class}`
: class of the request.
*
`{proto}`
: protocol used (tcp or udp).
*
`{when}`
: time of the query.
*
`{remote}`
: client's IP address.
*
`{port}`
: client's port.
*
`{rcode}`
: response RCODE.
*
`{size}`
: response size.
*
`{duration}`
: response duration (in seconds).
*
`{>bufsize}`
: the EDNS0 buffer size advertized by the client.
*
`{>do}`
: is the EDNS0 DO (DNSSEC OK) bit set.
*
`{>id}`
: query ID
*
`{>opcode}`
: query OPCODE
## Log Rotation
## Log Rotation
...
...
middleware/replacer.go
View file @
dd537b16
package
middleware
package
middleware
import
(
import
(
"fmt"
"strconv"
"strconv"
"strings"
"strings"
"time"
"time"
...
@@ -54,13 +55,15 @@ func NewReplacer(r *dns.Msg, rr *ResponseRecorder, emptyValue string) Replacer {
...
@@ -54,13 +55,15 @@ func NewReplacer(r *dns.Msg, rr *ResponseRecorder, emptyValue string) Replacer {
}
}
rep
.
replacements
[
"{rcode}"
]
=
rcode
rep
.
replacements
[
"{rcode}"
]
=
rcode
rep
.
replacements
[
"{size}"
]
=
strconv
.
Itoa
(
rr
.
size
)
rep
.
replacements
[
"{size}"
]
=
strconv
.
Itoa
(
rr
.
size
)
rep
.
replacements
[
"{
latency
}"
]
=
time
.
Since
(
rr
.
start
)
.
String
()
rep
.
replacements
[
"{
duration
}"
]
=
time
.
Since
(
rr
.
start
)
.
String
()
}
}
// Header placeholders (case-insensitive)
// Header placeholders (case-insensitive)
// TODO(miek): syntax for flags and document it
// TODO(miek): syntax for flags and document it
rep
.
replacements
[
headerReplacer
+
"id}"
]
=
strconv
.
Itoa
(
int
(
r
.
Id
))
rep
.
replacements
[
headerReplacer
+
"id}"
]
=
strconv
.
Itoa
(
int
(
r
.
Id
))
rep
.
replacements
[
headerReplacer
+
"opcode}"
]
=
strconv
.
Itoa
(
int
(
r
.
Opcode
))
rep
.
replacements
[
headerReplacer
+
"opcode}"
]
=
strconv
.
Itoa
(
int
(
r
.
Opcode
))
rep
.
replacements
[
headerReplacer
+
"do}"
]
=
fmt
.
Sprintf
(
"%b"
,
state
.
Do
())
rep
.
replacements
[
headerReplacer
+
"bufsize}"
]
=
strconv
.
Itoa
(
state
.
Size
())
return
rep
return
rep
}
}
...
...
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