-
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 ingest pipeline overwriting module field values #33236
[filebeat] Fix ingest pipeline overwriting module field values #33236
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
@@ -5,10 +5,20 @@ paths: | |||
{{ end }} | |||
exclude_files: [".gz$"] | |||
|
|||
json.keys_under_root: false |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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 <[email protected]>
… (#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 <[email protected]>
* 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.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.Note that if
fields_under_root
is omitted orfalse
, these custom fields will appear on the log asfields.ecs.version
,fields.kibana.service
and etc. Whentrue
, besides being included in the root, they can overwrite existing log entry fields.cloud.availability_zone
andservice.name
will be added to the ingested log,service.*
won't be overwritten byservice.name
andecs.version
andlog.level
will remain with their original valueRelated issues
Closes #32665