14
14
# .Compatibility Note
15
15
# [NOTE]
16
16
# ================================================================================
17
- # Starting with Elasticsearch 5.3, there's an {ref}modules-http.html[HTTP setting]
18
- # called `http.content_type.required`. If this option is set to `true`, and you
19
- # are using Logstash 2.4 through 5.2, you need to update the Elasticsearch output
20
- # plugin to version 6.2.5 or higher.
21
- #
22
- # ================================================================================
23
17
#
24
18
# This plugin is the recommended method of storing logs in Elasticsearch.
25
19
# If you plan on using the Kibana web interface, you'll want to use this output.
26
20
#
27
- # This output only speaks the HTTP protocol. HTTP is the preferred protocol for interacting with Elasticsearch as of Logstash 2.0.
28
- # We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
29
- # yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
30
- # to upgrade Logstash in lock-step.
21
+ # This output only speaks the HTTP protocol.
31
22
#
32
23
# You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
33
24
#
34
- # ==== Template management for Elasticsearch 5.x
35
- # Index template for this version (Logstash 5.0) has been changed to reflect Elasticsearch's mapping changes in version 5.0.
36
- # Most importantly, the subfield for string multi-fields has changed from `.raw` to `.keyword` to match ES default
37
- # behavior.
38
- #
39
- # ** Users installing ES 5.x and LS 5.x **
40
- # This change will not affect you and you will continue to use the ES defaults.
41
- #
42
- # ** Users upgrading from LS 2.x to LS 5.x with ES 5.x **
43
- # LS will not force upgrade the template, if `logstash` template already exists. This means you will still use
44
- # `.raw` for sub-fields coming from 2.x. If you choose to use the new template, you will have to reindex your data after
45
- # the new template is installed.
46
- #
47
25
# ==== Retry Policy
48
26
#
49
- # The retry policy has changed significantly in the 2.2.0 release.
50
27
# This plugin uses the Elasticsearch bulk API to optimize its imports into Elasticsearch. These requests may experience
51
28
# either partial or total failures.
52
29
#
@@ -129,8 +106,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
129
106
# - delete: deletes a document by id (An id is required for this action)
130
107
# - create: indexes a document, fails if a document by that id already exists in the index.
131
108
# - update: updates a document by id. Update has a special case where you can upsert -- update a
132
- # document if not already present. See the `upsert` option. NOTE: This does not work and is not supported
133
- # in Elasticsearch 1.x. Please upgrade to ES 2.x or greater to use this feature with Logstash!
109
+ # document if not already present. See the `upsert` option.
134
110
# - A sprintf style string to change the action based on the content of the event. The value `%{[foo]}`
135
111
# would use the foo field for the action
136
112
#
@@ -148,7 +124,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
148
124
149
125
config :document_type ,
150
126
:validate => :string ,
151
- :deprecated => "Document types are being deprecated in Elasticsearch 6 .0, and removed entirely in 7 .0. You should avoid this feature"
127
+ :deprecated => "Document types were deprecated in Elasticsearch 7 .0, and no longer configurable since 8 .0. You should avoid this feature. "
152
128
153
129
# From Logstash 1.3 onwards, a template is applied to Elasticsearch during
154
130
# Logstash's startup if one with the name `template_name` does not already exist.
@@ -483,7 +459,7 @@ def event_action_tuple(event)
483
459
join_value = event . get ( @join_field )
484
460
parent_value = event . sprintf ( @parent )
485
461
event . set ( @join_field , { "name" => join_value , "parent" => parent_value } )
486
- params [ routing_field_name ] = event . sprintf ( @parent )
462
+ params [ :routing ] = event . sprintf ( @parent )
487
463
else
488
464
params [ :parent ] = event . sprintf ( @parent )
489
465
end
@@ -495,7 +471,7 @@ def event_action_tuple(event)
495
471
if action == 'update'
496
472
params [ :_upsert ] = LogStash ::Json . load ( event . sprintf ( @upsert ) ) if @upsert != ""
497
473
params [ :_script ] = event . sprintf ( @script ) if @script != ""
498
- params [ retry_on_conflict_action_name ] = @retry_on_conflict
474
+ params [ :retry_on_conflict ] = @retry_on_conflict
499
475
end
500
476
501
477
event_control = event . get ( "[@metadata][_ingest_document]" )
@@ -552,7 +528,7 @@ def common_event_params(event)
552
528
params = {
553
529
:_id => resolve_document_id ( event , event_id ) ,
554
530
:_index => resolve_index! ( event , event_index ) ,
555
- routing_field_name => resolve_routing ( event , event_routing )
531
+ :routing => resolve_routing ( event , event_routing )
556
532
}
557
533
558
534
target_pipeline = resolve_pipeline ( event , event_pipeline )
@@ -615,16 +591,7 @@ def resolve_pipeline(event, event_pipeline)
615
591
require "logstash/outputs/elasticsearch/#{ name } "
616
592
end
617
593
618
- def retry_on_conflict_action_name
619
- maximum_seen_major_version >= 7 ? :retry_on_conflict : :_retry_on_conflict
620
- end
621
-
622
- def routing_field_name
623
- :routing
624
- end
625
-
626
594
# Determine the correct value for the 'type' field for the given event
627
- DEFAULT_EVENT_TYPE_ES6 = "doc" . freeze
628
595
DEFAULT_EVENT_TYPE_ES7 = "_doc" . freeze
629
596
630
597
def get_event_type ( event )
@@ -633,9 +600,7 @@ def get_event_type(event)
633
600
event . sprintf ( @document_type )
634
601
else
635
602
major_version = maximum_seen_major_version
636
- if major_version == 6
637
- DEFAULT_EVENT_TYPE_ES6
638
- elsif major_version == 7
603
+ if major_version == 7
639
604
DEFAULT_EVENT_TYPE_ES7
640
605
else
641
606
nil
@@ -653,9 +618,9 @@ def get_event_type(event)
653
618
# @param noop_required_client [nil]: required `nil` for legacy reasons.
654
619
# @return [Boolean]
655
620
def use_event_type? ( noop_required_client )
656
- # always set type for ES 6
657
- # for ES 7 only set it if the user defined it
658
- ( maximum_seen_major_version < 7 ) || ( maximum_seen_major_version == 7 && @document_type )
621
+ # never use event type unless
622
+ # ES is 7.x and the user defined it
623
+ maximum_seen_major_version == 7 && @document_type
659
624
end
660
625
661
626
def install_template
0 commit comments