-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Filebeat] Update CoreDNS pipelines for ECS DNS #13505
Merged
andrewkroh
merged 3 commits into
elastic:master
from
andrewkroh:feature/coredns-ecs-conversion
Sep 11, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the
registered_domain
processor, to setdns.question.registered_domain
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will take some refactoring because all of the processing is happening in Ingest Node with this pipeline. To use the Beat's
registered_domain
I'll need to move some of the dissecting to Beats.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, with all the YAML, I hadn't actually noticed that this was an ingest pipeline :-)
Let's call this out of scope for now, then?