Fix missing support for setting document id in decoder_json pr…#15859
Fix missing support for setting document id in decoder_json pr…#15859urso merged 3 commits intoelastic:masterfrom
Conversation
Update processors, output, and json parser to store the document ID in `@metadata._id`. This ensures better compatibility with Logstash inputs/filters setting `@metadata._id`. Also add missing `document_id` to decode_json_fields processor, given users the chance to set the document id if the JSON document was embedded in another JSON document.
| if e.Meta == nil { | ||
| e.Meta = common.MapStr{} | ||
| } | ||
| e.Meta["id"] = id |
There was a problem hiding this comment.
Given the special nature of this field name and the desire to keep it consistent in multiple places, do you think we should make it an exported const?
There was a problem hiding this comment.
We have more than one field that is special to meta. Let's clean these up (the other fields as well) in a follow up PR.
|
Should we add a CHANGELOG entry, maybe especially since it's technically a breaking change? |
Oops, Addded changelog. |
|
beats-ci failure due to timeouts downloading dependencies. All related tests passed on Travis. Merging. |
…tic#15859) * Change to metadata._id Update processors, output, and json parser to store the document ID in `@metadata._id`. This ensures better compatibility with Logstash inputs/filters setting `@metadata._id`. Also add missing `document_id` to decode_json_fields processor, given users the chance to set the document id if the JSON document was embedded in another JSON document. (cherry picked from commit d60b04a)
…tic#15859) * Change to metadata._id Update processors, output, and json parser to store the document ID in `@metadata._id`. This ensures better compatibility with Logstash inputs/filters setting `@metadata._id`. Also add missing `document_id` to decode_json_fields processor, given users the chance to set the document id if the JSON document was embedded in another JSON document. (cherry picked from commit d60b04a)
* Change to metadata._id Update processors, output, and json parser to store the document ID in `@metadata._id`. This ensures better compatibility with Logstash inputs/filters setting `@metadata._id`. Also add missing `document_id` to decode_json_fields processor, given users the chance to set the document id if the JSON document was embedded in another JSON document. (cherry picked from commit d60b04a)
* Change to metadata._id Update processors, output, and json parser to store the document ID in `@metadata._id`. This ensures better compatibility with Logstash inputs/filters setting `@metadata._id`. Also add missing `document_id` to decode_json_fields processor, given users the chance to set the document id if the JSON document was embedded in another JSON document. (cherry picked from commit d60b04a)
|
Testing turned up an oversight in this PR: |
In elastic#15859 the Elasticsearch output was changed to read from the @metadata._id field when it had been using @metadata.id. The s3 and googlepubsub inputs had both been setting @metadata.id, but were not updated with that change. This updates the s3 and googlepubsub inputs to use `beat.Event#SetID()` rather than creating the metadata object themselves.
In #15859 the Elasticsearch output was changed to read from the @metadata._id field when it had been using @metadata.id. The s3 and googlepubsub inputs had both been setting @metadata.id, but were not updated with that change. This updates the s3 and googlepubsub inputs to use `beat.Event#SetID()` rather than creating the metadata object themselves.
In elastic#15859 the Elasticsearch output was changed to read from the @metadata._id field when it had been using @metadata.id. The s3 and googlepubsub inputs had both been setting @metadata.id, but were not updated with that change. This updates the s3 and googlepubsub inputs to use `beat.Event#SetID()` rather than creating the metadata object themselves. (cherry picked from commit 304eca4)
In #15859 the Elasticsearch output was changed to read from the @metadata._id field when it had been using @metadata.id. The s3 and googlepubsub inputs had both been setting @metadata.id, but were not updated with that change. This updates the s3 and googlepubsub inputs to use `beat.Event#SetID()` rather than creating the metadata object themselves. (cherry picked from commit 304eca4)
What does this PR do?
Update processors, output, and json parser to store the document ID in
@metadata._id.Also add missing
document_idto decode_json_fields processor, givenusers the chance to set the document id if the JSON document was
embedded in another JSON document.
Why is it important?
@metadata._id.About the breaking change: The
document_idsetting on the JSON decoder has been introduced in 7.5, but overall effort on supporting event duplication was only finalized in 7.6. This means that the to@metadata._idis a breaking change. But the feature wasn't much documented, while actual documentation on how to configure beats + ES for data duplication is planned for 7.6.Checklist
Author's Checklist
How to test this PR locally
{"myid": "id1", "log": "..."}-d 'publish'and check that@metadata._idis set when inspecting events to be published in the logs. Themyidshould be removed from the event._idmatches the original contents ofmyid.Related issues