logstash-output-elasticsearch 10.5.0-java → 10.7.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 +16 -0
- data/docs/index.asciidoc +80 -50
- data/lib/logstash/outputs/elasticsearch.rb +33 -0
- data/lib/logstash/outputs/elasticsearch/common.rb +21 -8
- data/lib/logstash/outputs/elasticsearch/common_configs.rb +3 -3
- 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 +2 -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 +23 -1
- 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: 311303e9bfc0369329af5ec4da290d92e428bddee2e022fb1f22967fb1f1d6d9
|
|
4
|
+
data.tar.gz: c88b0816b49bd5f5ab232156340f946b674e70a62b86f8a1c4c25ed985840c6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d9910d4f28a864ac45450cd2be179268d8b83c91f8dab57328e6c772b06a39d7d8aa3fa7c34cddcd45a185bc994da2f2b46ee3b29bf2dc219a3189b6e995b30
|
|
7
|
+
data.tar.gz: de41059508b3f06466446d3a183d4959cdaaacffb00492d917acc57824b4864a694c5834c8e210d8d277ae186c146d6bf3c6b9ab0c0cd1ab73bc7f95a6f4e871
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 10.7.0
|
|
2
|
+
- Changed: don't set the pipeline parameter if the value resolves to an empty string [#962](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/962)
|
|
3
|
+
|
|
4
|
+
## 10.6.2
|
|
5
|
+
- [DOC] Added clarifying info on http compression settings and behaviors [#943](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/943)
|
|
6
|
+
- [DOC] Fixed entry for ilm_policy default value[#956](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/956)
|
|
7
|
+
|
|
8
|
+
## 10.6.1
|
|
9
|
+
- 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)
|
|
10
|
+
|
|
11
|
+
## 10.6.0
|
|
12
|
+
- Added `ecs_compatiblity` mode, for managing ECS-compatable templates [#952](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/952)
|
|
13
|
+
|
|
14
|
+
## 10.5.1
|
|
15
|
+
- [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)
|
|
16
|
+
|
|
1
17
|
## 10.5.0
|
|
2
18
|
- Added api_key support [#934](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/934)
|
|
3
19
|
|
data/docs/index.asciidoc
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
46
|
-
|
|
47
|
-
================================================================================
|
|
54
|
+
===== Hosted {es} Service on Elastic Cloud
|
|
48
55
|
|
|
49
|
-
|
|
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
|
|
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.
|
|
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].
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
==== Compatibility with the Elastic Common Schema (ECS)
|
|
64
62
|
|
|
65
|
-
|
|
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.
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
This change will not affect you and you will continue to use the ES defaults.
|
|
74
|
-
|
|
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,13 +218,17 @@ 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
|
|
228
|
-
for Elasticsearch versions 5.0 and later
|
|
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.
|
|
231
223
|
|
|
232
|
-
|
|
233
|
-
|
|
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.
|
|
234
232
|
|
|
235
233
|
==== Authentication
|
|
236
234
|
|
|
@@ -254,6 +252,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
|
254
252
|
| <<plugins-{type}s-{plugin}-doc_as_upsert>> |<<boolean,boolean>>|No
|
|
255
253
|
| <<plugins-{type}s-{plugin}-document_id>> |<<string,string>>|No
|
|
256
254
|
| <<plugins-{type}s-{plugin}-document_type>> |<<string,string>>|No
|
|
255
|
+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
|
257
256
|
| <<plugins-{type}s-{plugin}-failure_type_logging_whitelist>> |<<array,array>>|No
|
|
258
257
|
| <<plugins-{type}s-{plugin}-healthcheck_path>> |<<string,string>>|No
|
|
259
258
|
| <<plugins-{type}s-{plugin}-hosts>> |<<uri,uri>>|No
|
|
@@ -413,6 +412,25 @@ If you don't set a value for this option:
|
|
|
413
412
|
- for elasticsearch clusters 6.x: the value of 'doc' will be used;
|
|
414
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.
|
|
415
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
|
+
|
|
416
434
|
[id="plugins-{type}s-{plugin}-failure_type_logging_whitelist"]
|
|
417
435
|
===== `failure_type_logging_whitelist`
|
|
418
436
|
|
|
@@ -453,11 +471,15 @@ If you have custom firewall rules you may need to change this
|
|
|
453
471
|
|
|
454
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.
|
|
455
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
|
+
|
|
456
477
|
`"127.0.0.1"`
|
|
457
478
|
`["127.0.0.1:9200","127.0.0.2:9200"]`
|
|
458
479
|
`["http://127.0.0.1"]`
|
|
459
480
|
`["https://127.0.0.1:9200"]`
|
|
460
481
|
`["https://127.0.0.1:9200/mypath"]` (If using a proxy on a subpath)
|
|
482
|
+
|
|
461
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
|
|
462
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.
|
|
463
485
|
|
|
@@ -505,7 +527,7 @@ NOTE: The pattern must finish with a dash and a number that will be automaticall
|
|
|
505
527
|
===== `ilm_policy`
|
|
506
528
|
|
|
507
529
|
* Value type is <<string,string>>
|
|
508
|
-
* Default value is `logstash`
|
|
530
|
+
* Default value is `logstash-policy`
|
|
509
531
|
|
|
510
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
|
|
511
533
|
be automatically installed into Elasticsearch
|
|
@@ -516,7 +538,9 @@ NOTE: If this setting is specified, the policy must already exist in Elasticsear
|
|
|
516
538
|
===== `ilm_rollover_alias`
|
|
517
539
|
|
|
518
540
|
* Value type is <<string,string>>
|
|
519
|
-
* Default value is
|
|
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`
|
|
520
544
|
|
|
521
545
|
The rollover alias is the alias where indices managed using Index Lifecycle Management will be written to.
|
|
522
546
|
|
|
@@ -530,7 +554,9 @@ NOTE: `ilm_rollover_alias` does NOT support dynamic variable substitution as `in
|
|
|
530
554
|
===== `index`
|
|
531
555
|
|
|
532
556
|
* Value type is <<string,string>>
|
|
533
|
-
* Default value
|
|
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}"`
|
|
534
560
|
|
|
535
561
|
The index to write events to. This can be dynamic using the `%{foo}` syntax.
|
|
536
562
|
The default value will partition your indices by day so you can more easily
|
|
@@ -564,7 +590,8 @@ Set the keystore password
|
|
|
564
590
|
* Default value is `true`
|
|
565
591
|
|
|
566
592
|
From Logstash 1.3 onwards, a template is applied to Elasticsearch during
|
|
567
|
-
Logstash's startup if one with the name
|
|
593
|
+
Logstash's startup if one with the name <<plugins-{type}s-{plugin}-template_name>>
|
|
594
|
+
does not already exist.
|
|
568
595
|
By default, the contents of this template is the default template for
|
|
569
596
|
`logstash-%{+YYYY.MM.dd}` which always matches indices based on the pattern
|
|
570
597
|
`logstash-*`. Should you require support for other index names, or would like
|
|
@@ -620,8 +647,8 @@ not also set this field. That will raise an error at startup
|
|
|
620
647
|
* Value type is <<string,string>>
|
|
621
648
|
* Default value is `nil`
|
|
622
649
|
|
|
623
|
-
Set which ingest pipeline you wish to execute for an event. You can also use event dependent configuration
|
|
624
|
-
|
|
650
|
+
Set which ingest pipeline you wish to execute for an event. You can also use event dependent configuration here
|
|
651
|
+
like `pipeline => "%{[@metadata][pipeline]}"`. The pipeline parameter won't be set if the value resolves to empty string ("").
|
|
625
652
|
|
|
626
653
|
[id="plugins-{type}s-{plugin}-pool_max"]
|
|
627
654
|
===== `pool_max`
|
|
@@ -815,7 +842,10 @@ If not set, the included template will be used.
|
|
|
815
842
|
===== `template_name`
|
|
816
843
|
|
|
817
844
|
* Value type is <<string,string>>
|
|
818
|
-
* Default value is
|
|
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
|
+
|
|
819
849
|
|
|
820
850
|
This configuration option defines how the template is named inside Elasticsearch.
|
|
821
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:
|
|
@@ -242,6 +247,34 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
|
242
247
|
# Custom Headers to send on each request to elasticsearch nodes
|
|
243
248
|
config :custom_headers, :validate => :hash, :default => {}
|
|
244
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
|
+
|
|
245
278
|
# @override to handle proxy => '' as if none was set
|
|
246
279
|
def config_init(params)
|
|
247
280
|
proxy = params['proxy']
|
|
@@ -60,8 +60,15 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
|
60
60
|
!!maximum_seen_major_version
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
65
72
|
end
|
|
66
73
|
|
|
67
74
|
# Convert the event into a 3-tuple of action, params, and event
|
|
@@ -74,10 +81,16 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
|
74
81
|
routing_field_name => @routing ? event.sprintf(@routing) : nil
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
params[:_type] = get_event_type(event) if use_event_type?(
|
|
84
|
+
params[:_type] = get_event_type(event) if use_event_type?(nil)
|
|
78
85
|
|
|
79
86
|
if @pipeline
|
|
80
|
-
|
|
87
|
+
value = event.sprintf(@pipeline)
|
|
88
|
+
# convention: empty string equates to not using a pipeline
|
|
89
|
+
# this is useful when using a field reference in the pipeline setting, e.g.
|
|
90
|
+
# elasticsearch {
|
|
91
|
+
# pipeline => "%{[@metadata][pipeline]}"
|
|
92
|
+
# }
|
|
93
|
+
params[:pipeline] = value unless value.empty?
|
|
81
94
|
end
|
|
82
95
|
|
|
83
96
|
if @parent
|
|
@@ -347,11 +360,11 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
|
347
360
|
type = if @document_type
|
|
348
361
|
event.sprintf(@document_type)
|
|
349
362
|
else
|
|
350
|
-
if
|
|
363
|
+
if maximum_seen_major_version < 6
|
|
351
364
|
event.get("type") || DEFAULT_EVENT_TYPE_ES6
|
|
352
|
-
elsif
|
|
365
|
+
elsif maximum_seen_major_version == 6
|
|
353
366
|
DEFAULT_EVENT_TYPE_ES6
|
|
354
|
-
elsif
|
|
367
|
+
elsif maximum_seen_major_version == 7
|
|
355
368
|
DEFAULT_EVENT_TYPE_ES7
|
|
356
369
|
else
|
|
357
370
|
nil
|
|
@@ -436,7 +449,7 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
|
436
449
|
end
|
|
437
450
|
|
|
438
451
|
def default_index?(index)
|
|
439
|
-
@index ==
|
|
452
|
+
@index == @default_index
|
|
440
453
|
end
|
|
441
454
|
|
|
442
455
|
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.
|
|
@@ -12,7 +12,7 @@ module LogStash; module Outputs; class ElasticSearch
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def default_rollover_alias?(rollover_alias)
|
|
15
|
-
rollover_alias ==
|
|
15
|
+
rollover_alias == default_ilm_rollover_alias
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def ilm_alias_set?
|
|
@@ -3,14 +3,15 @@ module LogStash; module Outputs; class ElasticSearch
|
|
|
3
3
|
# To be mixed into the elasticsearch plugin base
|
|
4
4
|
def self.install_template(plugin)
|
|
5
5
|
return unless plugin.manage_template
|
|
6
|
-
if plugin.template
|
|
7
|
-
plugin.logger.info("Using default mapping template")
|
|
8
|
-
else
|
|
6
|
+
if plugin.template
|
|
9
7
|
plugin.logger.info("Using mapping template from", :path => plugin.template)
|
|
8
|
+
template = read_template_file(plugin.template)
|
|
9
|
+
else
|
|
10
|
+
plugin.logger.info("Using a default mapping template", :es_version => plugin.maximum_seen_major_version,
|
|
11
|
+
:ecs_compatibility => plugin.ecs_compatibility)
|
|
12
|
+
template = load_default_template(plugin.maximum_seen_major_version, plugin.ecs_compatibility)
|
|
10
13
|
end
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
template = get_template(plugin.template, plugin.maximum_seen_major_version)
|
|
14
15
|
add_ilm_settings_to_template(plugin, template) if plugin.ilm_in_use?
|
|
15
16
|
plugin.logger.info("Attempting to install template", :manage_template => template)
|
|
16
17
|
install(plugin.client, template_name(plugin), template, plugin.template_overwrite)
|
|
@@ -19,9 +20,11 @@ module LogStash; module Outputs; class ElasticSearch
|
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
private
|
|
22
|
-
def self.
|
|
23
|
-
template_path =
|
|
23
|
+
def self.load_default_template(es_major_version, ecs_compatibility)
|
|
24
|
+
template_path = default_template_path(es_major_version, ecs_compatibility)
|
|
24
25
|
read_template_file(template_path)
|
|
26
|
+
rescue => e
|
|
27
|
+
fail "Failed to load default template for Elasticsearch v#{es_major_version} with ECS #{ecs_compatibility}; caused by: #{e.inspect}"
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
def self.install(client, template_name, template, template_overwrite)
|
|
@@ -46,9 +49,9 @@ module LogStash; module Outputs; class ElasticSearch
|
|
|
46
49
|
plugin.ilm_in_use? && !plugin.original_params.key?('template_name') ? plugin.ilm_rollover_alias : plugin.template_name
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def self.default_template_path(es_major_version)
|
|
52
|
+
def self.default_template_path(es_major_version, ecs_compatibility=:disabled)
|
|
50
53
|
template_version = es_major_version == 1 ? 2 : es_major_version
|
|
51
|
-
default_template_name = "elasticsearch
|
|
54
|
+
default_template_name = "templates/ecs-#{ecs_compatibility}/elasticsearch-#{template_version}x.json"
|
|
52
55
|
::File.expand_path(default_template_name, ::File.dirname(__FILE__))
|
|
53
56
|
end
|
|
54
57
|
|