-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new jinja format settings in console and logfile (#856)
* Update docs * add new jinja format settings in console and logfile * update README.md
- Loading branch information
Showing
16 changed files
with
458 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
global: | ||
trace: | ||
verbose: true | ||
|
||
pipelines: | ||
- name: tap | ||
dnstap: | ||
listen-ip: 0.0.0.0 | ||
listen-port: 6000 | ||
transforms: | ||
normalize: | ||
qname-lowercase: true | ||
qname-replace-nonprintable: true | ||
routing-policy: | ||
forward: [ console ] | ||
dropped: [ ] | ||
|
||
- name: console | ||
stdout: | ||
mode: jinja | ||
jinja-format: |+ | ||
;; Got {% if dm.DNS.Type == "QUERY" %}query{% else %}answer{% endif %} from {{ dm.NetworkInfo.QueryIP }}#{{ dm.NetworkInfo.QueryPort }}: | ||
;; ->>HEADER<<- opcode: {{ dm.DNS.Opcode }}, status: {{ dm.DNS.Rcode }}, id: {{ dm.DNS.ID }} | ||
;; flags: {{ dm.DNS.Flags.QR | yesno:"qr ," }}{{ dm.DNS.Flags.RD | yesno:"rd ," }}{{ dm.DNS.Flags.RA | yesno:"ra ," }}; QUERY: {{ dm.DNS.QdCount }}, ANSWER: {{ dm.DNS.AnCount }}, AUTHORITY: {{ dm.DNS.NsCount }}, ADDITIONAL: {{ dm.DNS.ArCount }} | ||
;; QUESTION SECTION: | ||
;{{ dm.DNS.Qname }} {{ dm.DNS.Qclass }} {{ dm.DNS.Qtype }} | ||
;; ANSWER SECTION: {% for rr in dm.DNS.DNSRRs.Answers %} | ||
{{ rr.Name }} {{ rr.TTL }} {{ rr.Class }} {{ rr.Rdatatype }} {{ rr.Rdata }}{% endfor %} | ||
;; WHEN: {{ dm.DNSTap.Timestamp }} | ||
;; MSG SIZE rcvd: {{ dm.DNS.Length }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
global: | ||
trace: | ||
verbose: true | ||
|
||
pipelines: | ||
- name: tap | ||
dnstap: | ||
listen-ip: 0.0.0.0 | ||
listen-port: 6000 | ||
transforms: | ||
normalize: | ||
qname-lowercase: true | ||
qname-replace-nonprintable: true | ||
routing-policy: | ||
forward: [ console ] | ||
dropped: [ ] | ||
|
||
- name: console | ||
stdout: | ||
mode: text | ||
text-format: "timestamp-rfc3339ns identity version operation rcode queryip qname qtype ancount" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
global: | ||
trace: | ||
verbose: true | ||
|
||
pipelines: | ||
- name: tap | ||
dnstap: | ||
listen-ip: 0.0.0.0 | ||
listen-port: 6000 | ||
transforms: | ||
normalize: | ||
qname-lowercase: true | ||
qname-replace-nonprintable: true | ||
routing-policy: | ||
forward: [ console ] | ||
dropped: [ ] | ||
|
||
- name: console | ||
stdout: | ||
mode: flat-json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
global: | ||
trace: | ||
verbose: true | ||
|
||
pipelines: | ||
- name: tap | ||
dnstap: | ||
listen-ip: 0.0.0.0 | ||
listen-port: 6000 | ||
transforms: | ||
normalize: | ||
qname-lowercase: true | ||
qname-replace-nonprintable: true | ||
routing-policy: | ||
forward: [ console ] | ||
dropped: [ ] | ||
|
||
- name: console | ||
stdout: | ||
mode: text | ||
text-format: "timestamp-rfc3339ns identity version operation rcode queryip qname qtype ancount" | ||
text-format-delimiter: ";" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# DNS-collector - Advanced configuration Guide | ||
|
||
- [Configuration checks](#configuration-checks) | ||
- [Global settings](#global-settings) | ||
- [Trace](#trace) | ||
- [Server identity](#server-identity) | ||
- [Pid file](#pid-file) | ||
- [Telemetry](#telemetry) | ||
- [Configuration reloading](#configuration-reloading) | ||
|
||
## Configuration checks | ||
|
||
DNS-collector also supports a dry-run mode for configuration verification. Run the following command to check your setup: | ||
|
||
```bash | ||
./go-dnscollector -config config.yml -test-config | ||
INFO: 2023/12/24 14:43:29.043730 main - config OK! | ||
``` | ||
|
||
## Global settings | ||
|
||
### Trace | ||
|
||
Enable logging to capture detailed information, such as debug and error messages generated by the application. | ||
|
||
**Options** | ||
|
||
- `verbose`: (boolean) debug informations, if turned on, log some applications messages | ||
- `filename`: (string) filename is the file to write logs to. | ||
- `max-size`: (integer) maximum size in megabytes of the log file it gets rotated | ||
- `max-backups`: (integer) maximum number of old log files to retain | ||
- `log-malformed`: (boolean) log malformed packet | ||
|
||
**Example Configuration** | ||
|
||
```yaml | ||
global: | ||
trace: | ||
verbose: true | ||
log-malformed: false | ||
filename: "" | ||
max-size: 10 | ||
max-backups: 10 | ||
``` | ||
**Sample Log Output** | ||
```bash | ||
INFO: 2022/06/25 20:54:18.173239 main - version 0.0.0 | ||
INFO: 2022/06/25 20:54:18.173271 main - config loaded... | ||
INFO: 2022/06/25 20:54:18.173277 main - starting dns-collector... | ||
.... | ||
INFO: 2022/06/25 20:54:18.174256 [dtap] dnstap collector - running in background... | ||
INFO: 2022/06/25 20:54:18.174286 [dtap] dnstap collector - is listening on [::]:6000 | ||
``` | ||
### Server Identity | ||
Set the server identity name. If this field is left empty, the hostname will be used as the identity. | ||
**Example Configuration** | ||
```yaml | ||
global: | ||
server-identity: "dns-collector" | ||
``` | ||
### Worker Settings | ||
The `interval-monitor` in second(s) is used to count every XX second the number of in/out packets. | ||
|
||
The `buffer-size` settings enable to adjust the size of the buffer before discard additional packets. If you encounter the warning message buffer is full, xxx packet(s) dropped, consider increasing this parameter to prevent message drops. | ||
|
||
**Example Configuration** | ||
|
||
```yaml | ||
global: | ||
worker: | ||
interval-monitor: 10 | ||
buffer-size: 8192 | ||
``` | ||
|
||
### PID file | ||
|
||
Specify the path for the DNS-Collector PID file. By default, this setting is empty. | ||
|
||
**Example Configuration** | ||
|
||
```yaml | ||
global: | ||
pid-file: "/path/to/your/pidfile.pid" | ||
``` | ||
|
||
### Telemetry | ||
|
||
Enable and configure telemetry for monitoring purposes. | ||
|
||
**Example Configuration** | ||
|
||
```yaml | ||
global: | ||
telemetry: | ||
enabled: false | ||
web-path: "/metrics" | ||
web-listen: ":9165" | ||
prometheus-prefix: "dnscollector_exporter" | ||
tls-support: false | ||
tls-cert-file: "" | ||
tls-key-file: "" | ||
client-ca-file: "" | ||
basic-auth-enable: false | ||
basic-auth-login: admin | ||
basic-auth-pwd: changeme | ||
``` | ||
|
||
|
||
## Configuration reloading | ||
|
||
DNS-collector automatically reloads its configuration upon receiving a SIGHUP signal, allowing you to update settings without restarting the service. | ||
|
||
To trigger a reload, send the SIGHUP signal: | ||
|
||
``` | ||
$ sudo pkill -HUP dnscollector | ||
``` | ||
|
||
Expected output: | ||
|
||
``` | ||
WARNING: 2024/10/28 18:37:05.046321 main - SIGHUP received | ||
INFO: 2024/10/28 18:37:05.049529 worker - [tap] dnstap - reload configuration... | ||
INFO: 2024/10/28 18:37:05.050071 worker - [tofile] file - reload configuration... | ||
INFO: 2024/10/28 18:37:05.050132 worker - [tofile] file - running in mode: json | ||
INFO: 2024/10/28 18:37:05.050765 worker - [prom] prometheus - reload configuration... | ||
INFO: 2024/10/28 18:37:05.051304 worker - [console] stdout - reload configuration... | ||
``` |
Oops, something went wrong.