-
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
Deep merge event fields and metadata maps #17958
Deep merge event fields and metadata maps #17958
Conversation
Pinging @elastic/integrations-services (Team:Services) |
|
||
// We have accounted for @timestamp, @metadata, type above. So let's remove these keys and | ||
// deep update the event with the rest of the keys | ||
delete(keys, "@timestamp") |
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.
Nit: How about using a for
loop instead of calling delete
three times?
for _, name := range []string{"@timestamp", "@metadata", "type"} {
delete(keys, name)
}
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.
Addressed in 4f1ee99ec.
@@ -77,6 +77,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d | |||
- Do not rotate log files on startup when interval is configured and rotateonstartup is disabled. {pull}17613[17613] | |||
- Fix goroutine leak and Elasticsearch output file descriptor leak when output reloading is in use. {issue}10491[10491] {pull}17381[17381] | |||
- Fix `setup.dashboards.index` setting not working. {pull}17749[17749] | |||
- Arbitrary fields and metadata maps are now deep merged into event. {pull}17958[17958] |
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.
nit; this PR looks it is improving/fixing some issue with the JSON parser (most likely json decoder processor only). Reading this changelog makes me think it is a generic bug in 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.
Updated CHANGELOG in d27bb07.
d27bb07
to
cbb13b3
Compare
@@ -200,6 +200,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d | |||
- Add optional regex based cid extractor to `add_kubernetes_metadata` processor. {pull}17360[17360] | |||
- Add `urldecode` processor to for decoding URL-encoded fields. {pull}17505[17505] | |||
- Add support for AWS IAM `role_arn` in credentials config. {pull}17658[17658] {issue}12464[12464] | |||
- When using the `decode_json_fields` processor, decoded fields are now deep-merged into existing event. {pull}17958[17958] |
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.
How about: Change
decode_json_fields to merge parsed json objects with existing objects in the event instead of fully replacing them.
.
Would it make sense to treat this as a bug and add the changelog note to the bugfix section?
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.
Done in b7304af16.
cbb13b3
to
b7304af
Compare
@@ -275,6 +276,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d | |||
- Improve ECS categorization field mappings in postgresql module. {issue}16177[16177] {pull}17914[17914] | |||
- Improve ECS categorization field mappings in rabbitmq module. {issue}16178[16178] {pull}17916[17916] | |||
- Improve ECS categorization field mappings in redis module. {issue}16179[16179] {pull}17918[17918] | |||
- When using the `json.*` setting available on some inputs, decoded fields are now deep-merged into existing event. {pull}17958[17958] |
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.
let's adapt this changelog entry as well :)
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.
Done in 4b2cd165bc979fdaa7720f7d88d3a2ecd134d143.
4b2cd16
to
df10f8f
Compare
💔 Build FailedExpand to view the summary
Build stats
Test stats 🧪
Test errorsExpand to view the tests failures
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
df10f8f
to
2e10719
Compare
2e10719
to
2a9821b
Compare
Jenkins CI failures are unrelated and Travis CI is green. Merging. |
* Deep merge event fields and metadata maps (#17958) * Deep merge event fields and metadata maps * Add CHANGELOG entry * Use loop to remove keys; extract into function * Relocating CHANGELOG entry * Rewording and moving to bugfix section per review feedback * Adapting other CHANGELOG entry * Fix comparison in test * Fixing up CHANGELOG * Cleaning up CHANGELOG * Fixing up CHANGELOG * Fixing up CHANGELOG
* Deep merge event fields and metadata maps (#17958) * Deep merge event fields and metadata maps * Add CHANGELOG entry * Use loop to remove keys; extract into function * Relocating CHANGELOG entry * Rewording and moving to bugfix section per review feedback * Adapting other CHANGELOG entry * Fix comparison in test * Fixing up CHANGELOG * Fixing up CHANGELOG
…tic#18231) * Deep merge event fields and metadata maps (elastic#17958) * Deep merge event fields and metadata maps * Add CHANGELOG entry * Use loop to remove keys; extract into function * Relocating CHANGELOG entry * Rewording and moving to bugfix section per review feedback * Adapting other CHANGELOG entry * Fix comparison in test * Fixing up CHANGELOG * Cleaning up CHANGELOG * Fixing up CHANGELOG * Fixing up CHANGELOG
What does this PR do?
When merging an arbitrary map of metadata or fields into a
beat.Event
, we deep merge theevent.Meta
andevent.Fields
, respectively, while still respecting theoverrideKeys
boolean flag.Why is it important?
Before this PR were were shallow-merging
event.Meta
andevent.Fields
. As a result, when the Filebeatlog
input was creatinglog.offset
andlog.file.path
fields, if the the event already contained alog
field, the event'slog
field would take complete precedence. Instead, what we want is for the event'slog
field and Filebeat'slog
field to be deep merged, while respecting the override boolean setting.Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.