logstash-output-elasticsearch 11.0.1-java → 11.0.5-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 +12 -0
- data/docs/index.asciidoc +12 -12
- data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +2 -28
- data/lib/logstash/outputs/elasticsearch/http_client.rb +4 -0
- data/lib/logstash/outputs/elasticsearch/ilm.rb +2 -33
- data/lib/logstash/outputs/elasticsearch/license_checker.rb +12 -6
- data/lib/logstash/outputs/elasticsearch/template_manager.rb +1 -1
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-8x.json +1 -0
- data/lib/logstash/outputs/elasticsearch.rb +3 -14
- data/lib/logstash/plugin_mixins/elasticsearch/common.rb +5 -1
- data/logstash-output-elasticsearch.gemspec +2 -2
- data/spec/es_spec_helper.rb +4 -6
- data/spec/fixtures/_nodes/{5x_6x.json → 6x.json} +5 -5
- data/spec/integration/outputs/compressed_indexing_spec.rb +47 -46
- data/spec/integration/outputs/delete_spec.rb +49 -51
- data/spec/integration/outputs/ilm_spec.rb +230 -246
- data/spec/integration/outputs/index_spec.rb +5 -2
- data/spec/integration/outputs/index_version_spec.rb +78 -82
- data/spec/integration/outputs/ingest_pipeline_spec.rb +58 -60
- data/spec/integration/outputs/no_es_on_startup_spec.rb +14 -0
- data/spec/integration/outputs/painless_update_spec.rb +74 -164
- data/spec/integration/outputs/parent_spec.rb +67 -75
- data/spec/integration/outputs/retry_spec.rb +2 -2
- data/spec/integration/outputs/sniffer_spec.rb +15 -53
- data/spec/integration/outputs/templates_spec.rb +79 -81
- data/spec/integration/outputs/update_spec.rb +99 -101
- data/spec/spec_helper.rb +1 -5
- data/spec/unit/outputs/elasticsearch/data_stream_support_spec.rb +0 -14
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +30 -37
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +9 -9
- data/spec/unit/outputs/elasticsearch_spec.rb +2 -8
- data/spec/unit/outputs/error_whitelist_spec.rb +1 -0
- metadata +8 -22
- data/lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-2x.json +0 -95
- data/lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-5x.json +0 -46
- data/spec/fixtures/_nodes/2x_1x.json +0 -27
- data/spec/fixtures/scripts/groovy/scripted_update.groovy +0 -2
- data/spec/fixtures/scripts/groovy/scripted_update_nested.groovy +0 -2
- data/spec/fixtures/scripts/groovy/scripted_upsert.groovy +0 -2
- data/spec/integration/outputs/groovy_update_spec.rb +0 -150
- data/spec/integration/outputs/templates_5x_spec.rb +0 -98
@@ -2,64 +2,62 @@ require_relative "../../../spec/es_spec_helper"
|
|
2
2
|
require "logstash/outputs/elasticsearch"
|
3
3
|
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe "Versioned delete", :integration => true do
|
6
|
+
require "logstash/outputs/elasticsearch"
|
7
|
+
|
8
|
+
let(:es) { get_client }
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
# Delete all templates first.
|
12
|
+
# Clean ES of data before we start.
|
13
|
+
es.indices.delete_template(:name => "*")
|
14
|
+
# This can fail if there are no indexes, ignore failure.
|
15
|
+
es.indices.delete(:index => "*") rescue nil
|
16
|
+
es.indices.refresh
|
17
|
+
end
|
8
18
|
|
9
|
-
|
19
|
+
context "when delete only" do
|
20
|
+
subject { LogStash::Outputs::ElasticSearch.new(settings) }
|
10
21
|
|
11
|
-
before
|
12
|
-
|
13
|
-
# Clean ES of data before we start.
|
14
|
-
es.indices.delete_template(:name => "*")
|
15
|
-
# This can fail if there are no indexes, ignore failure.
|
16
|
-
es.indices.delete(:index => "*") rescue nil
|
17
|
-
es.indices.refresh
|
22
|
+
before do
|
23
|
+
subject.register
|
18
24
|
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"hosts" => get_host_port(),
|
33
|
-
"document_id" => "%{my_id}",
|
34
|
-
"version" => "%{my_version}",
|
35
|
-
"version_type" => "external",
|
36
|
-
"action" => "%{my_action}"
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should ignore non-monotonic external version updates" do
|
41
|
-
id = "ev2"
|
42
|
-
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_action" => "index", "message" => "foo", "my_version" => 99)])
|
43
|
-
r = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
44
|
-
expect(r['_version']).to eq(99)
|
45
|
-
expect(r['_source']['message']).to eq('foo')
|
26
|
+
let(:settings) do
|
27
|
+
{
|
28
|
+
"manage_template" => true,
|
29
|
+
"index" => "logstash-delete",
|
30
|
+
"template_overwrite" => true,
|
31
|
+
"hosts" => get_host_port(),
|
32
|
+
"document_id" => "%{my_id}",
|
33
|
+
"version" => "%{my_version}",
|
34
|
+
"version_type" => "external",
|
35
|
+
"action" => "%{my_action}"
|
36
|
+
}
|
37
|
+
end
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
it "should ignore non-monotonic external version updates" do
|
40
|
+
id = "ev2"
|
41
|
+
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_action" => "index", "message" => "foo", "my_version" => 99)])
|
42
|
+
r = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
43
|
+
expect(r['_version']).to eq(99)
|
44
|
+
expect(r['_source']['message']).to eq('foo')
|
45
|
+
|
46
|
+
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_action" => "delete", "message" => "foo", "my_version" => 98)])
|
47
|
+
r2 = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
48
|
+
expect(r2['_version']).to eq(99)
|
49
|
+
expect(r2['_source']['message']).to eq('foo')
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
it "should commit monotonic external version updates" do
|
53
|
+
id = "ev3"
|
54
|
+
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_action" => "index", "message" => "foo", "my_version" => 99)])
|
55
|
+
r = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
56
|
+
expect(r['_version']).to eq(99)
|
57
|
+
expect(r['_source']['message']).to eq('foo')
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
end
|
59
|
+
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_action" => "delete", "message" => "foo", "my_version" => 100)])
|
60
|
+
expect { es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
@@ -111,9 +111,7 @@ shared_examples_for 'an ILM disabled Logstash' do
|
|
111
111
|
|
112
112
|
template = get_template(@es, "logstash")
|
113
113
|
expect(template).to have_index_pattern("logstash-*")
|
114
|
-
|
115
|
-
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
116
|
-
end
|
114
|
+
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
117
115
|
end
|
118
116
|
|
119
117
|
context 'with an existing policy that will roll over' do
|
@@ -163,9 +161,7 @@ shared_examples_for 'an ILM disabled Logstash' do
|
|
163
161
|
|
164
162
|
template = get_template(@es, template_name)
|
165
163
|
expect(template).to have_index_pattern("logstash-*")
|
166
|
-
|
167
|
-
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
168
|
-
end
|
164
|
+
expect(get_template_settings(template)['index']['lifecycle']).to be_nil
|
169
165
|
end
|
170
166
|
end
|
171
167
|
end
|
@@ -231,319 +227,307 @@ shared_examples_for 'an Elasticsearch instance that does not support index lifec
|
|
231
227
|
|
232
228
|
end
|
233
229
|
|
234
|
-
|
235
|
-
describe 'Pre-ILM versions of Elasticsearch', :integration => true do
|
236
|
-
it_behaves_like 'an Elasticsearch instance that does not support index lifecycle management'
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
if ESHelper.es_version_satisfies?(">= 6.6")
|
241
|
-
describe 'OSS Elasticsearch', :distribution => 'oss', :integration => true do
|
242
|
-
it_behaves_like 'an Elasticsearch instance that does not support index lifecycle management'
|
243
|
-
end
|
230
|
+
describe 'Elasticsearch has index lifecycle management enabled', :integration => true do
|
244
231
|
|
245
|
-
|
232
|
+
DEFAULT_INTERVAL = '600s'
|
246
233
|
|
247
|
-
|
234
|
+
let (:ilm_enabled) { true }
|
248
235
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
"ilm_enabled" => ilm_enabled,
|
254
|
-
"hosts" => "#{get_host_port()}"
|
255
|
-
}
|
236
|
+
let (:settings) {
|
237
|
+
{
|
238
|
+
"ilm_enabled" => ilm_enabled,
|
239
|
+
"hosts" => "#{get_host_port()}"
|
256
240
|
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
subject(:elasticsearch_output_plugin) { LogStash::Outputs::ElasticSearch.new(settings) }
|
262
|
-
|
263
|
-
before :each do
|
264
|
-
# Delete all templates first.
|
265
|
-
require "elasticsearch"
|
266
|
-
|
267
|
-
# Clean ES of data before we start.
|
268
|
-
@es = get_client
|
269
|
-
clean(@es)
|
270
|
-
# Set the poll interval for lifecycle management to be short so changes get picked up in time.
|
271
|
-
set_cluster_settings(@es, {
|
272
|
-
"persistent" => {
|
273
|
-
"indices.lifecycle.poll_interval" => "1s"
|
274
|
-
}
|
275
|
-
})
|
276
|
-
end
|
241
|
+
}
|
242
|
+
let (:small_max_doc_policy) { max_docs_policy(3) }
|
243
|
+
let (:large_max_doc_policy) { max_docs_policy(1000000) }
|
244
|
+
let (:expected_index) { elasticsearch_output_plugin.default_ilm_rollover_alias }
|
277
245
|
|
278
|
-
|
279
|
-
# Set poll interval back to default
|
280
|
-
set_cluster_settings(@es, {
|
281
|
-
"persistent" => {
|
282
|
-
"indices.lifecycle.poll_interval" => DEFAULT_INTERVAL
|
283
|
-
}
|
284
|
-
})
|
285
|
-
clean(@es)
|
286
|
-
end
|
246
|
+
subject(:elasticsearch_output_plugin) { LogStash::Outputs::ElasticSearch.new(settings) }
|
287
247
|
|
288
|
-
|
289
|
-
|
248
|
+
before :each do
|
249
|
+
# Delete all templates first.
|
250
|
+
require "elasticsearch"
|
290
251
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
end
|
252
|
+
# Clean ES of data before we start.
|
253
|
+
@es = get_client
|
254
|
+
clean(@es)
|
255
|
+
# Set the poll interval for lifecycle management to be short so changes get picked up in time.
|
256
|
+
set_cluster_settings(@es, {
|
257
|
+
"persistent" => {
|
258
|
+
"indices.lifecycle.poll_interval" => "1s"
|
259
|
+
}
|
260
|
+
})
|
261
|
+
end
|
302
262
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
263
|
+
after :each do
|
264
|
+
# Set poll interval back to default
|
265
|
+
set_cluster_settings(@es, {
|
266
|
+
"persistent" => {
|
267
|
+
"indices.lifecycle.poll_interval" => DEFAULT_INTERVAL
|
268
|
+
}
|
269
|
+
})
|
270
|
+
clean(@es)
|
271
|
+
end
|
272
|
+
|
273
|
+
context 'with ilm enabled' do
|
274
|
+
let (:ilm_enabled) { true }
|
309
275
|
|
310
|
-
|
276
|
+
context 'when using the default policy' do
|
277
|
+
context 'with a custom pattern' do
|
278
|
+
let (:settings) { super().merge("ilm_pattern" => "000001")}
|
279
|
+
it 'should create a rollover alias' do
|
311
280
|
expect(@es.indices.exists_alias(name: "logstash")).to be_falsey
|
312
281
|
subject.register
|
313
282
|
sleep(1)
|
314
283
|
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
|
315
|
-
expect(@es.get_alias(name: "logstash")).to include("logstash
|
284
|
+
expect(@es.get_alias(name: "logstash")).to include("logstash-000001")
|
316
285
|
end
|
286
|
+
end
|
317
287
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
LogStash::Event.new("somevalue" => 100),
|
324
|
-
])
|
325
|
-
|
326
|
-
sleep(6)
|
327
|
-
|
328
|
-
subject.multi_receive([
|
329
|
-
LogStash::Event.new("country" => "us"),
|
330
|
-
LogStash::Event.new("country" => "at"),
|
331
|
-
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
332
|
-
])
|
333
|
-
|
334
|
-
@es.indices.refresh
|
335
|
-
|
336
|
-
# Wait or fail until everything's indexed.
|
337
|
-
Stud::try(20.times) do
|
338
|
-
r = @es.search(index: "logstash-*")
|
339
|
-
expect(r).to have_hits(6)
|
340
|
-
end
|
341
|
-
indexes_written = @es.search(index: "logstash-*")['hits']['hits'].each_with_object(Hash.new(0)) do |x, res|
|
342
|
-
index_written = x['_index']
|
343
|
-
res[index_written] += 1
|
344
|
-
end
|
345
|
-
|
346
|
-
expect(indexes_written.count).to eq(1)
|
347
|
-
expect(indexes_written["logstash-#{todays_date}-000001"]).to eq(6)
|
348
|
-
end
|
288
|
+
it 'should install it if it is not present' do
|
289
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
290
|
+
subject.register
|
291
|
+
sleep(1)
|
292
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.not_to raise_error
|
349
293
|
end
|
350
294
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
295
|
+
it 'should create the default rollover alias' do
|
296
|
+
expect(@es.indices.exists_alias(name: "logstash")).to be_falsey
|
297
|
+
subject.register
|
298
|
+
sleep(1)
|
299
|
+
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
|
300
|
+
expect(@es.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001")
|
301
|
+
end
|
355
302
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
303
|
+
it 'should ingest into a single index' do
|
304
|
+
subject.register
|
305
|
+
subject.multi_receive([
|
306
|
+
LogStash::Event.new("message" => "sample message here"),
|
307
|
+
LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
|
308
|
+
LogStash::Event.new("somevalue" => 100),
|
309
|
+
])
|
360
310
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
311
|
+
sleep(6)
|
312
|
+
|
313
|
+
subject.multi_receive([
|
314
|
+
LogStash::Event.new("country" => "us"),
|
315
|
+
LogStash::Event.new("country" => "at"),
|
316
|
+
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
317
|
+
])
|
318
|
+
|
319
|
+
@es.indices.refresh
|
320
|
+
|
321
|
+
# Wait or fail until everything's indexed.
|
322
|
+
Stud::try(20.times) do
|
323
|
+
r = @es.search(index: "logstash-*")
|
324
|
+
expect(r).to have_hits(6)
|
325
|
+
end
|
326
|
+
indexes_written = @es.search(index: "logstash-*")['hits']['hits'].each_with_object(Hash.new(0)) do |x, res|
|
327
|
+
index_written = x['_index']
|
328
|
+
res[index_written] += 1
|
365
329
|
end
|
330
|
+
|
331
|
+
expect(indexes_written.count).to eq(1)
|
332
|
+
expect(indexes_written["logstash-#{todays_date}-000001"]).to eq(6)
|
366
333
|
end
|
334
|
+
end
|
367
335
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
336
|
+
context 'when not using the default policy' do
|
337
|
+
let (:ilm_policy_name) {"logstash-policy-small"}
|
338
|
+
let (:settings) { super().merge("ilm_policy" => ilm_policy_name)}
|
339
|
+
let (:policy) { small_max_doc_policy }
|
372
340
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
341
|
+
before do
|
342
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
343
|
+
put_policy(@es,ilm_policy_name, policy)
|
344
|
+
end
|
377
345
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
end
|
346
|
+
it 'should not install the default policy if it is not used' do
|
347
|
+
subject.register
|
348
|
+
sleep(1)
|
349
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
383
350
|
end
|
351
|
+
end
|
384
352
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
sleep(1)
|
390
|
-
expect(@es.indices.exists_alias(name: expected_index)).to be_truthy
|
391
|
-
expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
|
392
|
-
end
|
353
|
+
context 'when using a time based policy' do
|
354
|
+
let (:ilm_policy_name) {"logstash-policy-time"}
|
355
|
+
let (:settings) { super().merge("ilm_policy" => ilm_policy_name)}
|
356
|
+
let (:policy) { max_age_policy("1d") }
|
393
357
|
|
394
|
-
|
395
|
-
|
396
|
-
|
358
|
+
before do
|
359
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
360
|
+
put_policy(@es,ilm_policy_name, policy)
|
361
|
+
end
|
397
362
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
363
|
+
it 'should not install the default policy if it is not used' do
|
364
|
+
subject.register
|
365
|
+
sleep(1)
|
366
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
367
|
+
end
|
368
|
+
end
|
403
369
|
|
404
|
-
|
370
|
+
context 'with the default template' do
|
371
|
+
it 'should create the rollover alias' do
|
372
|
+
expect(@es.indices.exists_alias(name: expected_index)).to be_falsey
|
373
|
+
subject.register
|
374
|
+
sleep(1)
|
375
|
+
expect(@es.indices.exists_alias(name: expected_index)).to be_truthy
|
376
|
+
expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
|
405
377
|
end
|
406
378
|
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
411
|
-
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
412
|
-
else
|
413
|
-
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
414
|
-
end
|
379
|
+
it 'should write the ILM settings into the template' do
|
380
|
+
subject.register
|
381
|
+
sleep(1)
|
415
382
|
|
416
|
-
|
417
|
-
|
383
|
+
template = get_template(@es, "logstash")
|
384
|
+
expect(template).to have_index_pattern("logstash-*")
|
385
|
+
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq("logstash-policy")
|
386
|
+
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq("logstash")
|
387
|
+
end
|
418
388
|
|
419
|
-
|
420
|
-
|
421
|
-
sleep(1)
|
389
|
+
it_behaves_like 'an ILM enabled Logstash'
|
390
|
+
end
|
422
391
|
|
423
|
-
|
424
|
-
|
425
|
-
|
392
|
+
context 'with a set index and a custom index pattern' do
|
393
|
+
if ESHelper.es_version_satisfies?(">= 8.0")
|
394
|
+
let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
|
395
|
+
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
396
|
+
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
397
|
+
else
|
398
|
+
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
426
399
|
end
|
427
400
|
|
401
|
+
let (:settings) { super().merge("template" => template,
|
402
|
+
"index" => "overwrite-4")}
|
428
403
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
let(:expected_index) { index }
|
433
|
-
let (:settings) { super().merge("ilm_policy" => ilm_policy_name,
|
434
|
-
"template" => template,
|
435
|
-
"ilm_rollover_alias" => ilm_rollover_alias)}
|
404
|
+
it 'should not overwrite the index patterns' do
|
405
|
+
subject.register
|
406
|
+
sleep(1)
|
436
407
|
|
408
|
+
template = get_template(@es, "logstash")
|
409
|
+
expect(template).to have_index_pattern("overwrite-*")
|
410
|
+
end
|
411
|
+
end
|
437
412
|
|
438
|
-
if ESHelper.es_version_satisfies?(">= 8.0")
|
439
|
-
let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
|
440
|
-
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
441
|
-
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
442
|
-
else
|
443
|
-
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
444
|
-
end
|
445
|
-
let (:ilm_enabled) { true }
|
446
|
-
let (:ilm_policy_name) { "logstash-policy-custom-policy" }
|
447
|
-
let (:policy) { small_max_doc_policy }
|
448
413
|
|
449
|
-
|
450
|
-
|
451
|
-
|
414
|
+
context 'with a custom template' do
|
415
|
+
let (:ilm_rollover_alias) { "logstash_the_cat_in_the_hat" }
|
416
|
+
let (:index) { ilm_rollover_alias }
|
417
|
+
let(:expected_index) { index }
|
418
|
+
let (:settings) { super().merge("ilm_policy" => ilm_policy_name,
|
419
|
+
"template" => template,
|
420
|
+
"ilm_rollover_alias" => ilm_rollover_alias)}
|
452
421
|
|
453
|
-
it_behaves_like 'an ILM enabled Logstash'
|
454
422
|
|
455
|
-
|
423
|
+
if ESHelper.es_version_satisfies?(">= 8.0")
|
424
|
+
let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
|
425
|
+
elsif ESHelper.es_version_satisfies?(">= 7.0")
|
426
|
+
let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
|
427
|
+
else
|
428
|
+
let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
|
429
|
+
end
|
430
|
+
let (:ilm_enabled) { true }
|
431
|
+
let (:ilm_policy_name) { "logstash-policy-custom-policy" }
|
432
|
+
let (:policy) { small_max_doc_policy }
|
433
|
+
|
434
|
+
before :each do
|
435
|
+
put_policy(@es,ilm_policy_name, policy)
|
436
|
+
end
|
437
|
+
|
438
|
+
it_behaves_like 'an ILM enabled Logstash'
|
439
|
+
|
440
|
+
it 'should create the rollover alias' do
|
441
|
+
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey
|
442
|
+
subject.register
|
443
|
+
sleep(1)
|
444
|
+
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
445
|
+
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
|
446
|
+
end
|
447
|
+
|
448
|
+
context 'when the custom rollover alias already exists' do
|
449
|
+
it 'should ignore the already exists error' do
|
456
450
|
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey
|
451
|
+
put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias)
|
452
|
+
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
457
453
|
subject.register
|
458
454
|
sleep(1)
|
459
|
-
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
460
455
|
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
|
461
456
|
end
|
462
457
|
|
463
|
-
|
464
|
-
it 'should ignore the already exists error' do
|
465
|
-
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey
|
466
|
-
put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias)
|
467
|
-
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
468
|
-
subject.register
|
469
|
-
sleep(1)
|
470
|
-
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
|
471
|
-
end
|
458
|
+
end
|
472
459
|
|
473
|
-
|
460
|
+
it 'should write the ILM settings into the template' do
|
461
|
+
subject.register
|
462
|
+
sleep(1)
|
463
|
+
|
464
|
+
template = get_template(@es, ilm_rollover_alias)
|
465
|
+
expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
|
466
|
+
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
|
467
|
+
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
|
468
|
+
end
|
469
|
+
|
470
|
+
context 'with a different template_name' do
|
471
|
+
let (:template_name) { "logstash_custom_template_name" }
|
472
|
+
let (:settings) { super().merge('template_name' => template_name)}
|
473
|
+
|
474
|
+
it_behaves_like 'an ILM enabled Logstash'
|
474
475
|
|
475
476
|
it 'should write the ILM settings into the template' do
|
476
477
|
subject.register
|
477
478
|
sleep(1)
|
478
|
-
|
479
|
-
template = get_template(@es, ilm_rollover_alias)
|
479
|
+
template = get_template(@es, template_name)
|
480
480
|
expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
|
481
481
|
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
|
482
482
|
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
|
483
483
|
end
|
484
|
-
|
485
|
-
context 'with a different template_name' do
|
486
|
-
let (:template_name) { "logstash_custom_template_name" }
|
487
|
-
let (:settings) { super().merge('template_name' => template_name)}
|
488
|
-
|
489
|
-
it_behaves_like 'an ILM enabled Logstash'
|
490
|
-
|
491
|
-
it 'should write the ILM settings into the template' do
|
492
|
-
subject.register
|
493
|
-
sleep(1)
|
494
|
-
template = get_template(@es, template_name)
|
495
|
-
expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
|
496
|
-
expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
|
497
|
-
expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
484
|
end
|
485
|
+
|
502
486
|
end
|
487
|
+
end
|
503
488
|
|
504
|
-
|
505
|
-
|
489
|
+
context 'when ilm_enabled is set to "auto"' do
|
490
|
+
let (:ilm_enabled) { 'auto' }
|
506
491
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
end
|
492
|
+
if ESHelper.es_version_satisfies?(">=7.0")
|
493
|
+
context 'when Elasticsearch is version 7 or above' do
|
494
|
+
it_behaves_like 'an ILM enabled Logstash'
|
511
495
|
end
|
496
|
+
end
|
512
497
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
end
|
498
|
+
if ESHelper.es_version_satisfies?('< 7.0')
|
499
|
+
context 'when Elasticsearch is version 7 or below' do
|
500
|
+
it_behaves_like 'an ILM disabled Logstash'
|
517
501
|
end
|
518
502
|
end
|
503
|
+
end
|
519
504
|
|
520
|
-
|
521
|
-
|
505
|
+
context 'when ilm_enabled is the default' do
|
506
|
+
let (:settings) { super().tap{|x|x.delete('ilm_enabled')}}
|
522
507
|
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
end
|
508
|
+
if ESHelper.es_version_satisfies?(">=7.0")
|
509
|
+
context 'when Elasticsearch is version 7 or above' do
|
510
|
+
it_behaves_like 'an ILM enabled Logstash'
|
527
511
|
end
|
512
|
+
end
|
528
513
|
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
end
|
514
|
+
if ESHelper.es_version_satisfies?('< 7.0')
|
515
|
+
context 'when Elasticsearch is version 7 or below' do
|
516
|
+
it_behaves_like 'an ILM disabled Logstash'
|
533
517
|
end
|
534
518
|
end
|
519
|
+
end
|
535
520
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
it_behaves_like 'an ILM disabled Logstash'
|
540
|
-
end
|
521
|
+
context 'with ilm disabled' do
|
522
|
+
let (:settings) { super().merge('ilm_enabled' => false )}
|
541
523
|
|
542
|
-
|
543
|
-
|
524
|
+
it_behaves_like 'an ILM disabled Logstash'
|
525
|
+
end
|
544
526
|
|
545
|
-
|
546
|
-
|
527
|
+
context 'with ilm disabled using a string' do
|
528
|
+
let (:settings) { super().merge('ilm_enabled' => 'false' )}
|
547
529
|
|
530
|
+
it_behaves_like 'an ILM disabled Logstash'
|
548
531
|
end
|
549
|
-
|
532
|
+
|
533
|
+
end
|