-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add support for using expressions with formatString in JacksonEvent, use for index in OpenSearch sink #3032
Add support for using expressions with formatString in JacksonEvent, use for index in OpenSearch sink #3032
Conversation
…use for index in OpenSearch sink Signed-off-by: Taylor Gray <[email protected]>
document_id_field: "document_id" | ||
index: "copied-${index}" | ||
document_id_field: "getMetadata(\"opensearch-document_id\")" | ||
index: "${getMetadata(\"opensearch-index\"}" |
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.
WHat's the difference between index
and document_id_field
? Is ${}
required?
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.
document_id_field currently only supports a single field in the Event. It does not support formatting the document id like is done in index. We could add later potentially but right now document id either supports a field in the Event or it supports an expression
|
||
Object val; | ||
if (Objects.nonNull(expressionEvaluator) && expressionEvaluator.isValidExpressionStatement(name)) { | ||
val = expressionEvaluator.evaluate(name, this); |
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.
can val
here be null? If yes, the statement in line 342(below) will result in null pointer exception. Probably good idea to put null check in line 337 outside of if statement.
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.
if the result of the evaluate method is null, should be just have it be literal string "null"? Or should we just leave it out of the format string?
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.
I added a null check around the appending to the result
Signed-off-by: Taylor Gray <[email protected]>
…use for index in OpenSearch sink (#3032) Add support for using expressions with formatString in JacksonEvent, use for index in OpenSearch sink Signed-off-by: Taylor Gray <[email protected]> --------- Signed-off-by: Taylor Gray <[email protected]> Signed-off-by: George Chen <[email protected]>
Description
This change adds support for using Data Prepper expressions in the
formatString
method forJacksonEvent
, and uses this functionality for theindex
parameter in the OpenSearch sink. For example, the index can now bewhich will inject the value of
some_key
from the Event, and inject the result of the evaluatedsome_data_prepper_expression
Issues Resolved
Resolves #2864
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.