[filebeat] Fix ingest pipeline overwriting module field values#33236
[filebeat] Fix ingest pipeline overwriting module field values#33236crespocarlos merged 5 commits intoelastic:mainfrom
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
|
Did you see a way to avoid doing this? Not sure but I'm guessing if we drop support we can't consider this a minor change. |
Yeah. This makes sense. Better address that in another ticket. |
5c5d933 to
157e00b
Compare
1c28d16 to
d567fd1
Compare
| {{ end }} | ||
| exclude_files: [".gz$"] | ||
|
|
||
| json.keys_under_root: false |
There was a problem hiding this comment.
When this is set to true, Filebeat overwrites all fields correctly, but it also replaces the log entry @timestamp with Filebeat's. And that would make the ingested data inconsistent
…tting existing log entry field values
87b5e20 to
3028b52
Compare
| inline: 'ctx.json.keySet().each (key -> ctx[key] = ctx.json.get(key))' | ||
| - remove: | ||
| field: json | ||
| - rename: |
There was a problem hiding this comment.
Consistent with integration packages. These lines are responsible for making this fix work:
add_to_root: true
add_to_root_conflict_strategy: merge
There was a problem hiding this comment.
LGTM, will approve after some exploratory testing.
I was wondering if maybe there's a way to override the configuration used in testing so we could inject some override fields. This would help protect against future regression. But if there's nothing we can easily use, I think it'd be beyond the scope of this PR to add it.
matschaffer
left a comment
There was a problem hiding this comment.
Cool. I was able to see the new fields. I was intuitively expecting the fields to override things originally found in the logs, but it doesn't look like that's what's being asked for in the original issue.
That is possible using |
* Fix ingest pipeline, allowing field value override * Fix ecs and non-ecs pipelines * Fix pipeline description * Revert all changes on pipeline.yml * Allow only adding fields to the output; revert possibility of overwritting existing log entry field values (cherry picked from commit 4b4bfc4)
* Fix ingest pipeline, allowing field value override * Fix ecs and non-ecs pipelines * Fix pipeline description * Revert all changes on pipeline.yml * Allow only adding fields to the output; revert possibility of overwritting existing log entry field values (cherry picked from commit 4b4bfc4)
… (#33256) * Fix ingest pipeline, allowing field value override * Fix ecs and non-ecs pipelines * Fix pipeline description * Revert all changes on pipeline.yml * Allow only adding fields to the output; revert possibility of overwritting existing log entry field values (cherry picked from commit 4b4bfc4) Co-authored-by: Carlos Crespo <crespocarlos@users.noreply.github.com>
… (#33255) * Fix ingest pipeline, allowing field value override * Fix ecs and non-ecs pipelines * Fix pipeline description * Revert all changes on pipeline.yml * Allow only adding fields to the output; revert possibility of overwritting existing log entry field values (cherry picked from commit 4b4bfc4) Co-authored-by: Carlos Crespo <crespocarlos@users.noreply.github.com>
* Fix ingest pipeline, allowing field value override * Fix ecs and non-ecs pipelines * Fix pipeline description * Revert all changes on pipeline.yml * Allow only adding fields to the output; revert possibility of overwritting existing log entry field values
What does this PR do?
This PR fixes a problem with the ingest pipeline not fully considering the fields included in the module configuration.
Notes
According to Filebeat doc, users can add new fields to the output, but doesn't mention anything about overwriting log entry's existing field values
Checklist
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.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
kibana.ymlPull 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.Note that if
fields_under_rootis omitted orfalse, these custom fields will appear on the log asfields.ecs.version,fields.kibana.serviceand etc. Whentrue, besides being included in the root, they can overwrite existing log entry fields.cloud.availability_zoneandservice.namewill be added to the ingested log,service.*won't be overwritten byservice.nameandecs.versionandlog.levelwill remain with their original valueRelated issues
Closes #32665