Skip to content

Commit a0be287

Browse files
committed
feat: add vector configuration
1 parent 3c9acde commit a0be287

File tree

2 files changed

+116
-3
lines changed

2 files changed

+116
-3
lines changed

config/agent/dnsdist-config.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ query_rules:
4040
type: DnstapLog
4141
identity: dnsdist_v2
4242
logger_name: remote_logging
43+
- name: "log all queries to vector"
44+
selector:
45+
type: All
46+
action:
47+
type: DnstapLog
48+
identity: dnsdist_v2
49+
logger_name: vector_remote_logging
4350

4451
- name: "default rule"
4552
selector:
@@ -56,6 +63,13 @@ response_rules:
5663
type: DnstapLog
5764
identity: dnsdist_v2
5865
logger_name: remote_logging
66+
- name: log all responses to vector
67+
selector:
68+
type: All
69+
action:
70+
type: DnstapLog
71+
identity: dnsdist_v2
72+
logger_name: vector_remote_logging
5973

6074
cache_hit_response_rules:
6175
- name: log all responses from cache
@@ -64,4 +78,11 @@ cache_hit_response_rules:
6478
action:
6579
type: DnstapLog
6680
identity: dnsdist_v2_cache
67-
logger_name: remote_logging
81+
logger_name: remote_logging
82+
- name: log all responses from cache to vector
83+
selector:
84+
type: All
85+
action:
86+
type: DnstapLog
87+
identity: dnsdist_v2_cache
88+
logger_name: vector_remote_logging

config/agent/vector-config.yaml

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,105 @@
1+
data_dir: /var/lib/vector
2+
3+
api:
4+
enabled: false
5+
16
sources:
27
dnstap_tcp:
38
type: dnstap
49
address: 0.0.0.0:6001
510
mode: tcp
11+
internal_metrics:
12+
type: internal_metrics
13+
14+
transforms:
15+
dnstap_enriched:
16+
type: remap
17+
inputs:
18+
- dnstap_tcp
19+
source: |
20+
.message_type = to_string(.messageType) ?? to_string(.message_type) ?? "unknown"
21+
.proto = to_string(.socketProtocol) ?? to_string(.protocol) ?? "unknown"
22+
.family = to_string(.socketFamily) ?? to_string(.network_family) ?? "unknown"
23+
.opcode = to_string(.requestData.header.opcode) ?? to_string(.responseData.header.opcode) ?? to_string(.opcode) ?? "unknown"
24+
.rcode = to_string(.responseData.rcodeName) ?? to_string(.response_code) ?? to_string(.responseData.header.rcode) ?? "unknown"
25+
.server_id = to_string(.serverId) ?? "unknown"
26+
.qname = to_string(.question[0].domainName) ?? to_string(.query_name) ?? "unknown"
27+
.qtype = to_string(.question[0].questionType) ?? to_string(.question[0].questionTypeId) ?? to_string(.query_type) ?? "unknown"
28+
.hit = 1
29+
if exists(.requestData.time) && exists(.time) {
30+
req, err_req = to_int(.requestData.time)
31+
resp, err_resp = to_int(.time)
32+
if !is_null(err_req) { req = null }
33+
if !is_null(err_resp) { resp = null }
34+
if is_integer(req) && is_integer(resp) {
35+
diff = to_int!(resp) - to_int!(req)
36+
if diff >= 0 {
37+
.latency_ns = diff
38+
.latency_seconds = to_float(.latency_ns) / 1000000000.0
39+
}
40+
}
41+
}
42+
43+
dnstap_metrics:
44+
type: log_to_metric
45+
inputs:
46+
- dnstap_enriched
47+
metrics:
48+
- type: counter
49+
name: dns_queries_total
50+
field: hit
51+
condition: '.message_type == "ClientQuery"'
52+
tags:
53+
family: "{{family}}"
54+
proto: "{{proto}}"
55+
opcode: "{{opcode}}"
56+
qtype: "{{qtype}}"
57+
- type: counter
58+
name: dns_responses_total
59+
field: hit
60+
condition: '.message_type == "ClientResponse"'
61+
tags:
62+
family: "{{family}}"
63+
proto: "{{proto}}"
64+
rcode: "{{rcode}}"
65+
server: "{{server_id}}"
66+
- type: counter
67+
name: dns_nxdomain_total
68+
field: hit
69+
condition: '.message_type == "ClientResponse" && .rcode == "NXDomain"'
70+
tags:
71+
proto: "{{proto}}"
72+
server: "{{server_id}}"
73+
- type: counter
74+
name: dns_servfail_total
75+
field: hit
76+
condition: '.message_type == "ClientResponse" && .rcode == "ServFail"'
77+
tags:
78+
proto: "{{proto}}"
79+
server: "{{server_id}}"
80+
- type: histogram
81+
name: dns_response_latency_seconds
82+
field: latency_seconds
83+
condition: '.message_type == "ClientResponse" && exists(.latency_seconds)'
84+
bins: [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2, 5]
85+
tags:
86+
proto: "{{proto}}"
87+
qtype: "{{qtype}}"
88+
rcode: "{{rcode}}"
89+
server: "{{server_id}}"
690

791
sinks:
892
console:
993
type: console
94+
target: stdout
95+
encoding:
96+
codec: json
1097
inputs:
1198
- dnstap_tcp
12-
encoding:
13-
codec: json
99+
100+
prometheus:
101+
type: prometheus_exporter
102+
inputs:
103+
- dnstap_metrics
104+
- internal_metrics
105+
address: 0.0.0.0:9598

0 commit comments

Comments
 (0)