aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-04-03 17:05:16 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2016-04-03 17:05:16 +0100
commitdd537b163ddf63eae428da346e4fa12c2266c0e7 (patch)
treeb148e1f84e261b68bd943cff54412af4c43b7cf3
parent8d0d324f274b6a2e59de472bac031433213f06aa (diff)
downloadcoredns-dd537b163ddf63eae428da346e4fa12c2266c0e7.tar.gz
coredns-dd537b163ddf63eae428da346e4fa12c2266c0e7.tar.zst
coredns-dd537b163ddf63eae428da346e4fa12c2266c0e7.zip
Document log replacements
Rename latency to duration.
-rw-r--r--middleware/log/README.md21
-rw-r--r--middleware/replacer.go5
2 files changed, 24 insertions, 2 deletions
diff --git a/middleware/log/README.md b/middleware/log/README.md
index ca601d3ef..2e5cd6d41 100644
--- a/middleware/log/README.md
+++ b/middleware/log/README.md
@@ -33,7 +33,26 @@ CoreDNS will create it before appending to it.
## 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
diff --git a/middleware/replacer.go b/middleware/replacer.go
index 9d242fdb9..6a5d48b27 100644
--- a/middleware/replacer.go
+++ b/middleware/replacer.go
@@ -1,6 +1,7 @@
package middleware
import (
+ "fmt"
"strconv"
"strings"
"time"
@@ -54,13 +55,15 @@ func NewReplacer(r *dns.Msg, rr *ResponseRecorder, emptyValue string) Replacer {
}
rep.replacements["{rcode}"] = rcode
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)
// TODO(miek): syntax for flags and document it
rep.replacements[headerReplacer+"id}"] = strconv.Itoa(int(r.Id))
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
}