-
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] Fix conditions to decode_json_fields and which pipeline to run #35268
[Filebeat] Fix conditions to decode_json_fields and which pipeline to run #35268
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
@@ -8,7 +8,11 @@ exclude_files: [".gz$"] | |||
processors: | |||
# non-ECS: same as json.keys_under_root: false, allows compatibility with non-ecs logs. | |||
- decode_json_fields: | |||
when: |
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.
Ensure this only runs if it's a json log
/test |
90d437e
to
73431e0
Compare
73431e0
to
fa8a313
Compare
It seems that we don't set the |
Thanks for catching this. I've managed to fix it and also updated the description with all scenarios that this change covers. |
- script: | ||
lang: painless | ||
if: 'ctx.json != null' | ||
description: Merges filebeat generated fields with ECS log content | ||
source: |- | ||
ctx.json.keySet().each(key -> ctx.merge(key, ctx.json.get(key), (oldValue, newValue) -> { | ||
if (newValue instanceof Map) { | ||
newValue.putAll(oldValue); | ||
} | ||
|
||
return newValue; | ||
})) |
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.
This way, the pipeline can properly merge the ECS log content with some fields the Filebeat adds by default (e.g log.offset
)
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.
@crespocarlos walked me through the change offline, looks great thanks!
… run (#35268) (#35331) * Fix conditions to decode_json_fields and which pipeline to run * Fix pipeline condition * Propery merge ingest log content (cherry picked from commit 3ee25d0) Co-authored-by: Carlos Crespo <[email protected]>
… run (#35268) (#35332) * Fix conditions to decode_json_fields and which pipeline to run * Fix pipeline condition * Propery merge ingest log content (cherry picked from commit 3ee25d0) Co-authored-by: Carlos Crespo <[email protected]>
… run (#35268) * Fix conditions to decode_json_fields and which pipeline to run * Fix pipeline condition * Propery merge ingest log content
What does this PR do?
This PR fixes a problem with the ingest pipeline failing to use the correct ingest pipeline when
json.keys_under_root
is set totrue
Why is it important?
The Kibana logs on ECS deployments constantly show
field [json] doesn't exist
message inerror.message
field. That happens because cloud deployments automatically setjson.keys_under_root
totrue
for versions > 8.0.0 and the pipeline didn't properly cover such scenario after this changeChecklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature worksI have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
kibana.yml
Pull this branch and start filebeat from the source https://github.com/elastic/kibana/blob/main/x-pack/plugins/monitoring/dev_docs/how_to/running_components_from_source.md#filebeat
filebeat.yml
, enable Kibana module.The ingest pipeline has to properly override the original log content when there are custom field values on
filebeat.yml
input.fields
settings. Therefore, these test scenarios have to work as following :fields_under_root: true
andjson.fields_under_root: true
->input.fields
override original log contentfields_under_root: true
andjson.fields_under_root: false
->input.fields
override original log contentfields_under_root: false
andjson.fields_under_root: true
->input.fields
override original log contentfields_under_root: false
andjson.fields_under_root: false
->input.fields
override original log contentinput
object altogether -> original log content is keptThe fact that
json.fields_under_root
istrue
, shouldn't causeerror.message
field to be present.Related issues
closes #34210