-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Filebeat] Update CoreDNS pipelines for ECS DNS (#13505)
This sets the ECS DNS fields. It does not remove the coredns.* fields to avoid introducing a breaking change. * Convert coredns ingest pipeline to YAML * Update pipelines for ECS DNS * Right trim trailing dots in dns.question.name Relates #13320
- Loading branch information
1 parent
38d29f2
commit 8f2216e
Showing
10 changed files
with
216 additions
and
177 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
101 changes: 0 additions & 101 deletions
101
x-pack/filebeat/module/coredns/log/ingest/pipeline-entry.json
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
x-pack/filebeat/module/coredns/log/ingest/pipeline-entry.yml
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,113 @@ | ||
--- | ||
description: Pipeline for normalizing Kubernetes CoreDNS logs. | ||
processors: | ||
- 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}}" | ||
if: ctx.source?.address != null | ||
- 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: | ||
if: ctx.dns?.id != null | ||
field: coredns.id | ||
value: '{{dns.id}}' | ||
- set: | ||
if: ctx.dns?.question?.class != null | ||
field: coredns.query.class | ||
value: '{{dns.question.class}}' | ||
- set: | ||
if: ctx.dns?.question?.name != null | ||
field: coredns.query.name | ||
value: '{{dns.question.name}}' | ||
- set: | ||
if: ctx.dns?.question?.type != null | ||
field: coredns.query.type | ||
value: '{{dns.question.type}}' | ||
- set: | ||
if: ctx.dns?.response_code != null | ||
field: coredns.response.code | ||
value: '{{dns.response_code}}' | ||
- 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); | ||
} | ||
on_failure: | ||
- set: | ||
field: error.message | ||
value: "{{ _ingest.on_failure_message }}" |
49 changes: 0 additions & 49 deletions
49
x-pack/filebeat/module/coredns/log/ingest/pipeline-json.json
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
x-pack/filebeat/module/coredns/log/ingest/pipeline-json.yml
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,32 @@ | ||
--- | ||
description: Pipeline for dissecting CoreDNS JSON logs. | ||
processors: | ||
- rename: | ||
field: message | ||
target_field: event.original | ||
ignore_failure: true | ||
- json: | ||
field: event.original | ||
target_field: json | ||
- dissect: | ||
field: json.message | ||
pattern: '%{timestamp} [%{log.level}] %{temp.source} - %{dns.id} "%{dns.question.type} | ||
%{dns.question.class} %{dns.question.name} %{network.transport} %{coredns.query.size} | ||
%{coredns.dnssec_ok} %{?bufsize}" %{dns.response_code} %{dns.header_flags} | ||
%{coredns.response.size} %{coredns.duration}s' | ||
- rename: | ||
field: json.message | ||
target_field: message | ||
ignore_failure: true | ||
- rename: | ||
field: json.kubernetes | ||
target_field: kubernetes | ||
ignore_failure: true | ||
- remove: | ||
field: | ||
- json | ||
ignore_failure: true | ||
on_failure: | ||
- set: | ||
field: error.message | ||
value: "{{ _ingest.on_failure_message }}" |
23 changes: 0 additions & 23 deletions
23
x-pack/filebeat/module/coredns/log/ingest/pipeline-plaintext.json
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
x-pack/filebeat/module/coredns/log/ingest/pipeline-plaintext.yml
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,13 @@ | ||
--- | ||
description: Pipeline for dissecting CoreDNS plaintext logs. | ||
processors: | ||
- dissect: | ||
field: message | ||
pattern: '%{timestamp} [%{log.level}] %{temp.source} - %{dns.id} "%{dns.question.type} | ||
%{dns.question.class} %{dns.question.name} %{network.transport} %{coredns.query.size} | ||
%{coredns.dnssec_ok} %{?bufsize}" %{dns.response_code} %{dns.header_flags} | ||
%{coredns.response.size} %{coredns.duration}s' | ||
on_failure: | ||
- set: | ||
field: error.message | ||
value: "{{ _ingest.on_failure_message }}" |
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
Oops, something went wrong.