Query Log Export¶
Prometheus metrics answer how much and how healthy. Forensics and
compliance ask a different question — "what did this client get at 14:07?" —
and only a per-query record answers it. dns.queryLogExport writes one JSON
object per sampled query to a file, stdout, or syslog.
dns:
queryLogExport:
enabled: true
destination: /var/log/gslbd/queries.jsonl
sampleRate: 0.01 # 1% of queries
redactClientIp: true # default
bufferSize: 4096 # default
This is separate from dns.queryLog, which emits a human-readable log line per
response for watching a live server. One is for your eyes, the other for a log
pipeline.
Fields¶
{"ts":"2026-08-09T14:07:11.482913Z","qname":"www.example.com.","qtype":"A",
"client":"203.0.113.0/24","rcode":"NOERROR","answers":["192.0.2.10"],
"proto":"udp","duration_us":412,"tenant":"default","node":"lon-01"}
| Field | Meaning |
|---|---|
ts |
RFC 3339 timestamp, UTC, nanosecond precision |
qname / qtype |
The question, with the queried name's case preserved |
client |
Client address, bucketed unless redaction is off (see below) |
rcode |
Response code (NOERROR, NXDOMAIN, …) |
answers |
A/AAAA addresses and CNAME targets returned; absent when empty |
proto |
udp or tcp — DoT and DoH both report tcp |
duration_us |
Handler time in microseconds |
tenant |
Tenant the query billed to, when a service matched |
node |
The node that answered, for stitching logs from a cluster |
Configuration¶
| Field | Default | Notes |
|---|---|---|
enabled |
false |
Off unless set. |
destination |
stdout |
stdout, stderr, syslog, or an absolute path. |
sampleRate |
1.0 |
Fraction of queries logged, 0–1. Unset (0) means log everything — to log nothing, set enabled: false. |
redactClientIp |
true |
Bucket the client address to /24 (IPv4) or /48 (IPv6). |
bufferSize |
4096 |
Pending entries held before dropping. |
Settings are validated at load: a sample rate outside 0–1, a negative buffer, or a destination that is neither a keyword nor an absolute path is rejected rather than silently ignored.
Client-address redaction¶
Addresses are bucketed by default — /24 for IPv4, /48 for IPv6, matching the aggregation RUM already uses. That is coarse enough not to single out a household and fine enough to investigate an incident.
Turning redaction off writes full client addresses to disk. "Per-query logs for
compliance" and "a file full of personal data" are easy to confuse, so treat
redactClientIp: false as a decision with a data-protection consequence, not a
verbosity setting.
The log never slows down DNS¶
Entries go onto a buffered channel and are written by a separate goroutine. When the buffer is full — slow disk, stalled syslog, a burst beyond what the destination can absorb — entries are dropped, never queued into the query path. A degraded log is an acceptable outcome; a DNS server blocked on a log write is not.
Drops are counted in gslbd_query_log_dropped_total and summarised in a warning
at shutdown. If that counter climbs, lower sampleRate or move the destination
to faster storage — do not raise bufferSize and expect the problem to go away,
since a bigger buffer only delays the same outcome.
Sampling¶
At sampleRate: 0.01 roughly one query in a hundred is logged, chosen
independently per query. There is no per-client stickiness: sampling is for
volume control, not for following one client end to end. If you need every query
for a specific investigation, raise the rate for the duration and put it back
afterwards — the setting is reloadable, so this costs no downtime.
Rotation¶
Reloading (systemctl reload gslbd, i.e. SIGHUP) reopens the destination, so
logrotate works with an ordinary postrotate hook:
/var/log/gslbd/queries.jsonl {
daily
rotate 14
compress
missingok
postrotate
systemctl reload gslbd
endscript
}
The reload also applies any change to the block — sample rate, destination, redaction — without restarting the daemon or dropping a query.
Shipping elsewhere (Kafka, S3, a SIEM)¶
There is no Kafka producer built in, deliberately. A JSON-lines file or a syslog
stream is already the input format every log shipper expects, so vector,
fluent-bit, filebeat or rsyslog will forward this to Kafka, S3,
Elasticsearch or a SIEM with a few lines of their own config — and they handle
the retries, batching, backpressure and disk buffering that a built-in producer
would have to reimplement badly.
Per-query records are also deliberately not written to the database. One row per query would multiply the cluster's write load for data whose natural home is a log pipeline with its own retention.