logstash-output-elasticsearch 10.4.0-java → 10.6.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/docs/index.asciidoc +90 -35
- data/lib/logstash/outputs/elasticsearch.rb +45 -0
- data/lib/logstash/outputs/elasticsearch/common.rb +29 -21
- data/lib/logstash/outputs/elasticsearch/common_configs.rb +3 -3
- data/lib/logstash/outputs/elasticsearch/http_client_builder.rb +11 -1
- data/lib/logstash/outputs/elasticsearch/ilm.rb +1 -1
- data/lib/logstash/outputs/elasticsearch/template_manager.rb +12 -9
- data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es2x.json → templates/ecs-disabled/elasticsearch-2x.json} +0 -0
- data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es5x.json → templates/ecs-disabled/elasticsearch-5x.json} +0 -0
- data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es6x.json → templates/ecs-disabled/elasticsearch-6x.json} +0 -0
- data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es7x.json → templates/ecs-disabled/elasticsearch-7x.json} +0 -0
- data/lib/logstash/outputs/elasticsearch/{elasticsearch-template-es8x.json → templates/ecs-disabled/elasticsearch-8x.json} +0 -0
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-6x.json +2950 -0
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-7x.json +2948 -0
- data/logstash-output-elasticsearch.gemspec +3 -1
- data/spec/integration/outputs/ilm_spec.rb +2 -2
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +9 -3
- data/spec/unit/outputs/elasticsearch_spec.rb +86 -2
- data/spec/unit/outputs/error_whitelist_spec.rb +1 -1
- metadata +23 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69cd4a7aaa5a5b66bc94d633f1e482f472a557a464f0077e1382fe3b8d8bf6a4
|
4
|
+
data.tar.gz: 3b08e4236f1ba8d580a4f35b528400a3c3a3e0b33123ca9e5d0b983cdb6a256d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5acda5b8b7a8654f0a8ffd9c99483f25eb7076184d018a76615e7d88861a45c898a6f1d20a80396791f8e6ec53746d716705ebde4db7d60b258b17941bb073b9
|
7
|
+
data.tar.gz: 9927d71a573cf5aee344d8d8e0f8c7808b4e98769a1a35ae83ac25186439326f9ffa9910c676aec567607da3b9cb8bb26570fb5dd662c1ca62f648288230acb5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 10.6.0
|
2
|
+
- Added `ecs_compatiblity` mode, for managing ECS-compatable templates [#952](https://github.com/logstash-plugins/logstash-output-elasticsearch/issue/952)
|
3
|
+
|
4
|
+
## 10.5.1
|
5
|
+
- [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)
|
6
|
+
|
7
|
+
## 10.5.0
|
8
|
+
- Added api_key support [#934](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/934)
|
9
|
+
|
10
|
+
## 10.4.1
|
11
|
+
- [DOC] Added note about `_type` setting change from `doc` to `_doc` [#884](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/884)
|
12
|
+
|
1
13
|
## 10.4.0
|
2
14
|
- Fixed default index value [#927](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/927)
|
3
15
|
|
data/docs/index.asciidoc
CHANGED
@@ -21,47 +21,56 @@ 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
|
================================================================================
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
42
|
+
When connected to Elasticsearch 7.x, modern versions of this plugin
|
43
|
+
use the required `_doc` document-type when inserting documents.
|
44
|
+
|
45
|
+
If you are using an earlier version of Logstash and wish to connect to
|
46
|
+
Elasticsearch 7.x, first upgrade Logstash to version 6.8 to ensure it
|
47
|
+
picks up changes to the Elasticsearch index template.
|
31
48
|
|
49
|
+
If you are using a custom <<plugins-{type}s-{plugin}-template>>,
|
50
|
+
ensure your template uses the `_doc` document-type before
|
51
|
+
connecting to Elasticsearch 7.x.
|
32
52
|
================================================================================
|
33
53
|
|
34
|
-
|
35
|
-
interface, use the Elasticsearch output plugin to get your log data into
|
36
|
-
Elasticsearch.
|
54
|
+
===== Hosted {es} Service on Elastic Cloud
|
37
55
|
|
38
|
-
|
56
|
+
You can run Elasticsearch on your own hardware, or use our
|
39
57
|
https://www.elastic.co/cloud/elasticsearch-service[hosted {es} Service] on
|
40
|
-
Elastic Cloud. The Elasticsearch Service is available on
|
41
|
-
{ess-trial}[Try the {es} Service for free].
|
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].
|
42
60
|
|
43
|
-
|
44
|
-
We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
|
45
|
-
yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
|
46
|
-
to upgrade Logstash in lock-step.
|
61
|
+
==== Compatibility with the Elastic Common Schema (ECS)
|
47
62
|
|
48
|
-
|
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.
|
49
68
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
**Users installing ES 5.x and LS 5.x**
|
57
|
-
|
58
|
-
This change will not affect you and you will continue to use the ES defaults.
|
59
|
-
|
60
|
-
**Users upgrading from LS 2.x to LS 5.x with ES 5.x**
|
61
|
-
|
62
|
-
LS will not force upgrade the template, if `logstash` template already exists. This means you will still use
|
63
|
-
`.raw` for sub-fields coming from 2.x. If you choose to use the new template, you will have to reindex your data after
|
64
|
-
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.
|
65
74
|
|
66
75
|
==== Writing to different indices: best practices
|
67
76
|
|
@@ -72,7 +81,7 @@ when using `ilm_rollover_alias`.
|
|
72
81
|
|
73
82
|
================================================================================
|
74
83
|
|
75
|
-
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:
|
76
85
|
|
77
86
|
* use different Elasticsearch outputs, each one with a different value for the `index` parameter
|
78
87
|
* use one Elasticsearch output and use the dynamic variable substitution for the `index` parameter
|
@@ -217,6 +226,9 @@ Elasticsearch] to take advantage of response compression when using this plugin
|
|
217
226
|
For requests compression, regardless of the Elasticsearch version, users have to enable `http_compression`
|
218
227
|
setting in their Logstash config file.
|
219
228
|
|
229
|
+
==== Authentication
|
230
|
+
|
231
|
+
Authentication to a secure Elasticsearch cluster is possible using one of the `user`/`password`, `cloud_auth` or `api_key` options.
|
220
232
|
|
221
233
|
[id="plugins-{type}s-{plugin}-options"]
|
222
234
|
==== Elasticsearch Output Configuration Options
|
@@ -227,6 +239,7 @@ This plugin supports the following configuration options plus the < |
|
227
239
|
|=======================================================================
|
228
240
|
|Setting |Input type|Required
|
229
241
|
| <<plugins-{type}s-{plugin}-action>> |<<string,string>>|No
|
242
|
+
| <<plugins-{type}s-{plugin}-api_key>> |<<password,password>>|No
|
230
243
|
| <<plugins-{type}s-{plugin}-bulk_path>> |<<string,string>>|No
|
231
244
|
| <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
|
232
245
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
@@ -235,6 +248,7 @@ This plugin supports the following configuration options plus the < |
|
235
248
|
| <<plugins-{type}s-{plugin}-doc_as_upsert>> |<<boolean,boolean>>|No
|
236
249
|
| <<plugins-{type}s-{plugin}-document_id>> |<<string,string>>|No
|
237
250
|
| <<plugins-{type}s-{plugin}-document_type>> |<<string,string>>|No
|
251
|
+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
238
252
|
| <<plugins-{type}s-{plugin}-failure_type_logging_whitelist>> |<<array,array>>|No
|
239
253
|
| <<plugins-{type}s-{plugin}-healthcheck_path>> |<<string,string>>|No
|
240
254
|
| <<plugins-{type}s-{plugin}-hosts>> |<<uri,uri>>|No
|
@@ -309,6 +323,16 @@ The Elasticsearch action to perform. Valid actions are:
|
|
309
323
|
|
310
324
|
For more details on actions, check out the http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html[Elasticsearch bulk API documentation]
|
311
325
|
|
326
|
+
[id="plugins-{type}s-{plugin}-api_key"]
|
327
|
+
===== `api_key`
|
328
|
+
|
329
|
+
* Value type is <<password,password>>
|
330
|
+
* There is no default value for this setting.
|
331
|
+
|
332
|
+
Authenticate using Elasticsearch API key. Note that this option also requires enabling the `ssl` option.
|
333
|
+
|
334
|
+
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].
|
335
|
+
|
312
336
|
[id="plugins-{type}s-{plugin}-bulk_path"]
|
313
337
|
===== `bulk_path`
|
314
338
|
|
@@ -384,6 +408,25 @@ If you don't set a value for this option:
|
|
384
408
|
- for elasticsearch clusters 6.x: the value of 'doc' will be used;
|
385
409
|
- 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.
|
386
410
|
|
411
|
+
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
|
412
|
+
===== `ecs_compatibility`
|
413
|
+
|
414
|
+
* Value type is <<string,string>>
|
415
|
+
* Supported values are:
|
416
|
+
** `disabled`: does not provide ECS-compatible templates
|
417
|
+
** `v1`: provides defaults that are compatible with v1 of the Elastic Common Schema
|
418
|
+
* Default value depends on which version of Logstash is running:
|
419
|
+
** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
|
420
|
+
** Otherwise, the default value is `disabled`.
|
421
|
+
|
422
|
+
Controls this plugin's compatibility with the {ecs-ref}}[Elastic Common Schema (ECS)],
|
423
|
+
including the installation of ECS-compatible index templates.
|
424
|
+
The value of this setting affects the _default_ values of:
|
425
|
+
|
426
|
+
* <<plugins-{type}s-{plugin}-index>>
|
427
|
+
* <<plugins-{type}s-{plugin}-template_name>>
|
428
|
+
* <<plugins-{type}s-{plugin}-ilm_rollover_alias>>
|
429
|
+
|
387
430
|
[id="plugins-{type}s-{plugin}-failure_type_logging_whitelist"]
|
388
431
|
===== `failure_type_logging_whitelist`
|
389
432
|
|
@@ -424,11 +467,15 @@ If you have custom firewall rules you may need to change this
|
|
424
467
|
|
425
468
|
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.
|
426
469
|
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).
|
470
|
+
|
471
|
+
Examples:
|
472
|
+
|
427
473
|
`"127.0.0.1"`
|
428
474
|
`["127.0.0.1:9200","127.0.0.2:9200"]`
|
429
475
|
`["http://127.0.0.1"]`
|
430
476
|
`["https://127.0.0.1:9200"]`
|
431
477
|
`["https://127.0.0.1:9200/mypath"]` (If using a proxy on a subpath)
|
478
|
+
|
432
479
|
It is important to exclude http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html[dedicated master nodes] from the `hosts` list
|
433
480
|
to prevent LS from sending bulk requests to the master nodes. So this parameter should only reference either data or client nodes in Elasticsearch.
|
434
481
|
|
@@ -487,7 +534,9 @@ NOTE: If this setting is specified, the policy must already exist in Elasticsear
|
|
487
534
|
===== `ilm_rollover_alias`
|
488
535
|
|
489
536
|
* Value type is <<string,string>>
|
490
|
-
* Default value is
|
537
|
+
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
|
538
|
+
** ECS Compatibility disabled: `logstash`
|
539
|
+
** ECS Compatibility enabled: `ecs-logstash`
|
491
540
|
|
492
541
|
The rollover alias is the alias where indices managed using Index Lifecycle Management will be written to.
|
493
542
|
|
@@ -501,7 +550,9 @@ NOTE: `ilm_rollover_alias` does NOT support dynamic variable substitution as `in
|
|
501
550
|
===== `index`
|
502
551
|
|
503
552
|
* Value type is <<string,string>>
|
504
|
-
* Default value
|
553
|
+
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
|
554
|
+
** ECS Compatibility disabled: `"logstash-%{+yyyy.MM.dd}"`
|
555
|
+
** ECS Compatibility enabled: `"ecs-logstash-%{+yyyy.MM.dd}"`
|
505
556
|
|
506
557
|
The index to write events to. This can be dynamic using the `%{foo}` syntax.
|
507
558
|
The default value will partition your indices by day so you can more easily
|
@@ -535,7 +586,8 @@ Set the keystore password
|
|
535
586
|
* Default value is `true`
|
536
587
|
|
537
588
|
From Logstash 1.3 onwards, a template is applied to Elasticsearch during
|
538
|
-
Logstash's startup if one with the name
|
589
|
+
Logstash's startup if one with the name <<plugins-{type}s-{plugin}-template_name>>
|
590
|
+
does not already exist.
|
539
591
|
By default, the contents of this template is the default template for
|
540
592
|
`logstash-%{+YYYY.MM.dd}` which always matches indices based on the pattern
|
541
593
|
`logstash-*`. Should you require support for other index names, or would like
|
@@ -786,7 +838,10 @@ If not set, the included template will be used.
|
|
786
838
|
===== `template_name`
|
787
839
|
|
788
840
|
* Value type is <<string,string>>
|
789
|
-
* Default value is
|
841
|
+
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
|
842
|
+
** ECS Compatibility disabled: `logstash`
|
843
|
+
** ECS Compatibility enabled: `ecs-logstash`
|
844
|
+
|
790
845
|
|
791
846
|
This configuration option defines how the template is named inside Elasticsearch.
|
792
847
|
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,6 +292,14 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
255
292
|
end
|
256
293
|
|
257
294
|
def build_client
|
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
|
300
|
+
fill_hosts_from_cloud_id
|
301
|
+
setup_hosts
|
302
|
+
|
258
303
|
params["metric"] = metric
|
259
304
|
if @proxy.eql?('')
|
260
305
|
@logger.warn "Supplied proxy setting (proxy => '') has no effect"
|
@@ -20,10 +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
|
-
fill_hosts_from_cloud_id
|
25
|
-
fill_user_password_from_cloud_auth
|
26
|
-
setup_hosts # properly sets @hosts
|
27
23
|
build_client
|
28
24
|
setup_after_successful_connection
|
29
25
|
check_action_validity
|
@@ -64,8 +60,8 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
64
60
|
!!maximum_seen_major_version
|
65
61
|
end
|
66
62
|
|
67
|
-
def use_event_type?
|
68
|
-
|
63
|
+
def use_event_type?
|
64
|
+
maximum_seen_major_version < 8
|
69
65
|
end
|
70
66
|
|
71
67
|
# Convert the event into a 3-tuple of action, params, and event
|
@@ -78,7 +74,7 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
78
74
|
routing_field_name => @routing ? event.sprintf(@routing) : nil
|
79
75
|
}
|
80
76
|
|
81
|
-
params[:_type] = get_event_type(event) if use_event_type?
|
77
|
+
params[:_type] = get_event_type(event) if use_event_type?
|
82
78
|
|
83
79
|
if @pipeline
|
84
80
|
params[:pipeline] = event.sprintf(@pipeline)
|
@@ -112,6 +108,28 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
112
108
|
[action, params, event]
|
113
109
|
end
|
114
110
|
|
111
|
+
def validate_authentication
|
112
|
+
authn_options = 0
|
113
|
+
authn_options += 1 if @cloud_auth
|
114
|
+
authn_options += 1 if (@api_key && @api_key.value)
|
115
|
+
authn_options += 1 if (@user || (@password && @password.value))
|
116
|
+
|
117
|
+
if authn_options > 1
|
118
|
+
raise LogStash::ConfigurationError, 'Multiple authentication options are specified, please only use one of user/password, cloud_auth or api_key'
|
119
|
+
end
|
120
|
+
|
121
|
+
if @api_key && @api_key.value && @ssl != true
|
122
|
+
raise(LogStash::ConfigurationError, "Using api_key authentication requires SSL/TLS secured communication using the `ssl => true` option")
|
123
|
+
end
|
124
|
+
|
125
|
+
if @cloud_auth
|
126
|
+
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
127
|
+
# params is the plugin global params hash which will be passed to HttpClientBuilder.build
|
128
|
+
params['user'], params['password'] = @user, @password
|
129
|
+
end
|
130
|
+
end
|
131
|
+
private :validate_authentication
|
132
|
+
|
115
133
|
def setup_hosts
|
116
134
|
@hosts = Array(@hosts)
|
117
135
|
if @hosts.empty?
|
@@ -135,16 +153,6 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
135
153
|
@hosts = parse_host_uri_from_cloud_id(@cloud_id)
|
136
154
|
end
|
137
155
|
|
138
|
-
def fill_user_password_from_cloud_auth
|
139
|
-
return unless @cloud_auth
|
140
|
-
|
141
|
-
if @user || @password
|
142
|
-
raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
|
143
|
-
end
|
144
|
-
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
145
|
-
params['user'], params['password'] = @user, @password
|
146
|
-
end
|
147
|
-
|
148
156
|
def parse_host_uri_from_cloud_id(cloud_id)
|
149
157
|
begin # might not be available on older LS
|
150
158
|
require 'logstash/util/cloud_setting_id'
|
@@ -339,11 +347,11 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
339
347
|
type = if @document_type
|
340
348
|
event.sprintf(@document_type)
|
341
349
|
else
|
342
|
-
if
|
350
|
+
if maximum_seen_major_version < 6
|
343
351
|
event.get("type") || DEFAULT_EVENT_TYPE_ES6
|
344
|
-
elsif
|
352
|
+
elsif maximum_seen_major_version == 6
|
345
353
|
DEFAULT_EVENT_TYPE_ES6
|
346
|
-
elsif
|
354
|
+
elsif maximum_seen_major_version == 7
|
347
355
|
DEFAULT_EVENT_TYPE_ES7
|
348
356
|
else
|
349
357
|
nil
|
@@ -428,7 +436,7 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
428
436
|
end
|
429
437
|
|
430
438
|
def default_index?(index)
|
431
|
-
@index ==
|
439
|
+
@index == @default_index
|
432
440
|
end
|
433
441
|
|
434
442
|
def dlq_enabled?
|
@@ -17,7 +17,7 @@ module LogStash; module Outputs; class ElasticSearch
|
|
17
17
|
# For weekly indexes ISO 8601 format is recommended, eg. logstash-%{+xxxx.ww}.
|
18
18
|
# LS uses Joda to format the index pattern from event timestamp.
|
19
19
|
# Joda formats are defined http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[here].
|
20
|
-
mod.config :index, :validate => :string
|
20
|
+
mod.config :index, :validate => :string
|
21
21
|
|
22
22
|
mod.config :document_type,
|
23
23
|
:validate => :string,
|
@@ -44,7 +44,7 @@ module LogStash; module Outputs; class ElasticSearch
|
|
44
44
|
# `curl -XDELETE <http://localhost:9200/_template/OldTemplateName?pretty>`
|
45
45
|
#
|
46
46
|
# where `OldTemplateName` is whatever the former setting was.
|
47
|
-
mod.config :template_name, :validate => :string
|
47
|
+
mod.config :template_name, :validate => :string
|
48
48
|
|
49
49
|
# You can set the path to your own template here, if you so desire.
|
50
50
|
# If not set, the included template will be used.
|
@@ -153,7 +153,7 @@ module LogStash; module Outputs; class ElasticSearch
|
|
153
153
|
mod.config :ilm_enabled, :validate => [true, false, 'true', 'false', 'auto'], :default => 'auto'
|
154
154
|
|
155
155
|
# Rollover alias used for indexing data. If rollover alias doesn't exist, Logstash will create it and map it to the relevant index
|
156
|
-
mod.config :ilm_rollover_alias, :validate => :string
|
156
|
+
mod.config :ilm_rollover_alias, :validate => :string
|
157
157
|
|
158
158
|
# appends “{now/d}-000001” by default for new index creation, subsequent rollover indices will increment based on this pattern i.e. “000002”
|
159
159
|
# {now/d} is date math, and will insert the appropriate value automatically.
|