-
Notifications
You must be signed in to change notification settings - Fork 306
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 use_metadata option for index, id, and pipeline #1041
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -251,6 +251,9 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base | |||||||||||||||||
# ILM policy to use, if undefined the default policy will be used. | ||||||||||||||||||
config :ilm_policy, :validate => :string, :default => DEFAULT_POLICY | ||||||||||||||||||
|
||||||||||||||||||
# ILM policy to use, if undefined the default policy will be used. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✂️ the comment does not make sense - seems to have been copy pasted |
||||||||||||||||||
config :use_metadata, :validate => :boolean, :default => false | ||||||||||||||||||
|
||||||||||||||||||
attr_reader :client | ||||||||||||||||||
attr_reader :default_index | ||||||||||||||||||
attr_reader :default_ilm_rollover_alias | ||||||||||||||||||
|
@@ -428,6 +431,14 @@ def common_event_params(event) | |||||||||||||||||
params[:pipeline] = value unless value.empty? | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
if @use_metadata | ||||||||||||||||||
params[:_id] = event.get("[@metadata][_id]") || params[:_id] | ||||||||||||||||||
event_index = event.get("[@metadata][_index]") | ||||||||||||||||||
params[:_index] = event.sprintf(event_index) if event_index && !event_index.empty? | ||||||||||||||||||
event_pipeline = event.get("[@metadata][pipeline]") | ||||||||||||||||||
params[:pipeline] = event.sprintf(event_pipeline) if event_pipeline && !event_pipeline.empty? | ||||||||||||||||||
Comment on lines
+436
to
+439
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specs don't have any coverage for sprintf-ing the value in
Suggested change
|
||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
params | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
|
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.
It looks like
_id
has a trailing underscore:I think we should use the Logstash field reference notation for these, instead of the Elasticsearch dot-notation: