-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
pipeline-entry.yml
144 lines (144 loc) · 4.05 KB
/
pipeline-entry.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
description: Pipeline for normalizing Kubernetes CoreDNS logs.
processors:
- set:
field: event.ingested
value: '{{_ingest.timestamp}}'
- pipeline:
if: ctx.message.charAt(0) == (char)("{")
name: '{< IngestPipeline "pipeline-json" >}'
- pipeline:
if: ctx.message.charAt(0) != (char)("{")
name: '{< IngestPipeline "pipeline-plaintext" >}'
- script:
lang: painless
source: >
ctx.event.created = ctx['@timestamp'];
ctx['@timestamp'] = ctx['timestamp'];
ctx.remove('timestamp');
ignore_failure: true
- script:
lang: painless
if: ctx.temp?.source != null
source: >
ctx['source'] = new HashMap();
if (ctx.temp.source.charAt(0) == (char)("[")) {
def p = ctx.temp.source.indexOf (']');
def l = ctx.temp.source.length();
ctx.source.address = ctx.temp.source.substring(1, p);
ctx.source.port = ctx.temp.source.substring(p+2, l);
} else {
def p = ctx.temp.source.indexOf(':');
def l = ctx.temp.source.length();
ctx.source.address = ctx.temp.source.substring(0, p);
ctx.source.port = ctx.temp.source.substring(p+1, l);
}
ctx.remove('temp');
- set:
field: source.ip
value: "{{source.address}}"
ignore_empty_value: true
- convert:
field: source.port
type: integer
- convert:
field: coredns.duration
type: double
- convert:
field: coredns.query.size
type: long
- convert:
field: coredns.response.size
type: long
- convert:
field: coredns.dnssec_ok
type: boolean
- uppercase:
field: dns.header_flags
- split:
field: dns.header_flags
separator: ","
- append:
if: ctx.coredns?.dnssec_ok
field: dns.header_flags
value: DO
- script:
lang: painless
source: ctx.event.duration = Math.round(ctx.coredns.duration * params.scale);
params:
scale: 1000000000
if: ctx.coredns?.duration != null
- remove:
field:
- coredns.duration
ignore_missing: true
# The following copies values from dns namespace (ECS) to the coredns
# namespace to avoid introducing breaking change. This should be removed
# for 8.0.0. Additionally coredns.dnssec_ok can be removed.
- set:
field: coredns.id
value: '{{dns.id}}'
ignore_empty_value: true
- set:
field: coredns.query.class
value: '{{dns.question.class}}'
ignore_empty_value: true
- set:
field: coredns.query.name
value: '{{dns.question.name}}'
ignore_empty_value: true
- set:
field: coredns.query.type
value: '{{dns.question.type}}'
ignore_empty_value: true
- set:
field: coredns.response.code
value: '{{dns.response_code}}'
ignore_empty_value: true
- script:
if: ctx.dns?.header_flags != null
lang: painless
source: >
ctx.coredns.response.flags = ctx.dns.header_flags;
# Right trim the trailing dot from domain names.
- script:
if: ctx.dns?.question?.name != null
lang: painless
source: >
def q = ctx.dns.question.name;
def end = q.length() - 1;
if (q.charAt(end) == (char) '.') {
ctx.dns.question.name = q.substring(0, end);
}
- set:
field: event.kind
value: event
- append:
field: event.category
value: network
- append:
field: event.type
value: protocol
- set:
field: event.outcome
value: success
if: "ctx?.dns?.response_code == 'NOERROR'"
- set:
field: event.outcome
value: failure
if: "ctx?.dns?.response_code != null && ctx.dns.response_code != 'NOERROR'"
- set:
field: network.protocol
value: dns
- append:
field: related.ip
value: "{{source.ip}}"
if: "ctx?.source?.ip != null"
- append:
field: related.ip
value: "{{destination.ip}}"
if: "ctx?.destination?.ip != null"
on_failure:
- set:
field: error.message
value: "{{ _ingest.on_failure_message }}"