logstash-output-elasticsearch 10.4.2-java → 10.6.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -2
  3. data/docs/index.asciidoc +92 -48
  4. data/lib/logstash/outputs/elasticsearch.rb +42 -1
  5. data/lib/logstash/outputs/elasticsearch/common.rb +36 -18
  6. data/lib/logstash/outputs/elasticsearch/common_configs.rb +3 -3
  7. data/lib/logstash/outputs/elasticsearch/http_client_builder.rb +11 -1
  8. data/lib/logstash/outputs/elasticsearch/ilm.rb +1 -1
  9. data/lib/logstash/outputs/elasticsearch/template_manager.rb +12 -9
  10. data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es2x.json → templates/ecs-disabled/elasticsearch-2x.json} +0 -0
  11. data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es5x.json → templates/ecs-disabled/elasticsearch-5x.json} +0 -0
  12. data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es6x.json → templates/ecs-disabled/elasticsearch-6x.json} +0 -0
  13. data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es7x.json → templates/ecs-disabled/elasticsearch-7x.json} +0 -0
  14. data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es8x.json → templates/ecs-disabled/elasticsearch-8x.json} +0 -0
  15. data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-6x.json +2950 -0
  16. data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-7x.json +2948 -0
  17. data/logstash-output-elasticsearch.gemspec +2 -1
  18. data/spec/integration/outputs/ilm_spec.rb +2 -2
  19. data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +9 -3
  20. data/spec/unit/outputs/elasticsearch_spec.rb +86 -2
  21. data/spec/unit/outputs/error_whitelist_spec.rb +1 -1
  22. metadata +23 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f27a5838e3f5abb53fb561802f1fa6f88e25b43f252951f6a2e8a1a8402d11a
4
- data.tar.gz: d77d44f5f208793751f7e026a47806523158f490fd0872f739aea9102acae7a5
3
+ metadata.gz: c2b97b57f05641257d4d82abf2ffc924252385a2376e80ed760bef849d5d2699
4
+ data.tar.gz: e4fd909cb0fbe096ff54abc0f77c013e601c7a4c01e3ba3bc72a7e121739a80e
5
5
  SHA512:
