-
Notifications
You must be signed in to change notification settings - Fork 84
Add a target field support. #196
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
Conversation
…e if set result is placed into the target.
event.set(new_key, value_to_set) | ||
else | ||
event_target = event.get(@target) || {} | ||
@logger.debug("Overwriting existing target field", field: @target, existing_value: event_target) if @logger.debug? && event.include?(@target) |
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.
Because we do a field-oriented mapping and invoke this once for each top-level field in the result (with a set of the values of that field across all returned documents), a fields
mapping of N
entries will emit this debug message at least N-1
times (e.g., 1st field sets target, subsequent fields encounter already-set target), even if the target was empty when the filter received the event.
…pplies setting to target with aggregations similarly with es-input. Co-authored-by: Rye Biesemeyer <ry.biesemeyer@elastic.co>
2e9e643
to
7342069
Compare
@@ -84,7 +84,9 @@ | |||
end | |||
|
|||
it "fails to register plugin" do | |||
expect { plugin.register }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized | |||
expect { plugin.register }.to raise_error elastic_ruby_v8_client_available? ? |
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.
review note: no any logic related with this but this fixes one integration test failure.
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've left a couple of nitpicks, but this looks sensible.
We may want to also link back to target
in each of the affected fields (and improve their docs while we're at it), something like:
diff --git a/docs/index.asciidoc b/docs/index.asciidoc
index b5a6eff..f86be0c 100644
--- a/docs/index.asciidoc
+++ b/docs/index.asciidoc
@@ -176,8 +176,11 @@ filter plugins.
* Value type is <<hash,hash>>
* Default value is `{}`
+ * format: `+"aggregation_name" => "[path][on][event]"+`:
+ ** `aggregation_name`: aggregation name in result from {es}
+ ** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
-Hash of aggregation names to copy from elasticsearch response into Logstash event fields
+A mapping of aggregations to copy into the <<plugins-{type}s-{plugin}-target>> of the current event.
Example:
[source,ruby]
@@ -247,8 +250,11 @@ These custom headers will override any headers previously set by the plugin such
* Value type is <<hash,hash>>
* Default value is `{}`
+ * format: `+"path.in.source" => "[path][on][event]"+`:
+ ** `path.in.source`: field path in document source of result from {es}, using dot-notation
+ ** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
-Hash of docinfo fields to copy from old event (found via elasticsearch) into new event
+A mapping of docinfo (`_source`) fields to copy into the <<plugins-{type}s-{plugin}-target>> of the current event.
Example:
[source,ruby]
@@ -274,9 +280,11 @@ Whether results should be sorted or not
* Value type is <<array,array>>
* Default value is `{}`
+ * format: `+"path.in.result" => "[path][on][event]"+`:
+ ** `path.in.result`: field path in indexed result from {es}, using dot-notation
+ ** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
-An array of fields to copy from the old event (found via elasticsearch) into the
-new event, currently being processed.
+A mapping of indexed fields to copy into the <<plugins-{type}s-{plugin}-target>> of the current event.
In the following example, the values of `@timestamp` and `event_id` on the event
found via elasticsearch are copied to the current event's
Documentation suggestions. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
…ocs info fields are placed in target field.
Applied with commit. The additional changes I made:
I will be merging on 🟢 CI and iterate with separate changes if required. |
* Introduces a target field as a field reference (mixin validated) where if set result is placed into the target. * Simplifies the set extracted values to the event with target logic. Applies setting to target with aggregations similarly with es-input. * Mention to target in each fields which can be placed in the target. Docs info fields are placed in target field. --------- Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit 5abbe49)
* Introduces a target field as a field reference (mixin validated) where if set result is placed into the target. * Simplifies the set extracted values to the event with target logic. Applies setting to target with aggregations similarly with es-input. * Mention to target in each fields which can be placed in the target. Docs info fields are placed in target field. --------- (cherry picked from commit 5abbe49) Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
Introduces a target field as a field reference (mixin validated) where if set result is placed into the target.
Test logs