logstash-output-elasticsearch 10.7.0-java → 10.7.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTORS +1 -0
- data/docs/index.asciidoc +84 -69
- data/lib/logstash/outputs/elasticsearch/http_client.rb +6 -2
- data/lib/logstash/outputs/elasticsearch/template_manager.rb +8 -3
- data/lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-8x.json +39 -33
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/es_spec_helper.rb +32 -12
- data/spec/fixtures/template-with-policy-es8x.json +50 -0
- data/spec/integration/outputs/ilm_spec.rb +34 -20
- data/spec/integration/outputs/metrics_spec.rb +1 -5
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +22 -0
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +31 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800beb4697a44f1c41a41490b627b5b6dd192c695a818b33118e778a0fde7902
|
4
|
+
data.tar.gz: 380591f1e759722fac05fbc8893113ad0821cb9878e5257a9da8dc90f9a4fd09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 895bdaa0f45d48396b594df34545174a7788eb7647df0fc6cad58ab162950c399319d0c462d97a49133368a88731e3548e4ef508dc7115fd448ebd75b7da6d47
|
7
|
+
data.tar.gz: 96feefdd53810337a249cb4412296515ff049a6a07c0a81c81fc23b4152bd0061f3d7fd3cec7956eb0abb07636c3b78c1dbb16daf1040a77e359dc771f79d67d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 10.7.3
|
2
|
+
- Added composable index template support for elasticsearch version 8 [#980](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/980)
|
3
|
+
|
4
|
+
## 10.7.2
|
5
|
+
- [DOC] Fixed links to restructured Logstash-to-cloud docs [#975](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/975)
|
6
|
+
|
7
|
+
## 10.7.1
|
8
|
+
- [DOC] Document the permissions required in secured clusters [#969](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/969)
|
9
|
+
|
1
10
|
## 10.7.0
|
2
11
|
- 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
12
|
|
data/CONTRIBUTORS
CHANGED
@@ -26,6 +26,7 @@ Contributors:
|
|
26
26
|
* Tom Hodder (tolland)
|
27
27
|
* jimmyjones2
|
28
28
|
* Gabriel Moskovicz (gmoskovicz)
|
29
|
+
* Luca Belluccini (lucabelluccini)
|
29
30
|
|
30
31
|
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
31
32
|
Logstash, and you aren't on the list above and want to be, please let us know
|
data/docs/index.asciidoc
CHANGED
@@ -23,14 +23,14 @@ include::{include_path}/plugin_header.asciidoc[]
|
|
23
23
|
|
24
24
|
If you plan to use the Kibana web interface to analyze data transformed by
|
25
25
|
Logstash, use the Elasticsearch output plugin to get your data into
|
26
|
-
Elasticsearch.
|
26
|
+
Elasticsearch.
|
27
27
|
|
28
28
|
This output only speaks the HTTP protocol as it is the preferred protocol for
|
29
29
|
interacting with Elasticsearch. In previous versions it was possible to
|
30
30
|
communicate with Elasticsearch through the transport protocol, which is now
|
31
31
|
reserved for internal cluster communication between nodes
|
32
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]
|
33
|
+
Using the https://www.elastic.co/guide/en/elasticsearch/reference/current/java-clients.html[transport protocol]
|
34
34
|
to communicate with the cluster has been deprecated in Elasticsearch 7.0.0 and
|
35
35
|
will be removed in 8.0.0
|
36
36
|
|
@@ -53,10 +53,7 @@ connecting to Elasticsearch 7.x.
|
|
53
53
|
|
54
54
|
===== Hosted {es} Service on Elastic Cloud
|
55
55
|
|
56
|
-
|
57
|
-
https://www.elastic.co/cloud/elasticsearch-service[hosted {es} Service] on
|
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].
|
56
|
+
{ess-leadin}
|
60
57
|
|
61
58
|
==== Compatibility with the Elastic Common Schema (ECS)
|
62
59
|
|
@@ -76,7 +73,7 @@ and will correctly reject events with fields that conflict and cannot be coerced
|
|
76
73
|
|
77
74
|
[NOTE]
|
78
75
|
================================================================================
|
79
|
-
You cannot use dynamic variable substitution when `ilm_enabled` is `true` and
|
76
|
+
You cannot use dynamic variable substitution when `ilm_enabled` is `true` and
|
80
77
|
when using `ilm_rollover_alias`.
|
81
78
|
|
82
79
|
================================================================================
|
@@ -91,7 +88,10 @@ Each Elasticsearch output is a new client connected to the cluster:
|
|
91
88
|
* it has to initialize the client and connect to Elasticsearch (restart time is longer if you have more clients)
|
92
89
|
* it has an associated connection pool
|
93
90
|
|
94
|
-
In order to minimize the number of open connections to Elasticsearch, maximize
|
91
|
+
In order to minimize the number of open connections to Elasticsearch, maximize
|
92
|
+
the bulk size and reduce the number of "small" bulk requests (which could easily
|
93
|
+
fill up the queue), it is usually more efficient to have a single Elasticsearch
|
94
|
+
output.
|
95
95
|
|
96
96
|
Example:
|
97
97
|
[source,ruby]
|
@@ -100,11 +100,14 @@ Example:
|
|
100
100
|
index => "%{[some_field][sub_field]}-%{+YYYY.MM.dd}"
|
101
101
|
}
|
102
102
|
}
|
103
|
-
|
103
|
+
|
104
104
|
**What to do in case there is no field in the event containing the destination index prefix?**
|
105
105
|
|
106
|
-
You can use the `mutate` filter and conditionals to add a `[@metadata]` field
|
107
|
-
|
106
|
+
You can use the `mutate` filter and conditionals to add a `[@metadata]` field
|
107
|
+
(see
|
108
|
+
https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#metadata)
|
109
|
+
to set the destination index for each event. The `[@metadata]` fields will not
|
110
|
+
be sent to Elasticsearch.
|
108
111
|
|
109
112
|
Example:
|
110
113
|
[source,ruby]
|
@@ -136,7 +139,7 @@ HTTP requests to the bulk API are expected to return a 200 response code. All ot
|
|
136
139
|
The following document errors are handled as follows:
|
137
140
|
|
138
141
|
* 400 and 404 errors are sent to the dead letter queue (DLQ), if enabled. If a DLQ is not enabled, a log message will be emitted, and the event will be dropped. See <<plugins-{type}s-{plugin}-dlq-policy>> for more info.
|
139
|
-
* 409 errors (conflict) are logged as a warning and dropped.
|
142
|
+
* 409 errors (conflict) are logged as a warning and dropped.
|
140
143
|
|
141
144
|
Note that 409 exceptions are no longer retried. Please set a higher `retry_on_conflict` value if you experience 409 exceptions.
|
142
145
|
It is more performant for Elasticsearch to retry these exceptions than this plugin.
|
@@ -219,7 +222,7 @@ not reevaluate its DNS value while the keepalive is in effect.
|
|
219
222
|
==== HTTP Compression
|
220
223
|
|
221
224
|
This plugin supports request and response compression. Response compression is
|
222
|
-
enabled by default for HTTP and for Elasticsearch versions 5.0 and later.
|
225
|
+
enabled by default for HTTP and for Elasticsearch versions 5.0 and later.
|
223
226
|
|
224
227
|
You don't have to set any configs in Elasticsearch for it to send back a
|
225
228
|
compressed response. For versions before 5.0, or if HTTPS is enabled,
|
@@ -234,6 +237,13 @@ For requests compression, regardless of the Elasticsearch version, enable the
|
|
234
237
|
|
235
238
|
Authentication to a secure Elasticsearch cluster is possible using one of the `user`/`password`, `cloud_auth` or `api_key` options.
|
236
239
|
|
240
|
+
[id="plugins-{type}s-{plugin}-autz"]
|
241
|
+
==== Authorization
|
242
|
+
|
243
|
+
Authorization to a secure Elasticsearch cluster requires `read` permission at index level and `monitoring` permissions at cluster level.
|
244
|
+
The `monitoring` permission at cluster level is necessary to perform periodic connectivity checks.
|
245
|
+
|
246
|
+
|
237
247
|
[id="plugins-{type}s-{plugin}-options"]
|
238
248
|
==== Elasticsearch Output Configuration Options
|
239
249
|
|
@@ -307,7 +317,7 @@ output plugins.
|
|
307
317
|
|
308
318
|
|
309
319
|
[id="plugins-{type}s-{plugin}-action"]
|
310
|
-
===== `action`
|
320
|
+
===== `action`
|
311
321
|
|
312
322
|
* Value type is <<string,string>>
|
313
323
|
* Default value is `"index"`
|
@@ -338,7 +348,7 @@ Authenticate using Elasticsearch API key. Note that this option also requires en
|
|
338
348
|
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
349
|
|
340
350
|
[id="plugins-{type}s-{plugin}-bulk_path"]
|
341
|
-
===== `bulk_path`
|
351
|
+
===== `bulk_path`
|
342
352
|
|
343
353
|
* Value type is <<string,string>>
|
344
354
|
* There is no default value for this setting.
|
@@ -347,7 +357,7 @@ HTTP Path to perform the _bulk requests to
|
|
347
357
|
this defaults to a concatenation of the path parameter and "_bulk"
|
348
358
|
|
349
359
|
[id="plugins-{type}s-{plugin}-cacert"]
|
350
|
-
===== `cacert`
|
360
|
+
===== `cacert`
|
351
361
|
|
352
362
|
* Value type is <<path,path>>
|
353
363
|
* There is no default value for this setting.
|
@@ -362,7 +372,7 @@ The .cer or .pem file to validate the server's certificate
|
|
362
372
|
|
363
373
|
Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` pair.
|
364
374
|
|
365
|
-
For more details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html
|
375
|
+
For more details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html[Logstash-to-Cloud documentation]
|
366
376
|
|
367
377
|
[id="plugins-{type}s-{plugin}-cloud_id"]
|
368
378
|
===== `cloud_id`
|
@@ -372,10 +382,10 @@ For more details, check out the https://www.elastic.co/guide/en/logstash/current
|
|
372
382
|
|
373
383
|
Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
374
384
|
|
375
|
-
For more details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html
|
385
|
+
For more details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html[Logstash-to-Cloud documentation]
|
376
386
|
|
377
387
|
[id="plugins-{type}s-{plugin}-doc_as_upsert"]
|
378
|
-
===== `doc_as_upsert`
|
388
|
+
===== `doc_as_upsert`
|
379
389
|
|
380
390
|
* Value type is <<boolean,boolean>>
|
381
391
|
* Default value is `false`
|
@@ -384,7 +394,7 @@ Enable `doc_as_upsert` for update mode.
|
|
384
394
|
Create a new document with source if `document_id` doesn't exist in Elasticsearch
|
385
395
|
|
386
396
|
[id="plugins-{type}s-{plugin}-document_id"]
|
387
|
-
===== `document_id`
|
397
|
+
===== `document_id`
|
388
398
|
|
389
399
|
* Value type is <<string,string>>
|
390
400
|
* There is no default value for this setting.
|
@@ -392,7 +402,7 @@ Create a new document with source if `document_id` doesn't exist in Elasticsearc
|
|
392
402
|
The document ID for the index. Useful for overwriting existing entries in Elasticsearch with the same ID.
|
393
403
|
|
394
404
|
[id="plugins-{type}s-{plugin}-document_type"]
|
395
|
-
===== `document_type`
|
405
|
+
===== `document_type`
|
396
406
|
|
397
407
|
* Value type is <<string,string>>
|
398
408
|
* There is no default value for this setting.
|
@@ -432,7 +442,7 @@ The value of this setting affects the _default_ values of:
|
|
432
442
|
* <<plugins-{type}s-{plugin}-ilm_rollover_alias>>
|
433
443
|
|
434
444
|
[id="plugins-{type}s-{plugin}-failure_type_logging_whitelist"]
|
435
|
-
===== `failure_type_logging_whitelist`
|
445
|
+
===== `failure_type_logging_whitelist`
|
436
446
|
|
437
447
|
* Value type is <<array,array>>
|
438
448
|
* Default value is `[]`
|
@@ -453,7 +463,7 @@ an elasticsearch node. The headers will be used for any kind of request
|
|
453
463
|
These custom headers will be overidden by settings like `http_compression`.
|
454
464
|
|
455
465
|
[id="plugins-{type}s-{plugin}-healthcheck_path"]
|
456
|
-
===== `healthcheck_path`
|
466
|
+
===== `healthcheck_path`
|
457
467
|
|
458
468
|
* Value type is <<string,string>>
|
459
469
|
* There is no default value for this setting.
|
@@ -464,7 +474,7 @@ before it is once again eligible to service requests.
|
|
464
474
|
If you have custom firewall rules you may need to change this
|
465
475
|
|
466
476
|
[id="plugins-{type}s-{plugin}-hosts"]
|
467
|
-
===== `hosts`
|
477
|
+
===== `hosts`
|
468
478
|
|
469
479
|
* Value type is <<uri,uri>>
|
470
480
|
* Default value is `[//127.0.0.1]`
|
@@ -480,13 +490,17 @@ Examples:
|
|
480
490
|
`["https://127.0.0.1:9200"]`
|
481
491
|
`["https://127.0.0.1:9200/mypath"]` (If using a proxy on a subpath)
|
482
492
|
|
483
|
-
|
484
|
-
|
493
|
+
Exclude
|
494
|
+
http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html[dedicated
|
495
|
+
master nodes] from the `hosts` list to prevent Logstash from sending bulk
|
496
|
+
requests to the master nodes. This parameter should reference only data or
|
497
|
+
client nodes in Elasticsearch.
|
485
498
|
|
486
|
-
Any special characters present in the URLs here MUST be URL escaped! This means
|
499
|
+
Any special characters present in the URLs here MUST be URL escaped! This means
|
500
|
+
`#` should be put in as `%23` for instance.
|
487
501
|
|
488
502
|
[id="plugins-{type}s-{plugin}-http_compression"]
|
489
|
-
===== `http_compression`
|
503
|
+
===== `http_compression`
|
490
504
|
|
491
505
|
* Value type is <<boolean,boolean>>
|
492
506
|
* Default value is `false`
|
@@ -523,6 +537,9 @@ NOTE: Updating the pattern will require the index template to be rewritten
|
|
523
537
|
|
524
538
|
NOTE: The pattern must finish with a dash and a number that will be automatically incremented when indices rollover.
|
525
539
|
|
540
|
+
NOTE: The pattern is a 6-digit string padded by zeros, regardless of prior index name. Example: 000001.
|
541
|
+
See {ref}/indices-rollover-index.html#rollover-index-api-path-params[Rollover path parameters API docs] for details.
|
542
|
+
|
526
543
|
[id="plugins-{type}s-{plugin}-ilm_policy"]
|
527
544
|
===== `ilm_policy`
|
528
545
|
|
@@ -551,7 +568,7 @@ NOTE: Updating the rollover alias will require the index template to be rewritte
|
|
551
568
|
NOTE: `ilm_rollover_alias` does NOT support dynamic variable substitution as `index` does.
|
552
569
|
|
553
570
|
[id="plugins-{type}s-{plugin}-index"]
|
554
|
-
===== `index`
|
571
|
+
===== `index`
|
555
572
|
|
556
573
|
* Value type is <<string,string>>
|
557
574
|
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
|
@@ -567,7 +584,7 @@ LS uses Joda to format the index pattern from event timestamp.
|
|
567
584
|
Joda formats are defined http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[here].
|
568
585
|
|
569
586
|
[id="plugins-{type}s-{plugin}-keystore"]
|
570
|
-
===== `keystore`
|
587
|
+
===== `keystore`
|
571
588
|
|
572
589
|
* Value type is <<path,path>>
|
573
590
|
* There is no default value for this setting.
|
@@ -576,7 +593,7 @@ The keystore used to present a certificate to the server.
|
|
576
593
|
It can be either .jks or .p12
|
577
594
|
|
578
595
|
[id="plugins-{type}s-{plugin}-keystore_password"]
|
579
|
-
===== `keystore_password`
|
596
|
+
===== `keystore_password`
|
580
597
|
|
581
598
|
* Value type is <<password,password>>
|
582
599
|
* There is no default value for this setting.
|
@@ -584,7 +601,7 @@ It can be either .jks or .p12
|
|
584
601
|
Set the keystore password
|
585
602
|
|
586
603
|
[id="plugins-{type}s-{plugin}-manage_template"]
|
587
|
-
===== `manage_template`
|
604
|
+
===== `manage_template`
|
588
605
|
|
589
606
|
* Value type is <<boolean,boolean>>
|
590
607
|
* Default value is `true`
|
@@ -604,7 +621,7 @@ field names) you should set `manage_template` to false and use the REST
|
|
604
621
|
API to apply your templates manually.
|
605
622
|
|
606
623
|
[id="plugins-{type}s-{plugin}-parameters"]
|
607
|
-
===== `parameters`
|
624
|
+
===== `parameters`
|
608
625
|
|
609
626
|
* Value type is <<hash,hash>>
|
610
627
|
* There is no default value for this setting.
|
@@ -614,7 +631,7 @@ to every host listed in the 'hosts' configuration. If the 'hosts' list contains
|
|
614
631
|
urls that already have query strings, the one specified here will be appended.
|
615
632
|
|
616
633
|
[id="plugins-{type}s-{plugin}-parent"]
|
617
|
-
===== `parent`
|
634
|
+
===== `parent`
|
618
635
|
|
619
636
|
* Value type is <<string,string>>
|
620
637
|
* Default value is `nil`
|
@@ -623,7 +640,7 @@ For child documents, ID of the associated parent.
|
|
623
640
|
This can be dynamic using the `%{foo}` syntax.
|
624
641
|
|
625
642
|
[id="plugins-{type}s-{plugin}-password"]
|
626
|
-
===== `password`
|
643
|
+
===== `password`
|
627
644
|
|
628
645
|
* Value type is <<password,password>>
|
629
646
|
* There is no default value for this setting.
|
@@ -631,7 +648,7 @@ This can be dynamic using the `%{foo}` syntax.
|
|
631
648
|
Password to authenticate to a secure Elasticsearch cluster
|
632
649
|
|
633
650
|
[id="plugins-{type}s-{plugin}-path"]
|
634
|
-
===== `path`
|
651
|
+
===== `path`
|
635
652
|
|
636
653
|
* Value type is <<string,string>>
|
637
654
|
* There is no default value for this setting.
|
@@ -642,7 +659,7 @@ Note that if you use paths as components of URLs in the 'hosts' field you may
|
|
642
659
|
not also set this field. That will raise an error at startup
|
643
660
|
|
644
661
|
[id="plugins-{type}s-{plugin}-pipeline"]
|
645
|
-
===== `pipeline`
|
662
|
+
===== `pipeline`
|
646
663
|
|
647
664
|
* Value type is <<string,string>>
|
648
665
|
* Default value is `nil`
|
@@ -651,7 +668,7 @@ Set which ingest pipeline you wish to execute for an event. You can also use eve
|
|
651
668
|
like `pipeline => "%{[@metadata][pipeline]}"`. The pipeline parameter won't be set if the value resolves to empty string ("").
|
652
669
|
|
653
670
|
[id="plugins-{type}s-{plugin}-pool_max"]
|
654
|
-
===== `pool_max`
|
671
|
+
===== `pool_max`
|
655
672
|
|
656
673
|
* Value type is <<number,number>>
|
657
674
|
* Default value is `1000`
|
@@ -662,7 +679,7 @@ Setting this too low may mean frequently closing / opening connections
|
|
662
679
|
which is bad.
|
663
680
|
|
664
681
|
[id="plugins-{type}s-{plugin}-pool_max_per_route"]
|
665
|
-
===== `pool_max_per_route`
|
682
|
+
===== `pool_max_per_route`
|
666
683
|
|
667
684
|
* Value type is <<number,number>>
|
668
685
|
* Default value is `100`
|
@@ -673,7 +690,7 @@ Setting this too low may mean frequently closing / opening connections
|
|
673
690
|
which is bad.
|
674
691
|
|
675
692
|
[id="plugins-{type}s-{plugin}-proxy"]
|
676
|
-
===== `proxy`
|
693
|
+
===== `proxy`
|
677
694
|
|
678
695
|
* Value type is <<uri,uri>>
|
679
696
|
* There is no default value for this setting.
|
@@ -684,7 +701,7 @@ An empty string is treated as if proxy was not set. This is useful when using
|
|
684
701
|
environment variables e.g. `proxy => '${LS_PROXY:}'`.
|
685
702
|
|
686
703
|
[id="plugins-{type}s-{plugin}-resurrect_delay"]
|
687
|
-
===== `resurrect_delay`
|
704
|
+
===== `resurrect_delay`
|
688
705
|
|
689
706
|
* Value type is <<number,number>>
|
690
707
|
* Default value is `5`
|
@@ -694,7 +711,7 @@ Resurrection is the process by which backend endpoints marked 'down' are checked
|
|
694
711
|
to see if they have come back to life
|
695
712
|
|
696
713
|
[id="plugins-{type}s-{plugin}-retry_initial_interval"]
|
697
|
-
===== `retry_initial_interval`
|
714
|
+
===== `retry_initial_interval`
|
698
715
|
|
699
716
|
* Value type is <<number,number>>
|
700
717
|
* Default value is `2`
|
@@ -702,7 +719,7 @@ to see if they have come back to life
|
|
702
719
|
Set initial interval in seconds between bulk retries. Doubled on each retry up to `retry_max_interval`
|
703
720
|
|
704
721
|
[id="plugins-{type}s-{plugin}-retry_max_interval"]
|
705
|
-
===== `retry_max_interval`
|
722
|
+
===== `retry_max_interval`
|
706
723
|
|
707
724
|
* Value type is <<number,number>>
|
708
725
|
* Default value is `64`
|
@@ -710,17 +727,15 @@ Set initial interval in seconds between bulk retries. Doubled on each retry up t
|
|
710
727
|
Set max interval in seconds between bulk retries.
|
711
728
|
|
712
729
|
[id="plugins-{type}s-{plugin}-retry_on_conflict"]
|
713
|
-
===== `retry_on_conflict`
|
730
|
+
===== `retry_on_conflict`
|
714
731
|
|
715
732
|
* Value type is <<number,number>>
|
716
733
|
* Default value is `1`
|
717
734
|
|
718
|
-
The number of times Elasticsearch should internally retry an update/upserted document
|
719
|
-
See the https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html[partial updates]
|
720
|
-
for more info
|
735
|
+
The number of times Elasticsearch should internally retry an update/upserted document.
|
721
736
|
|
722
737
|
[id="plugins-{type}s-{plugin}-routing"]
|
723
|
-
===== `routing`
|
738
|
+
===== `routing`
|
724
739
|
|
725
740
|
* Value type is <<string,string>>
|
726
741
|
* There is no default value for this setting.
|
@@ -729,7 +744,7 @@ A routing override to be applied to all processed events.
|
|
729
744
|
This can be dynamic using the `%{foo}` syntax.
|
730
745
|
|
731
746
|
[id="plugins-{type}s-{plugin}-script"]
|
732
|
-
===== `script`
|
747
|
+
===== `script`
|
733
748
|
|
734
749
|
* Value type is <<string,string>>
|
735
750
|
* Default value is `""`
|
@@ -745,7 +760,7 @@ Example:
|
|
745
760
|
}
|
746
761
|
|
747
762
|
[id="plugins-{type}s-{plugin}-script_lang"]
|
748
|
-
===== `script_lang`
|
763
|
+
===== `script_lang`
|
749
764
|
|
750
765
|
* Value type is <<string,string>>
|
751
766
|
* Default value is `"painless"`
|
@@ -754,7 +769,7 @@ Set the language of the used script. If not set, this defaults to painless in ES
|
|
754
769
|
When using indexed (stored) scripts on Elasticsearch 6 and higher, you must set this parameter to `""` (empty string).
|
755
770
|
|
756
771
|
[id="plugins-{type}s-{plugin}-script_type"]
|
757
|
-
===== `script_type`
|
772
|
+
===== `script_type`
|
758
773
|
|
759
774
|
* Value can be any of: `inline`, `indexed`, `file`
|
760
775
|
* Default value is `["inline"]`
|
@@ -765,7 +780,7 @@ Define the type of script referenced by "script" variable
|
|
765
780
|
file : "script" contains the name of script stored in elasticsearch's config directory
|
766
781
|
|
767
782
|
[id="plugins-{type}s-{plugin}-script_var_name"]
|
768
|
-
===== `script_var_name`
|
783
|
+
===== `script_var_name`
|
769
784
|
|
770
785
|
* Value type is <<string,string>>
|
771
786
|
* Default value is `"event"`
|
@@ -773,7 +788,7 @@ Define the type of script referenced by "script" variable
|
|
773
788
|
Set variable name passed to script (scripted update)
|
774
789
|
|
775
790
|
[id="plugins-{type}s-{plugin}-scripted_upsert"]
|
776
|
-
===== `scripted_upsert`
|
791
|
+
===== `scripted_upsert`
|
777
792
|
|
778
793
|
* Value type is <<boolean,boolean>>
|
779
794
|
* Default value is `false`
|
@@ -781,7 +796,7 @@ Set variable name passed to script (scripted update)
|
|
781
796
|
if enabled, script is in charge of creating non-existent document (scripted update)
|
782
797
|
|
783
798
|
[id="plugins-{type}s-{plugin}-sniffing"]
|
784
|
-
===== `sniffing`
|
799
|
+
===== `sniffing`
|
785
800
|
|
786
801
|
* Value type is <<boolean,boolean>>
|
787
802
|
* Default value is `false`
|
@@ -791,7 +806,7 @@ For Elasticsearch 1.x and 2.x any nodes with `http.enabled` (on by default) will
|
|
791
806
|
For Elasticsearch 5.x and 6.x any nodes with `http.enabled` (on by default) will be added to the hosts list, excluding master-only nodes.
|
792
807
|
|
793
808
|
[id="plugins-{type}s-{plugin}-sniffing_delay"]
|
794
|
-
===== `sniffing_delay`
|
809
|
+
===== `sniffing_delay`
|
795
810
|
|
796
811
|
* Value type is <<number,number>>
|
797
812
|
* Default value is `5`
|
@@ -799,7 +814,7 @@ For Elasticsearch 5.x and 6.x any nodes with `http.enabled` (on by default) will
|
|
799
814
|
How long to wait, in seconds, between sniffing attempts
|
800
815
|
|
801
816
|
[id="plugins-{type}s-{plugin}-sniffing_path"]
|
802
|
-
===== `sniffing_path`
|
817
|
+
===== `sniffing_path`
|
803
818
|
|
804
819
|
* Value type is <<string,string>>
|
805
820
|
* There is no default value for this setting.
|
@@ -810,7 +825,7 @@ if sniffing_path is set it will be used as an absolute path
|
|
810
825
|
do not use full URL here, only paths, e.g. "/sniff/_nodes/http"
|
811
826
|
|
812
827
|
[id="plugins-{type}s-{plugin}-ssl"]
|
813
|
-
===== `ssl`
|
828
|
+
===== `ssl`
|
814
829
|
|
815
830
|
* Value type is <<boolean,boolean>>
|
816
831
|
* There is no default value for this setting.
|
@@ -820,7 +835,7 @@ is specified in the URLs listed in 'hosts'. If no explicit protocol is specified
|
|
820
835
|
If SSL is explicitly disabled here the plugin will refuse to start if an HTTPS URL is given in 'hosts'
|
821
836
|
|
822
837
|
[id="plugins-{type}s-{plugin}-ssl_certificate_verification"]
|
823
|
-
===== `ssl_certificate_verification`
|
838
|
+
===== `ssl_certificate_verification`
|
824
839
|
|
825
840
|
* Value type is <<boolean,boolean>>
|
826
841
|
* Default value is `true`
|
@@ -830,7 +845,7 @@ For more information on disabling certificate verification please read
|
|
830
845
|
https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
|
831
846
|
|
832
847
|
[id="plugins-{type}s-{plugin}-template"]
|
833
|
-
===== `template`
|
848
|
+
===== `template`
|
834
849
|
|
835
850
|
* Value type is <<path,path>>
|
836
851
|
* There is no default value for this setting.
|
@@ -839,7 +854,7 @@ You can set the path to your own template here, if you so desire.
|
|
839
854
|
If not set, the included template will be used.
|
840
855
|
|
841
856
|
[id="plugins-{type}s-{plugin}-template_name"]
|
842
|
-
===== `template_name`
|
857
|
+
===== `template_name`
|
843
858
|
|
844
859
|
* Value type is <<string,string>>
|
845
860
|
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
|
@@ -856,7 +871,7 @@ change this, you will need to prune the old template manually, e.g.
|
|
856
871
|
where `OldTemplateName` is whatever the former setting was.
|
857
872
|
|
858
873
|
[id="plugins-{type}s-{plugin}-template_overwrite"]
|
859
|
-
===== `template_overwrite`
|
874
|
+
===== `template_overwrite`
|
860
875
|
|
861
876
|
* Value type is <<boolean,boolean>>
|
862
877
|
* Default value is `false`
|
@@ -873,7 +888,7 @@ template (logstash), setting this to true will make Logstash to overwrite
|
|
873
888
|
the "logstash" template (i.e. removing all customized settings)
|
874
889
|
|
875
890
|
[id="plugins-{type}s-{plugin}-timeout"]
|
876
|
-
===== `timeout`
|
891
|
+
===== `timeout`
|
877
892
|
|
878
893
|
* Value type is <<number,number>>
|
879
894
|
* Default value is `60`
|
@@ -882,7 +897,7 @@ Set the timeout, in seconds, for network operations and requests sent Elasticsea
|
|
882
897
|
a timeout occurs, the request will be retried.
|
883
898
|
|
884
899
|
[id="plugins-{type}s-{plugin}-truststore"]
|
885
|
-
===== `truststore`
|
900
|
+
===== `truststore`
|
886
901
|
|
887
902
|
* Value type is <<path,path>>
|
888
903
|
* There is no default value for this setting.
|
@@ -892,7 +907,7 @@ It can be either .jks or .p12.
|
|
892
907
|
Use either `:truststore` or `:cacert`.
|
893
908
|
|
894
909
|
[id="plugins-{type}s-{plugin}-truststore_password"]
|
895
|
-
===== `truststore_password`
|
910
|
+
===== `truststore_password`
|
896
911
|
|
897
912
|
* Value type is <<password,password>>
|
898
913
|
* There is no default value for this setting.
|
@@ -900,7 +915,7 @@ Use either `:truststore` or `:cacert`.
|
|
900
915
|
Set the truststore password
|
901
916
|
|
902
917
|
[id="plugins-{type}s-{plugin}-upsert"]
|
903
|
-
===== `upsert`
|
918
|
+
===== `upsert`
|
904
919
|
|
905
920
|
* Value type is <<string,string>>
|
906
921
|
* Default value is `""`
|
@@ -909,7 +924,7 @@ Set upsert content for update mode.
|
|
909
924
|
Create a new document with this parameter as json string if `document_id` doesn't exists
|
910
925
|
|
911
926
|
[id="plugins-{type}s-{plugin}-user"]
|
912
|
-
===== `user`
|
927
|
+
===== `user`
|
913
928
|
|
914
929
|
* Value type is <<string,string>>
|
915
930
|
* There is no default value for this setting.
|
@@ -917,7 +932,7 @@ Create a new document with this parameter as json string if `document_id` doesn'
|
|
917
932
|
Username to authenticate to a secure Elasticsearch cluster
|
918
933
|
|
919
934
|
[id="plugins-{type}s-{plugin}-validate_after_inactivity"]
|
920
|
-
===== `validate_after_inactivity`
|
935
|
+
===== `validate_after_inactivity`
|
921
936
|
|
922
937
|
* Value type is <<number,number>>
|
923
938
|
* Default value is `10000`
|
@@ -932,7 +947,7 @@ have become stale (half-closed) while kept inactive in the pool.'
|
|
932
947
|
See https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html#setValidateAfterInactivity(int)[these docs for more info]
|
933
948
|
|
934
949
|
[id="plugins-{type}s-{plugin}-version"]
|
935
|
-
===== `version`
|
950
|
+
===== `version`
|
936
951
|
|
937
952
|
* Value type is <<string,string>>
|
938
953
|
* There is no default value for this setting.
|
@@ -941,7 +956,7 @@ The version to use for indexing. Use sprintf syntax like `%{my_version}` to use
|
|
941
956
|
See https://www.elastic.co/blog/elasticsearch-versioning-support.
|
942
957
|
|
943
958
|
[id="plugins-{type}s-{plugin}-version_type"]
|
944
|
-
===== `version_type`
|
959
|
+
===== `version_type`
|
945
960
|
|
946
961
|
* Value can be any of: `internal`, `external`, `external_gt`, `external_gte`, `force`
|
947
962
|
* There is no default value for this setting.
|
@@ -343,15 +343,19 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
343
343
|
end
|
344
344
|
|
345
345
|
def template_exists?(name)
|
346
|
-
exists?("
|
346
|
+
exists?("/#{template_endpoint}/#{name}")
|
347
347
|
end
|
348
348
|
|
349
349
|
def template_put(name, template)
|
350
|
-
path = "
|
350
|
+
path = "#{template_endpoint}/#{name}"
|
351
351
|
logger.info("Installing elasticsearch template to #{path}")
|
352
352
|
@pool.put(path, nil, LogStash::Json.dump(template))
|
353
353
|
end
|
354
354
|
|
355
|
+
def template_endpoint
|
356
|
+
maximum_seen_major_version < 8 ? '_template' : '_index_template'
|
357
|
+
end
|
358
|
+
|
355
359
|
# ILM methods
|
356
360
|
|
357
361
|
# check whether rollover alias already exists
|
@@ -34,12 +34,17 @@ module LogStash; module Outputs; class ElasticSearch
|
|
34
34
|
def self.add_ilm_settings_to_template(plugin, template)
|
35
35
|
# Overwrite any index patterns, and use the rollover alias. Use 'index_patterns' rather than 'template' for pattern
|
36
36
|
# definition - remove any existing definition of 'template'
|
37
|
-
template.delete('template') if template.include?('template')
|
37
|
+
template.delete('template') if template.include?('template') if plugin.maximum_seen_major_version < 8
|
38
38
|
template['index_patterns'] = "#{plugin.ilm_rollover_alias}-*"
|
39
|
-
|
39
|
+
settings = template_settings(plugin, template)
|
40
|
+
if settings && (settings['index.lifecycle.name'] || settings['index.lifecycle.rollover_alias'])
|
40
41
|
plugin.logger.info("Overwriting index lifecycle name and rollover alias as ILM is enabled.")
|
41
42
|
end
|
42
|
-
|
43
|
+
settings.update({ 'index.lifecycle.name' => plugin.ilm_policy, 'index.lifecycle.rollover_alias' => plugin.ilm_rollover_alias})
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.template_settings(plugin, template)
|
47
|
+
plugin.maximum_seen_major_version < 8 ? template['settings']: template['template']['settings']
|
43
48
|
end
|
44
49
|
|
45
50
|
# Template name - if template_name set, use it
|
@@ -1,44 +1,50 @@
|
|
1
1
|
{
|
2
2
|
"index_patterns" : "logstash-*",
|
3
3
|
"version" : 80001,
|
4
|
-
"
|
5
|
-
"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
|
13
|
-
|
14
|
-
"
|
15
|
-
|
4
|
+
"template" : {
|
5
|
+
"settings" : {
|
6
|
+
"index.refresh_interval" : "5s",
|
7
|
+
"number_of_shards": 1
|
8
|
+
},
|
9
|
+
"mappings" : {
|
10
|
+
"dynamic_templates" : [ {
|
11
|
+
"message_field" : {
|
12
|
+
"path_match" : "message",
|
13
|
+
"match_mapping_type" : "string",
|
14
|
+
"mapping" : {
|
15
|
+
"type" : "text",
|
16
|
+
"norms" : false
|
17
|
+
}
|
16
18
|
}
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
}, {
|
20
|
+
"string_fields" : {
|
21
|
+
"match" : "*",
|
22
|
+
"match_mapping_type" : "string",
|
23
|
+
"mapping" : {
|
24
|
+
"type" : "text", "norms" : false,
|
25
|
+
"fields" : {
|
26
|
+
"keyword" : { "type": "keyword", "ignore_above": 256 }
|
27
|
+
}
|
26
28
|
}
|
27
29
|
}
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
} ],
|
31
|
+
"properties" : {
|
32
|
+
"@timestamp": { "type": "date" },
|
33
|
+
"@version": { "type": "keyword" },
|
34
|
+
"geoip" : {
|
35
|
+
"dynamic": true,
|
36
|
+
"properties" : {
|
37
|
+
"ip": { "type": "ip" },
|
38
|
+
"location" : { "type" : "geo_point" },
|
39
|
+
"latitude" : { "type" : "half_float" },
|
40
|
+
"longitude" : { "type" : "half_float" }
|
41
|
+
}
|
40
42
|
}
|
41
43
|
}
|
42
44
|
}
|
45
|
+
},
|
46
|
+
"priority": 200,
|
47
|
+
"_meta" : {
|
48
|
+
"description": "index template for logstash-output-elasticsearch"
|
43
49
|
}
|
44
50
|
}
|
data/spec/es_spec_helper.rb
CHANGED
@@ -49,19 +49,10 @@ module ESHelper
|
|
49
49
|
Time.now.strftime("%Y.%m.%d")
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
def default_mapping_from_mappings(mappings)
|
54
|
-
if ESHelper.es_version_satisfies?(">=7")
|
55
|
-
mappings
|
56
|
-
else
|
57
|
-
mappings["_default_"]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
52
|
def field_properties_from_template(template_name, field)
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
template = get_template(@es, template_name)
|
54
|
+
mappings = get_template_mappings(template)
|
55
|
+
mappings["properties"][field]["properties"]
|
65
56
|
end
|
66
57
|
|
67
58
|
def routing_field_name
|
@@ -105,6 +96,7 @@ module ESHelper
|
|
105
96
|
|
106
97
|
def clean(client)
|
107
98
|
client.indices.delete_template(:name => "*")
|
99
|
+
client.indices.delete_index_template(:name => "logstash*") rescue nil
|
108
100
|
# This can fail if there are no indexes, ignore failure.
|
109
101
|
client.indices.delete(:index => "*") rescue nil
|
110
102
|
clean_ilm(client) if supports_ilm?(client)
|
@@ -182,6 +174,34 @@ module ESHelper
|
|
182
174
|
}
|
183
175
|
}
|
184
176
|
end
|
177
|
+
|
178
|
+
def get_template(client, name)
|
179
|
+
if ESHelper.es_version_satisfies?(">=8")
|
180
|
+
t = client.indices.get_index_template(name: name)
|
181
|
+
t['index_templates'][0]['index_template']
|
182
|
+
else
|
183
|
+
t = client.indices.get_template(name: name)
|
184
|
+
t[name]
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_template_settings(template)
|
189
|
+
if ESHelper.es_version_satisfies?(">=8")
|
190
|
+
template['template']['settings']
|
191
|
+
else
|
192
|
+
template['settings']
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def get_template_mappings(template)
|
197
|
+
if ESHelper.es_version_satisfies?(">=8")
|
198
|
+
template['template']['mappings']
|
199
|
+
elsif ESHelper.es_version_satisfies?(">=7")
|
200
|
+
template['mappings']
|
201
|
+
else
|
202
|
+
template['mappings']["_default_"]
|
203
|
+
end
|
204
|
+
end
|
185
205
|
end
|
186
206
|
|
187
207
|
RSpec.configure do |config|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"index_patterns" : "overwrite-*",
|
3
|
+
"version" : 80001,
|
4
|
+
"template" : {
|
5
|
+
"settings" : {
|
6
|
+
"index.refresh_interval" : "1s",
|
7
|
+
"number_of_shards": 1
|
8
|
+
},
|
9
|
+
"mappings" : {
|
10
|
+
"dynamic_templates" : [ {
|
11
|
+
"message_field" : {
|
12
|
+
"path_match" : "message",
|
13
|
+
"match_mapping_type" : "string",
|
14
|
+
"mapping" : {
|
15
|
+
"type" : "text",
|
16
|
+
"norms" : false
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}, {
|
20
|
+
"string_fields" : {
|
21
|
+
"match" : "*",
|
22
|
+
"match_mapping_type" : "string",
|
23
|
+
"mapping" : {
|
24
|
+
"type" : "text", "norms" : false,
|
25
|
+
"fields" : {
|
26
|
+
"keyword" : { "type": "keyword", "ignore_above": 256 }
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
} ],
|
31
|
+
"properties" : {
|
32
|
+
"@timestamp": { "type": "date" },
|
33
|
+
"@version": { "type": "keyword" },
|
34
|
+
"geoip" : {
|
35
|
+
"dynamic": true,
|
36
|
+
"properties" : {
|
37
|
+
"ip": { "type": "ip" },
|
38
|
+
"location" : { "type" : "geo_point" },
|
39
|
+
"latitude" : { "type" : "half_float" },
|
40
|
+
"longitude" : { "type" : "half_float" }
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
},
|
46
|
+
"priority": 200,
|
47
|
+
"_meta" : {
|
48
|
+
"description": "index template for logstash-output-elasticsearch"
|
49
|
+
}
|
50
|
+
}
|
@@ -8,7 +8,7 @@ shared_examples_for 'an ILM enabled Logstash' do
|
|
8
8
|
let (:settings) { super.merge("ilm_policy" => ilm_policy_name)}
|
9
9
|
|
10
10
|
it 'should rollover when the policy max docs is reached' do
|
11
|
-
put_policy(@es,ilm_policy_name, policy)
|
11
|
+
put_policy(@es, ilm_policy_name, policy)
|
12
12
|
subject.register
|
13
13
|
|
14
14
|
subject.multi_receive([
|
@@ -108,9 +108,11 @@ shared_examples_for 'an ILM disabled Logstash' do
|
|
108
108
|
it 'should not write the ILM settings into the template' do
|
109
109
|
subject.register
|
110
110
|
sleep(1)
|
111
|
-
|
111
|
+
|
112
|
+
template = get_template(@es, "logstash")
|
113
|
+
expect(template).to have_index_pattern("logstash-*")
|
112
114
|
if ESHelper.es_version_satisfies?(">= 2")
|
113
|
-
expect(
|
115
|
+
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
@@ -152,16 +154,17 @@ shared_examples_for 'an ILM disabled Logstash' do
|
|
152
154
|
end
|
153
155
|
|
154
156
|
context 'with a custom template name' do
|
155
|
-
let (:template_name) { "
|
157
|
+
let (:template_name) { "logstash_custom_template_name" }
|
156
158
|
let (:settings) { super.merge('template_name' => template_name)}
|
157
159
|
|
158
160
|
it 'should not write the ILM settings into the template' do
|
159
161
|
subject.register
|
160
162
|
sleep(1)
|
161
163
|
|
162
|
-
|
164
|
+
template = get_template(@es, template_name)
|
165
|
+
expect(template).to have_index_pattern("logstash-*")
|
163
166
|
if ESHelper.es_version_satisfies?(">= 2")
|
164
|
-
expect(
|
167
|
+
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
165
168
|
end
|
166
169
|
end
|
167
170
|
end
|
@@ -387,16 +390,20 @@ if ESHelper.es_version_satisfies?(">= 6.6")
|
|
387
390
|
it 'should write the ILM settings into the template' do
|
388
391
|
subject.register
|
389
392
|
sleep(1)
|
390
|
-
|
391
|
-
|
392
|
-
expect(
|
393
|
+
|
394
|
+
template = get_template(@es, "logstash")
|
395
|
+
expect(template).to have_index_pattern("logstash-*")
|
396
|
+
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq("logstash-policy")
|
397
|
+
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq("logstash")
|
393
398
|
end
|
394
399
|
|
395
400
|
it_behaves_like 'an ILM enabled Logstash'
|
396
401
|
end
|
397
402
|
|
398
403
|
context 'with a set index and a custom index pattern' do
|
399
|
-
if ESHelper.es_version_satisfies?(">=
|
404
|
+
if ESHelper.es_version_satisfies?(">= 8.0")
|
405
|
+
let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
|
406
|
+
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
400
407
|
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
401
408
|
else
|
402
409
|
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
@@ -408,13 +415,15 @@ if ESHelper.es_version_satisfies?(">= 6.6")
|
|
408
415
|
it 'should not overwrite the index patterns' do
|
409
416
|
subject.register
|
410
417
|
sleep(1)
|
411
|
-
|
418
|
+
|
419
|
+
template = get_template(@es, "logstash")
|
420
|
+
expect(template).to have_index_pattern("overwrite-*")
|
412
421
|
end
|
413
422
|
end
|
414
423
|
|
415
424
|
|
416
425
|
context 'with a custom template' do
|
417
|
-
let (:ilm_rollover_alias) { "
|
426
|
+
let (:ilm_rollover_alias) { "logstash_the_cat_in_the_hat" }
|
418
427
|
let (:index) { ilm_rollover_alias }
|
419
428
|
let(:expected_index) { index }
|
420
429
|
let (:settings) { super.merge("ilm_policy" => ilm_policy_name,
|
@@ -422,7 +431,9 @@ if ESHelper.es_version_satisfies?(">= 6.6")
|
|
422
431
|
"ilm_rollover_alias" => ilm_rollover_alias)}
|
423
432
|
|
424
433
|
|
425
|
-
if ESHelper.es_version_satisfies?(">=
|
434
|
+
if ESHelper.es_version_satisfies?(">= 8.0")
|
435
|
+
let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
|
436
|
+
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
426
437
|
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
427
438
|
else
|
428
439
|
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
@@ -460,13 +471,15 @@ if ESHelper.es_version_satisfies?(">= 6.6")
|
|
460
471
|
it 'should write the ILM settings into the template' do
|
461
472
|
subject.register
|
462
473
|
sleep(1)
|
463
|
-
|
464
|
-
|
465
|
-
expect(
|
474
|
+
|
475
|
+
template = get_template(@es, ilm_rollover_alias)
|
476
|
+
expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
|
477
|
+
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
|
478
|
+
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
|
466
479
|
end
|
467
480
|
|
468
481
|
context 'with a different template_name' do
|
469
|
-
let (:template_name) { "
|
482
|
+
let (:template_name) { "logstash_custom_template_name" }
|
470
483
|
let (:settings) { super.merge('template_name' => template_name)}
|
471
484
|
|
472
485
|
it_behaves_like 'an ILM enabled Logstash'
|
@@ -474,9 +487,10 @@ if ESHelper.es_version_satisfies?(">= 6.6")
|
|
474
487
|
it 'should write the ILM settings into the template' do
|
475
488
|
subject.register
|
476
489
|
sleep(1)
|
477
|
-
|
478
|
-
expect(
|
479
|
-
expect(
|
490
|
+
template = get_template(@es, template_name)
|
491
|
+
expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
|
492
|
+
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
|
493
|
+
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
|
480
494
|
end
|
481
495
|
end
|
482
496
|
|
@@ -19,11 +19,7 @@ describe "metrics", :integration => true do
|
|
19
19
|
|
20
20
|
# Clean ES of data before we start.
|
21
21
|
@es = get_client
|
22
|
-
@es
|
23
|
-
|
24
|
-
# This can fail if there are no indexes, ignore failure.
|
25
|
-
@es.indices.delete(:index => "*") rescue nil
|
26
|
-
#@es.indices.refresh
|
22
|
+
clean(@es)
|
27
23
|
subject.register
|
28
24
|
end
|
29
25
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative "../../../../spec/es_spec_helper"
|
1
2
|
require "logstash/devutils/rspec/spec_helper"
|
2
3
|
require "logstash/outputs/elasticsearch/http_client"
|
3
4
|
require "java"
|
@@ -138,6 +139,27 @@ describe LogStash::Outputs::ElasticSearch::HttpClient do
|
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
142
|
+
describe "index template" do
|
143
|
+
subject { described_class.new(base_options) }
|
144
|
+
let(:template_name) { "logstash" }
|
145
|
+
let(:template) { {} }
|
146
|
+
let(:get_response) {
|
147
|
+
double("response", :body => {})
|
148
|
+
}
|
149
|
+
|
150
|
+
it "should call composable index template in version 8+" do
|
151
|
+
expect(subject).to receive(:maximum_seen_major_version).and_return(8)
|
152
|
+
expect(subject.pool).to receive(:put).with("_index_template/#{template_name}", nil, anything).and_return(get_response)
|
153
|
+
subject.template_put(template_name, template)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should call index template in version < 8" do
|
157
|
+
expect(subject).to receive(:maximum_seen_major_version).and_return(7)
|
158
|
+
expect(subject.pool).to receive(:put).with("_template/#{template_name}", nil, anything).and_return(get_response)
|
159
|
+
subject.template_put(template_name, template)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
141
163
|
describe "join_bulk_responses" do
|
142
164
|
subject { described_class.new(base_options) }
|
143
165
|
|
@@ -28,4 +28,35 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
|
|
28
28
|
expect(described_class.default_template_path(7, :v1)).to end_with("/templates/ecs-v1/elasticsearch-7x.json")
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe "index template with ilm settings" do
|
33
|
+
let(:plugin_settings) { {"manage_template" => true, "template_overwrite" => true} }
|
34
|
+
let(:plugin) { LogStash::Outputs::ElasticSearch.new(plugin_settings) }
|
35
|
+
|
36
|
+
describe "in version 8+" do
|
37
|
+
let(:file_path) { described_class.default_template_path(8) }
|
38
|
+
let(:template) { described_class.read_template_file(file_path)}
|
39
|
+
|
40
|
+
it "should update settings" do
|
41
|
+
expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(8)
|
42
|
+
described_class.add_ilm_settings_to_template(plugin, template)
|
43
|
+
expect(template['template']['settings']['index.lifecycle.name']).not_to eq(nil)
|
44
|
+
expect(template['template']['settings']['index.lifecycle.rollover_alias']).not_to eq(nil)
|
45
|
+
expect(template.include?('settings')).to be_falsey
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "in version < 8" do
|
50
|
+
let(:file_path) { described_class.default_template_path(7) }
|
51
|
+
let(:template) { described_class.read_template_file(file_path)}
|
52
|
+
|
53
|
+
it "should update settings" do
|
54
|
+
expect(plugin).to receive(:maximum_seen_major_version).at_least(:once).and_return(7)
|
55
|
+
described_class.add_ilm_settings_to_template(plugin, template)
|
56
|
+
expect(template['settings']['index.lifecycle.name']).not_to eq(nil)
|
57
|
+
expect(template['settings']['index.lifecycle.rollover_alias']).not_to eq(nil)
|
58
|
+
expect(template.include?('template')).to be_falsey
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
31
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.7.
|
4
|
+
version: 10.7.3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- spec/fixtures/scripts/painless/scripted_upsert.painless
|
202
202
|
- spec/fixtures/template-with-policy-es6x.json
|
203
203
|
- spec/fixtures/template-with-policy-es7x.json
|
204
|
+
- spec/fixtures/template-with-policy-es8x.json
|
204
205
|
- spec/fixtures/test_certs/ca/ca.crt
|
205
206
|
- spec/fixtures/test_certs/ca/ca.key
|
206
207
|
- spec/fixtures/test_certs/test.crt
|
@@ -278,6 +279,7 @@ test_files:
|
|
278
279
|
- spec/fixtures/scripts/painless/scripted_upsert.painless
|
279
280
|
- spec/fixtures/template-with-policy-es6x.json
|
280
281
|
- spec/fixtures/template-with-policy-es7x.json
|
282
|
+
- spec/fixtures/template-with-policy-es8x.json
|
281
283
|
- spec/fixtures/test_certs/ca/ca.crt
|
282
284
|
- spec/fixtures/test_certs/ca/ca.key
|
283
285
|
- spec/fixtures/test_certs/test.crt
|