6
- metadata.gz: a64c0b9981fb551cba3a566a6c519d99579b5827128c3320ea77cd9c47932a54f0bcfcba9f94ca57c8570e428f8efde54f1e94d5351ec21ce91a95bf70999bce
7
- data.tar.gz: dd082458727f7b7bfaa8273606e12b131efe6fbd035f25f881d118e59e15fa0d556db1f4675baede6955827b89a1f127d05e16a86d11bf2f97b39861a68df945
6
+ metadata.gz: a17060e61a967293beda8046c0bc03d8583049509f0434c07c6024873b166a6cc2a011a6fa6293daee18f7fef6b6ca5f562e37c61f3150684ac88e58a397384b
7
+ data.tar.gz: f9f660a1b5d5eecb4a80dcafbd52872b34b4491a3d3b62e57d3710961c771488368960ec1662c5c2503de1ce2da45fc2b39f0900f407ed8f304b28539c291c26
@@ -1,5 +1,18 @@
1
- ## 10.4.2
2
- - Changed cloud id, credential and host setup to happen in `build_client` [#939](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/939)
1
+ ## 10.6.2
2
+ - [DOC] Added clarifying info on http compression settings and behaviors [#943](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/943)
3
+ - [DOC] Fixed entry for ilm_policy default value[#956](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/956)
4
+
5
+ ## 10.6.1
6
+ - Fixed an issue introduced in 10.6.0 that broke Logstash Core's monitoring feature when this plugin is run in Logstash 7.7-7.8. [#953](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/953)
7
+
8
+ ## 10.6.0
9
+ - Added `ecs_compatiblity` mode, for managing ECS-compatable templates [#952](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/952)
10
+
11
+ ## 10.5.1
12
+ - [DOC] Removed outdated compatibility notices, reworked cloud notice, and fixed formatting for `hosts` examples [#938](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/938)
13
+
14
+ ## 10.5.0
15
+ - Added api_key support [#934](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/934)
3
16
 
4
17
  ## 10.4.1
5
18
  - [DOC] Added note about `_type` setting change from `doc` to `_doc` [#884](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/884)
@@ -21,6 +21,21 @@ include::{include_path}/plugin_header.asciidoc[]
21
21
 
22
22
  ==== Description
23
23
 
24
+ If you plan to use the Kibana web interface to analyze data transformed by
25
+ Logstash, use the Elasticsearch output plugin to get your data into
26
+ Elasticsearch.
27
+
28
+ This output only speaks the HTTP protocol as it is the preferred protocol for
29
+ interacting with Elasticsearch. In previous versions it was possible to
30
+ communicate with Elasticsearch through the transport protocol, which is now
31
+ reserved for internal cluster communication between nodes
32
+ https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-transport.html[communication between nodes].
33
+ Using the https://www.elastic.co/guide/en/elasticsearch/reference/current/java-clients.html[transport protocol]
34
+ to communicate with the cluster has been deprecated in Elasticsearch 7.0.0 and
35
+ will be removed in 8.0.0
36
+
37
+ You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
38
+
24
39
  .Compatibility Note
25
40
  [NOTE]
26
41
  ================================================================================
@@ -36,47 +51,26 @@ ensure your template uses the `_doc` document-type before
36
51
  connecting to Elasticsearch 7.x.
37
52
  ================================================================================
38
53
 
39
- .Compatibility Note
40
- [NOTE]
41
- ================================================================================
42
- Starting with Elasticsearch 5.3, there's an {ref}/modules-http.html[HTTP setting]
43
- called `http.content_type.required`. If this option is set to `true`, and you
44
- are using Logstash 2.4 through 5.2, you need to update the Elasticsearch output
45
- plugin to version 6.2.5 or higher.
54
+ ===== Hosted {es} Service on Elastic Cloud
46
55
 
47
- ================================================================================
48
-
49
- If you plan to use the Kibana web
50
- interface, use the Elasticsearch output plugin to get your log data into
51
- Elasticsearch.
52
-
53
- TIP: You can run Elasticsearch on your own hardware, or use our
56
+ You can run Elasticsearch on your own hardware, or use our
54
57
  https://www.elastic.co/cloud/elasticsearch-service[hosted {es} Service] on
55
- Elastic Cloud. The Elasticsearch Service is available on both AWS and GCP.
56
- {ess-trial}[Try the {es} Service for free].
57
-
58
- This output only speaks the HTTP protocol. HTTP is the preferred protocol for interacting with Elasticsearch as of Logstash 2.0.
59
- We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
60
- yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
61
- to upgrade Logstash in lock-step.
62
-
63
- You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
64
-
65
- ==== Template management for Elasticsearch 5.x
66
-
67
- Index template for this version (Logstash 5.0) has been changed to reflect Elasticsearch's mapping changes in version 5.0.
68
- Most importantly, the subfield for string multi-fields has changed from `.raw` to `.keyword` to match ES default
69
- behavior.
58
+ Elastic Cloud. The Elasticsearch Service is available on AWS, Google Cloud
59
+ Platform, and Microsoft Azure. {ess-trial}[Try the {es} Service for free].
70
60
 
71
- **Users installing ES 5.x and LS 5.x**
61
+ ==== Compatibility with the Elastic Common Schema (ECS)
72
62
 
73
- This change will not affect you and you will continue to use the ES defaults.
63
+ This plugin will persist events to Elasticsearch in the shape produced by
64
+ your pipeline, and _cannot_ be used to re-shape the event structure into a
65
+ shape that complies with ECS. To produce events that fully comply with ECS,
66
+ you will need to populate ECS-defined fields throughout your pipeline
67
+ definition.
74
68
 
75
- **Users upgrading from LS 2.x to LS 5.x with ES 5.x**
76
-
77
- LS will not force upgrade the template, if `logstash` template already exists. This means you will still use
78
- `.raw` for sub-fields coming from 2.x. If you choose to use the new template, you will have to reindex your data after
79
- the new template is installed.
69
+ However, the Elasticsearch Index Templates it manages can be configured to
70
+ be ECS-compatible by setting <<plugins-{type}s-{plugin}-ecs_compatibility>>.
71
+ By having an ECS-compatible template in place, we can ensure that Elasticsearch
72
+ is prepared to create and index fields in a way that is compatible with ECS,
73
+ and will correctly reject events with fields that conflict and cannot be coerced.
80
74
 
81
75
  ==== Writing to different indices: best practices
82
76
 
@@ -87,7 +81,7 @@ when using `ilm_rollover_alias`.
87
81
 
88
82
  ================================================================================
89
83
 
90
- If you're sending events to the same Elasticsearch cluster but you're targeting different indices you can:
84
+ If you're sending events to the same Elasticsearch cluster, but you're targeting different indices you can:
91
85
 
92
86
  * use different Elasticsearch outputs, each one with a different value for the `index` parameter
93
87
  * use one Elasticsearch output and use the dynamic variable substitution for the `index` parameter
@@ -224,14 +218,21 @@ not reevaluate its DNS value while the keepalive is in effect.
224
218
 
225
219
  ==== HTTP Compression
226
220
 
227
- This plugin supports request and response compression. Response compression is enabled by default and
228
- for Elasticsearch versions 5.0 and later, the user doesn't have to set any configs in Elasticsearch for
229
- it to send back compressed response. For versions before 5.0, `http.compression` must be set to `true` https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#modules-http[in
230
- Elasticsearch] to take advantage of response compression when using this plugin
221
+ This plugin supports request and response compression. Response compression is
222
+ enabled by default for HTTP and for Elasticsearch versions 5.0 and later.
223
+
224
+ You don't have to set any configs in Elasticsearch for it to send back a
225
+ compressed response. For versions before 5.0, or if HTTPS is enabled,
226
+ `http.compression` must be set to `true`
227
+ https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#modules-http[in
228
+ Elasticsearch] to take advantage of response compression when using this plugin.
229
+
230
+ For requests compression, regardless of the Elasticsearch version, enable the
231
+ `http_compression` setting in the Logstash config file.
231
232
 
232
- For requests compression, regardless of the Elasticsearch version, users have to enable `http_compression`
233
- setting in their Logstash config file.
233
+ ==== Authentication
234
234
 
235
+ Authentication to a secure Elasticsearch cluster is possible using one of the `user`/`password`, `cloud_auth` or `api_key` options.
235
236
 
236
237
  [id="plugins-{type}s-{plugin}-options"]
237
238
  ==== Elasticsearch Output Configuration Options
@@ -242,6 +243,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
242
243
  |=======================================================================
243
244
  |Setting |Input type|Required
244
245
  | <<plugins-{type}s-{plugin}-action>> |<<string,string>>|No
246
+ | <<plugins-{type}s-{plugin}-api_key>> |<<password,password>>|No
245
247
  | <<plugins-{type}s-{plugin}-bulk_path>> |<<string,string>>|No
246
248
  | <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
247
249
  | <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
@@ -250,6 +252,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
250
252
  | <<plugins-{type}s-{plugin}-doc_as_upsert>> |<<boolean,boolean>>|No
251
253
  | <<plugins-{type}s-{plugin}-document_id>> |<<string,string>>|No
252
254
  | <<plugins-{type}s-{plugin}-document_type>> |<<string,string>>|No
255
+ | <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
253
256
  | <<plugins-{type}s-{plugin}-failure_type_logging_whitelist>> |<<array,array>>|No
254
257
  | <<plugins-{type}s-{plugin}-healthcheck_path>> |<<string,string>>|No
255
258
  | <<plugins-{type}s-{plugin}-hosts>> |<<uri,uri>>|No
@@ -324,6 +327,16 @@ The Elasticsearch action to perform. Valid actions are:
324
327
 
325
328
  For more details on actions, check out the http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html[Elasticsearch bulk API documentation]
326
329
 
330
+ [id="plugins-{type}s-{plugin}-api_key"]
331
+ ===== `api_key`
332
+
333
+ * Value type is <<password,password>>
334
+ * There is no default value for this setting.
335
+
336
+ Authenticate using Elasticsearch API key. Note that this option also requires enabling the `ssl` option.
337
+
338
+ Format is `id:api_key` where `id` and `api_key` are as returned by the Elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key API].
339
+
327
340
  [id="plugins-{type}s-{plugin}-bulk_path"]
328
341
  ===== `bulk_path`
329
342
 
@@ -399,6 +412,25 @@ If you don't set a value for this option:
399
412
  - for elasticsearch clusters 6.x: the value of 'doc' will be used;
400
413
  - for elasticsearch clusters 5.x and below: the event's 'type' field will be used, if the field is not present the value of 'doc' will be used.
401
414
 
415
+ [id="plugins-{type}s-{plugin}-ecs_compatibility"]
416
+ ===== `ecs_compatibility`
417
+
418
+ * Value type is <<string,string>>
419
+ * Supported values are:
420
+ ** `disabled`: does not provide ECS-compatible templates
421
+ ** `v1`: provides defaults that are compatible with v1 of the Elastic Common Schema
422
+ * Default value depends on which version of Logstash is running:
423
+ ** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
424
+ ** Otherwise, the default value is `disabled`.
425
+
426
+ Controls this plugin's compatibility with the https://www.elastic.co/guide/en/ecs/current/index.html[Elastic Common Schema (ECS)],
427
+ including the installation of ECS-compatible index templates.
428
+ The value of this setting affects the _default_ values of:
429
+
430
+ * <<plugins-{type}s-{plugin}-index>>
431
+ * <<plugins-{type}s-{plugin}-template_name>>
432
+ * <<plugins-{type}s-{plugin}-ilm_rollover_alias>>
433
+
402
434
  [id="plugins-{type}s-{plugin}-failure_type_logging_whitelist"]
403
435
  ===== `failure_type_logging_whitelist`
404
436
 
@@ -439,11 +471,15 @@ If you have custom firewall rules you may need to change this
439
471
 
440
472
  Sets the host(s) of the remote instance. If given an array it will load balance requests across the hosts specified in the `hosts` parameter.
441
473
  Remember the `http` protocol uses the http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#modules-http[http] address (eg. 9200, not 9300).
474
+
475
+ Examples:
476
+
442
477
  `"127.0.0.1"`
443
478
  `["127.0.0.1:9200","127.0.0.2:9200"]`
444
479
  `["http://127.0.0.1"]`
445
480
  `["https://127.0.0.1:9200"]`
446
481
  `["https://127.0.0.1:9200/mypath"]` (If using a proxy on a subpath)
482
+
447
483
  It is important to exclude http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html[dedicated master nodes] from the `hosts` list
448
484
  to prevent LS from sending bulk requests to the master nodes. So this parameter should only reference either data or client nodes in Elasticsearch.
449
485
 
@@ -491,7 +527,7 @@ NOTE: The pattern must finish with a dash and a number that will be automaticall
491
527
  ===== `ilm_policy`
492
528
 
493
529
  * Value type is <<string,string>>
494
- * Default value is `logstash`
530
+ * Default value is `logstash-policy`
495
531
 
496
532
  Modify this setting to use a custom Index Lifecycle Management policy, rather than the default. If this value is not set, the default policy will
497
533
  be automatically installed into Elasticsearch
@@ -502,7 +538,9 @@ NOTE: If this setting is specified, the policy must already exist in Elasticsear
502
538
  ===== `ilm_rollover_alias`
503
539
 
504
540
  * Value type is <<string,string>>
505
- * Default value is `logstash`
541
+ * Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
542
+ ** ECS Compatibility disabled: `logstash`
543
+ ** ECS Compatibility enabled: `ecs-logstash`
506
544
 
507
545
  The rollover alias is the alias where indices managed using Index Lifecycle Management will be written to.
508
546
 
@@ -516,7 +554,9 @@ NOTE: `ilm_rollover_alias` does NOT support dynamic variable substitution as `in
516
554
  ===== `index`
517
555
 
518
556
  * Value type is <<string,string>>
519
- * Default value is `"logstash-%{+yyyy.MM.dd}"`
557
+ * Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
558
+ ** ECS Compatibility disabled: `"logstash-%{+yyyy.MM.dd}"`
559
+ ** ECS Compatibility enabled: `"ecs-logstash-%{+yyyy.MM.dd}"`
520
560
 
521
561
  The index to write events to. This can be dynamic using the `%{foo}` syntax.
522
562
  The default value will partition your indices by day so you can more easily
@@ -550,7 +590,8 @@ Set the keystore password
550
590
  * Default value is `true`
551
591
 
552
592
  From Logstash 1.3 onwards, a template is applied to Elasticsearch during
553
- Logstash's startup if one with the name `template_name` does not already exist.
593
+ Logstash's startup if one with the name <<plugins-{type}s-{plugin}-template_name>>
594
+ does not already exist.
554
595
  By default, the contents of this template is the default template for
555
596
  `logstash-%{+YYYY.MM.dd}` which always matches indices based on the pattern
556
597
  `logstash-*`. Should you require support for other index names, or would like
@@ -801,7 +842,10 @@ If not set, the included template will be used.
801
842
  ===== `template_name`
802
843
 
803
844
  * Value type is <<string,string>>
804
- * Default value is `"logstash"`
845
+ * Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
846
+ ** ECS Compatibility disabled: `logstash`
847
+ ** ECS Compatibility enabled: `ecs-logstash`
848
+
805
849
 
806
850
  This configuration option defines how the template is named inside Elasticsearch.
807
851
  Note that if you have used the template management features and subsequently
@@ -92,6 +92,8 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
92
92
  require "logstash/outputs/elasticsearch/common"
93
93
  require "logstash/outputs/elasticsearch/ilm"
94
94
 
95
+ require 'logstash/plugin_mixins/ecs_compatibility_support'
96
+
95
97
  # Protocol agnostic (i.e. non-http, non-java specific) configs go here
96
98
  include(LogStash::Outputs::ElasticSearch::CommonConfigs)
97
99
 
@@ -101,6 +103,9 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
101
103
  # Methods for ILM support
102
104
  include(LogStash::Outputs::ElasticSearch::Ilm)
103
105
 
106
+ # ecs_compatibility option, provided by Logstash core or the support adapter.
107
+ include(LogStash::PluginMixins::ECSCompatibilitySupport)
108
+
104
109
  config_name "elasticsearch"
105
110
 
106
111
  # The Elasticsearch action to perform. Valid actions are:
@@ -122,6 +127,10 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
122
127
  # Password to authenticate to a secure Elasticsearch cluster
123
128
  config :password, :validate => :password
124
129
 
130
+ # Authenticate using Elasticsearch API key.
131
+ # format is id:api_key (as returned by https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key])
132
+ config :api_key, :validate => :password
133
+
125
134
  # Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
126
135
  #
127
136
  # For more details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[cloud documentation]
@@ -238,6 +247,34 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
238
247
  # Custom Headers to send on each request to elasticsearch nodes
239
248
  config :custom_headers, :validate => :hash, :default => {}
240
249
 
250
+ def initialize(*params)
251
+ super
252
+ setup_ecs_compatibility_related_defaults
253
+ end
254
+
255
+ def setup_ecs_compatibility_related_defaults
256
+ case ecs_compatibility
257
+ when :disabled
258
+ @default_index = "logstash-%{+yyyy.MM.dd}"
259
+ @default_ilm_rollover_alias = "logstash"
260
+ @default_template_name = 'logstash'
261
+ when :v1
262
+ @default_index = "ecs-logstash-%{+yyyy.MM.dd}"
263
+ @default_ilm_rollover_alias = "ecs-logstash"
264
+ @default_template_name = 'ecs-logstash'
265
+ else
266
+ fail("unsupported ECS Compatibility `#{ecs_compatibility}`")
267
+ end
268
+
269
+ @index ||= default_index
270
+ @ilm_rollover_alias ||= default_ilm_rollover_alias
271
+ @template_name ||= default_template_name
272
+ end
273
+
274
+ attr_reader :default_index
275
+ attr_reader :default_ilm_rollover_alias
276
+ attr_reader :default_template_name
277
+
241
278
  # @override to handle proxy => '' as if none was set
242
279
  def config_init(params)
243
280
  proxy = params['proxy']
@@ -255,7 +292,11 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
255
292
  end
256
293
 
257
294
  def build_client
258
- fill_user_password_from_cloud_auth
295
+ # the following 3 options validation & setup methods are called inside build_client
296
+ # because they must be executed prior to building the client and logstash
297
+ # monitoring and management rely on directly calling build_client
298
+ # see https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/934#pullrequestreview-396203307
299
+ validate_authentication
259
300
  fill_hosts_from_cloud_id
260
301
  setup_hosts
261
302
 
@@ -20,7 +20,6 @@ module LogStash; module Outputs; class ElasticSearch;
20
20
  @stopping = Concurrent::AtomicBoolean.new(false)
21
21
  # To support BWC, we check if DLQ exists in core (< 5.4). If it doesn't, we use nil to resort to previous behavior.
22
22
  @dlq_writer = dlq_enabled? ? execution_context.dlq_writer : nil
23
-
24
23
  build_client
25
24
  setup_after_successful_connection
26
25
  check_action_validity
@@ -61,8 +60,15 @@ module LogStash; module Outputs; class ElasticSearch;
61
60
  !!maximum_seen_major_version
62
61
  end
63
62
 
64
- def use_event_type?(client)
65
- client.maximum_seen_major_version < 8
63
+ ##
64
+ # WARNING: This method is overridden in a subclass in Logstash Core 7.7-7.8's monitoring,
65
+ # where a `client` argument is both required and ignored. In later versions of
66
+ # Logstash Core it is optional and ignored, but to make it optional here would
67
+ # allow us to accidentally break compatibility with Logstashes where it was required.
68
+ # @param noop_required_client [nil]: required `nil` for legacy reasons.
69
+ # @return [Boolean]
70
+ def use_event_type?(noop_required_client)
71
+ maximum_seen_major_version < 8
66
72
  end
67
73
 
68
74
  # Convert the event into a 3-tuple of action, params, and event
@@ -75,7 +81,7 @@ module LogStash; module Outputs; class ElasticSearch;
75
81
  routing_field_name => @routing ? event.sprintf(@routing) : nil
76
82
  }
77
83
 
78
- params[:_type] = get_event_type(event) if use_event_type?(client)
84
+ params[:_type] = get_event_type(event) if use_event_type?(nil)
79
85
 
80
86
  if @pipeline
81
87
  params[:pipeline] = event.sprintf(@pipeline)
@@ -109,6 +115,28 @@ module LogStash; module Outputs; class ElasticSearch;
109
115
  [action, params, event]
110
116
  end
111
117
 
118
+ def validate_authentication
119
+ authn_options = 0
120
+ authn_options += 1 if @cloud_auth
121
+ authn_options += 1 if (@api_key && @api_key.value)
122
+ authn_options += 1 if (@user || (@password && @password.value))
123
+
124
+ if authn_options > 1
125
+ raise LogStash::ConfigurationError, 'Multiple authentication options are specified, please only use one of user/password, cloud_auth or api_key'
126
+ end
127
+
128
+ if @api_key && @api_key.value && @ssl != true
129
+ raise(LogStash::ConfigurationError, "Using api_key authentication requires SSL/TLS secured communication using the `ssl => true` option")
130
+ end
131
+
132
+ if @cloud_auth
133
+ @user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
134
+ # params is the plugin global params hash which will be passed to HttpClientBuilder.build
135
+ params['user'], params['password'] = @user, @password
136
+ end
137
+ end
138
+ private :validate_authentication
139
+
112
140
  def setup_hosts
113
141
  @hosts = Array(@hosts)
114
142
  if @hosts.empty?
@@ -132,16 +160,6 @@ module LogStash; module Outputs; class ElasticSearch;
132
160
  @hosts = parse_host_uri_from_cloud_id(@cloud_id)
133
161
  end
134
162
 
135
- def fill_user_password_from_cloud_auth
136
- return unless @cloud_auth
137
-
138
- if @user || @password
139
- raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
140
- end
141
- @user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
142
- params['user'], params['password'] = @user, @password
143
- end
144
-
145
163
  def parse_host_uri_from_cloud_id(cloud_id)
146
164
  begin # might not be available on older LS
147
165
  require 'logstash/util/cloud_setting_id'
@@ -336,11 +354,11 @@ module LogStash; module Outputs; class ElasticSearch;
336
354
  type = if @document_type
337
355
  event.sprintf(@document_type)
338
356
  else
339
- if client.maximum_seen_major_version < 6
357
+ if maximum_seen_major_version < 6
340
358
  event.get("type") || DEFAULT_EVENT_TYPE_ES6
341
- elsif client.maximum_seen_major_version == 6
359
+ elsif maximum_seen_major_version == 6
342
360
  DEFAULT_EVENT_TYPE_ES6
343
- elsif client.maximum_seen_major_version == 7
361
+ elsif maximum_seen_major_version == 7
344
362
  DEFAULT_EVENT_TYPE_ES7
345
363
  else
346
364
  nil
@@ -425,7 +443,7 @@ module LogStash; module Outputs; class ElasticSearch;
425
443
  end
426
444
 
427
445
  def default_index?(index)
428
- @index == LogStash::Outputs::ElasticSearch::CommonConfigs::DEFAULT_INDEX_NAME
446
+ @index == @default_index
429
447
  end
430
448
 
431
449
  def dlq_enabled?