logstash-output-elasticsearch 11.22.13-java → 12.0.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 +11 -8
- data/docs/index.asciidoc +19 -106
- data/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb +4 -1
- data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +22 -11
- data/lib/logstash/outputs/elasticsearch/http_client.rb +29 -42
- data/lib/logstash/outputs/elasticsearch.rb +0 -47
- data/lib/logstash/plugin_mixins/elasticsearch/api_configs.rb +12 -28
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/es_spec_helper.rb +22 -34
- data/spec/fixtures/test_certs/GENERATED_AT +1 -1
- data/spec/fixtures/test_certs/ca.crt +27 -30
- data/spec/fixtures/test_certs/ca.der.sha256 +1 -1
- data/spec/fixtures/test_certs/renew.sh +3 -2
- data/spec/fixtures/test_certs/test.crt +28 -29
- data/spec/fixtures/test_certs/test.der.sha256 +1 -1
- data/spec/fixtures/test_certs/test.p12 +0 -0
- data/spec/integration/outputs/compressed_indexing_spec.rb +1 -3
- data/spec/integration/outputs/delete_spec.rb +4 -4
- data/spec/integration/outputs/ilm_spec.rb +12 -18
- data/spec/integration/outputs/index_spec.rb +2 -12
- data/spec/integration/outputs/index_version_spec.rb +7 -7
- data/spec/integration/outputs/painless_update_spec.rb +10 -11
- data/spec/integration/outputs/unsupported_actions_spec.rb +10 -15
- data/spec/integration/outputs/update_spec.rb +9 -11
- data/spec/spec_helper.rb +0 -8
- data/spec/support/elasticsearch/api/actions/get_alias.rb +18 -0
- data/spec/support/elasticsearch/api/actions/put_alias.rb +24 -0
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +0 -77
- data/spec/unit/outputs/elasticsearch_spec.rb +2 -82
- data/spec/unit/outputs/elasticsearch_ssl_spec.rb +22 -0
- data/spec/unit/outputs/error_whitelist_spec.rb +1 -0
- metadata +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VRiY6jPx+r7J9I5kSS1gwr/e3zHJHa79ijMB1SSIswQUmgSMkwGh
|
26
|
+
sNyDNI9ZxgJan3v7kVargMt2LiNcXvVyTzPSYSXcY7SoebfpMprVIG7vZ9TZf+Uu
|
27
|
+
FQeOfxdLFuGTnpFrYmvOD3OIKfODlY5t+TNICg7A3eTUXeJPcdBBnuVCiQU6TCB5
|
28
|
+
H+69K5w54Q6a70sHZU1IWsGT8XtbUizPNQky+LAFsE/5oUnCqtypeEu4srcZK53x
|
32
29
|
-----END CERTIFICATE-----
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
8b23238088af65cbae6ee9c23821068d896ec1dad081e2a1035ff70866943247
|
@@ -3,7 +3,8 @@
|
|
3
3
|
set -e
|
4
4
|
cd "$(dirname "$0")"
|
5
5
|
|
6
|
-
openssl
|
6
|
+
openssl x509 -x509toreq -in ca.crt -signkey ca.key -out ca.csr
|
7
|
+
openssl x509 -req -days 365 -in ca.csr -set_serial 0x01 -signkey ca.key -out ca.crt && rm ca.csr
|
7
8
|
openssl x509 -in ca.crt -outform der | sha256sum | awk '{print $1}' > ca.der.sha256
|
8
9
|
|
9
10
|
openssl x509 -x509toreq -in test.crt -signkey test.key -out test.csr
|
@@ -12,4 +13,4 @@ openssl x509 -in test.crt -outform der | sha256sum | awk '{print $1}' > test.der
|
|
12
13
|
openssl pkcs12 -export -inkey test.key -in test.crt -passout "pass:1234567890" -out test.p12
|
13
14
|
|
14
15
|
# output ISO8601 timestamp to file
|
15
|
-
date -Iseconds > GENERATED_AT
|
16
|
+
date -Iseconds > GENERATED_AT
|
@@ -1,31 +1,30 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
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1 +1 @@
|
|
1
|
-
|
1
|
+
80329a197063dea8cf7905d10d221648bbdbc05b8fb1d4c2e384b831bc6590df
|
Binary file
|
@@ -36,9 +36,7 @@ end
|
|
36
36
|
{
|
37
37
|
"Content-Encoding" => "gzip",
|
38
38
|
"Content-Type" => "application/json",
|
39
|
-
'x-elastic-product-origin' => 'logstash-output-elasticsearch'
|
40
|
-
'X-Elastic-Event-Count' => anything,
|
41
|
-
'X-Elastic-Uncompressed-Request-Length' => anything,
|
39
|
+
'x-elastic-product-origin' => 'logstash-output-elasticsearch'
|
42
40
|
}
|
43
41
|
}
|
44
42
|
|
@@ -39,12 +39,12 @@ describe "Versioned delete", :integration => true do
|
|
39
39
|
it "should ignore non-monotonic external version updates" do
|
40
40
|
id = "ev2"
|
41
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', :id => id, :refresh => true)
|
42
|
+
r = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
43
43
|
expect(r['_version']).to eq(99)
|
44
44
|
expect(r['_source']['message']).to eq('foo')
|
45
45
|
|
46
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', :id => id, :refresh => true)
|
47
|
+
r2 = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
48
48
|
expect(r2['_version']).to eq(99)
|
49
49
|
expect(r2['_source']['message']).to eq('foo')
|
50
50
|
end
|
@@ -52,12 +52,12 @@ describe "Versioned delete", :integration => true do
|
|
52
52
|
it "should commit monotonic external version updates" do
|
53
53
|
id = "ev3"
|
54
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', :id => id, :refresh => true)
|
55
|
+
r = es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true)
|
56
56
|
expect(r['_version']).to eq(99)
|
57
57
|
expect(r['_source']['message']).to eq('foo')
|
58
58
|
|
59
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', :id => id, :refresh => true) }.to raise_error(
|
60
|
+
expect { es.get(:index => 'logstash-delete', :type => doc_type, :id => id, :refresh => true) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -102,7 +102,7 @@ shared_examples_for 'an ILM disabled Logstash' do
|
|
102
102
|
it 'should not install the default policy' do
|
103
103
|
subject.register
|
104
104
|
sleep(1)
|
105
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
105
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'should not write the ILM settings into the template' do
|
@@ -282,12 +282,12 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
282
282
|
subject.register
|
283
283
|
sleep(1)
|
284
284
|
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
|
285
|
-
expect(@es.
|
285
|
+
expect(@es.get_alias(name: "logstash")).to include("logstash-000001")
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
289
|
it 'should install it if it is not present' do
|
290
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
290
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
291
291
|
subject.register
|
292
292
|
sleep(1)
|
293
293
|
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.not_to raise_error
|
@@ -298,7 +298,7 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
298
298
|
subject.register
|
299
299
|
sleep(1)
|
300
300
|
expect(@es.indices.exists_alias(name: "logstash")).to be_truthy
|
301
|
-
expect(@es.
|
301
|
+
expect(@es.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001")
|
302
302
|
end
|
303
303
|
|
304
304
|
it 'should ingest into a single index' do
|
@@ -340,14 +340,14 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
340
340
|
let (:policy) { small_max_doc_policy }
|
341
341
|
|
342
342
|
before do
|
343
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
343
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
344
344
|
put_policy(@es,ilm_policy_name, policy)
|
345
345
|
end
|
346
346
|
|
347
347
|
it 'should not install the default policy if it is not used' do
|
348
348
|
subject.register
|
349
349
|
sleep(1)
|
350
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
350
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
@@ -357,14 +357,14 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
357
357
|
let (:policy) { max_age_policy("1d") }
|
358
358
|
|
359
359
|
before do
|
360
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
360
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
361
361
|
put_policy(@es,ilm_policy_name, policy)
|
362
362
|
end
|
363
363
|
|
364
364
|
it 'should not install the default policy if it is not used' do
|
365
365
|
subject.register
|
366
366
|
sleep(1)
|
367
|
-
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(
|
367
|
+
expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
@@ -374,7 +374,7 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
374
374
|
subject.register
|
375
375
|
sleep(1)
|
376
376
|
expect(@es.indices.exists_alias(name: expected_index)).to be_truthy
|
377
|
-
expect(@es.
|
377
|
+
expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
|
378
378
|
end
|
379
379
|
|
380
380
|
it 'should write the ILM settings into the template' do
|
@@ -443,18 +443,17 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
443
443
|
subject.register
|
444
444
|
sleep(1)
|
445
445
|
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
446
|
-
expect(@es.
|
446
|
+
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
|
447
447
|
end
|
448
448
|
|
449
449
|
context 'when the custom rollover alias already exists' do
|
450
450
|
it 'should ignore the already exists error' do
|
451
451
|
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey
|
452
|
-
@es
|
453
|
-
@es.indices.put_alias(name: ilm_rollover_alias, index: "#{ilm_rollover_alias}-#{todays_date}-000001")
|
452
|
+
put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias)
|
454
453
|
expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
|
455
454
|
subject.register
|
456
455
|
sleep(1)
|
457
|
-
expect(@es.
|
456
|
+
expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
|
458
457
|
end
|
459
458
|
|
460
459
|
end
|
@@ -533,8 +532,3 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
|
|
533
532
|
end
|
534
533
|
|
535
534
|
end
|
536
|
-
|
537
|
-
def get_expected_error_class
|
538
|
-
return Elastic::Transport::Transport::Errors::NotFound if elastic_ruby_v8_client_available?
|
539
|
-
Elasticsearch::Transport::Transport::Errors::NotFound
|
540
|
-
end
|
@@ -215,22 +215,12 @@ describe "indexing" do
|
|
215
215
|
|
216
216
|
it "sets the correct content-type header" do
|
217
217
|
expected_manticore_opts = {
|
218
|
-
:headers => {
|
219
|
-
"Content-Type" => "application/json",
|
220
|
-
'x-elastic-product-origin' => 'logstash-output-elasticsearch',
|
221
|
-
'X-Elastic-Event-Count' => anything,
|
222
|
-
'X-Elastic-Uncompressed-Request-Length' => anything
|
223
|
-
},
|
218
|
+
:headers => {"Content-Type" => "application/json", 'x-elastic-product-origin' => 'logstash-output-elasticsearch'},
|
224
219
|
:body => anything
|
225
220
|
}
|
226
221
|
if secure
|
227
222
|
expected_manticore_opts = {
|
228
|
-
:headers => {
|
229
|
-
"Content-Type" => "application/json",
|
230
|
-
'x-elastic-product-origin' => 'logstash-output-elasticsearch',
|
231
|
-
'X-Elastic-Event-Count' => anything,
|
232
|
-
'X-Elastic-Uncompressed-Request-Length' => anything
|
233
|
-
},
|
223
|
+
:headers => {"Content-Type" => "application/json", 'x-elastic-product-origin' => 'logstash-output-elasticsearch'},
|
234
224
|
:body => anything,
|
235
225
|
:auth => {
|
236
226
|
:user => user,
|
@@ -36,11 +36,11 @@ describe "Versioned indexing", :integration => true do
|
|
36
36
|
|
37
37
|
it "should default to ES version" do
|
38
38
|
subject.multi_receive([LogStash::Event.new("my_id" => "123", "message" => "foo")])
|
39
|
-
r = es.get(:index => 'logstash-index', :id =>
|
39
|
+
r = es.get(:index => 'logstash-index', :type => doc_type, :id => "123", :refresh => true)
|
40
40
|
expect(r["_version"]).to eq(1)
|
41
41
|
expect(r["_source"]["message"]).to eq('foo')
|
42
42
|
subject.multi_receive([LogStash::Event.new("my_id" => "123", "message" => "foobar")])
|
43
|
-
r2 = es.get(:index => 'logstash-index', :id =>
|
43
|
+
r2 = es.get(:index => 'logstash-index', :type => doc_type, :id => "123", :refresh => true)
|
44
44
|
expect(r2["_version"]).to eq(2)
|
45
45
|
expect(r2["_source"]["message"]).to eq('foobar')
|
46
46
|
end
|
@@ -63,7 +63,7 @@ describe "Versioned indexing", :integration => true do
|
|
63
63
|
it "should respect the external version" do
|
64
64
|
id = "ev1"
|
65
65
|
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_version" => "99", "message" => "foo")])
|
66
|
-
r = es.get(:index => 'logstash-index', :id => id, :refresh => true)
|
66
|
+
r = es.get(:index => 'logstash-index', :type => doc_type, :id => id, :refresh => true)
|
67
67
|
expect(r["_version"]).to eq(99)
|
68
68
|
expect(r["_source"]["message"]).to eq('foo')
|
69
69
|
end
|
@@ -71,12 +71,12 @@ describe "Versioned indexing", :integration => true do
|
|
71
71
|
it "should ignore non-monotonic external version updates" do
|
72
72
|
id = "ev2"
|
73
73
|
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_version" => "99", "message" => "foo")])
|
74
|
-
r = es.get(:index => 'logstash-index', :id => id, :refresh => true)
|
74
|
+
r = es.get(:index => 'logstash-index', :type => doc_type, :id => id, :refresh => true)
|
75
75
|
expect(r["_version"]).to eq(99)
|
76
76
|
expect(r["_source"]["message"]).to eq('foo')
|
77
77
|
|
78
78
|
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_version" => "98", "message" => "foo")])
|
79
|
-
r2 = es.get(:index => 'logstash-index', :id => id, :refresh => true)
|
79
|
+
r2 = es.get(:index => 'logstash-index', :type => doc_type, :id => id, :refresh => true)
|
80
80
|
expect(r2["_version"]).to eq(99)
|
81
81
|
expect(r2["_source"]["message"]).to eq('foo')
|
82
82
|
end
|
@@ -84,12 +84,12 @@ describe "Versioned indexing", :integration => true do
|
|
84
84
|
it "should commit monotonic external version updates" do
|
85
85
|
id = "ev3"
|
86
86
|
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_version" => "99", "message" => "foo")])
|
87
|
-
r = es.get(:index => 'logstash-index', :id => id, :refresh => true)
|
87
|
+
r = es.get(:index => 'logstash-index', :type => doc_type, :id => id, :refresh => true)
|
88
88
|
expect(r["_version"]).to eq(99)
|
89
89
|
expect(r["_source"]["message"]).to eq('foo')
|
90
90
|
|
91
91
|
subject.multi_receive([LogStash::Event.new("my_id" => id, "my_version" => "100", "message" => "foo")])
|
92
|
-
r2 = es.get(:index => 'logstash-index', :id => id, :refresh => true)
|
92
|
+
r2 = es.get(:index => 'logstash-index', :type => doc_type, :id => id, :refresh => true)
|
93
93
|
expect(r2["_version"]).to eq(100)
|
94
94
|
expect(r2["_source"]["message"]).to eq('foo')
|
95
95
|
end
|
@@ -22,12 +22,11 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
22
22
|
# This can fail if there are no indexes, ignore failure.
|
23
23
|
@es.indices.delete(:index => "*") rescue nil
|
24
24
|
@es.index(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
})
|
25
|
+
:index => 'logstash-update',
|
26
|
+
:type => doc_type,
|
27
|
+
:id => "123",
|
28
|
+
:body => { :message => 'Test', :counter => 1 }
|
29
|
+
)
|
31
30
|
@es.indices.refresh
|
32
31
|
end
|
33
32
|
|
@@ -47,7 +46,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
47
46
|
subject = get_es_output(plugin_parameters)
|
48
47
|
subject.register
|
49
48
|
subject.multi_receive([LogStash::Event.new("count" => 4 )])
|
50
|
-
r = @es.get(:index => 'logstash-update', :id => "123", :refresh => true)
|
49
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
|
51
50
|
expect(r["_source"]["counter"]).to eq(5)
|
52
51
|
end
|
53
52
|
end
|
@@ -58,7 +57,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
58
57
|
subject = get_es_output({ 'document_id' => "456", 'upsert' => '{"message": "upsert message"}' })
|
59
58
|
subject.register
|
60
59
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
61
|
-
r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
|
60
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
62
61
|
expect(r["_source"]["message"]).to eq('upsert message')
|
63
62
|
end
|
64
63
|
|
@@ -66,7 +65,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
66
65
|
subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true })
|
67
66
|
subject.register
|
68
67
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
69
|
-
r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
|
68
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
70
69
|
expect(r["_source"]["message"]).to eq('sample message here')
|
71
70
|
end
|
72
71
|
|
@@ -83,7 +82,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
83
82
|
subject.register
|
84
83
|
|
85
84
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
86
|
-
r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
|
85
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
87
86
|
expect(r["_source"]["message"]).to eq('upsert message')
|
88
87
|
end
|
89
88
|
|
@@ -92,7 +91,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
|
|
92
91
|
subject.register
|
93
92
|
subject.multi_receive([LogStash::Event.new("counter" => 1)])
|
94
93
|
@es.indices.refresh
|
95
|
-
r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
|
94
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
96
95
|
expect(r["_source"]["counter"]).to eq(1)
|
97
96
|
end
|
98
97
|
end
|
@@ -27,21 +27,16 @@ describe "Unsupported actions testing...", :integration => true do
|
|
27
27
|
@es.indices.delete(:index => "*") rescue nil
|
28
28
|
# index single doc for update purpose
|
29
29
|
@es.index(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:refresh => true
|
35
|
-
}
|
30
|
+
:index => INDEX,
|
31
|
+
:type => doc_type,
|
32
|
+
:id => "2",
|
33
|
+
:body => { :message => 'Test to doc indexing', :counter => 1 }
|
36
34
|
)
|
37
|
-
|
38
35
|
@es.index(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
:refresh => true
|
44
|
-
}
|
36
|
+
:index => INDEX,
|
37
|
+
:type => doc_type,
|
38
|
+
:id => "3",
|
39
|
+
:body => { :message => 'Test to doc deletion', :counter => 2 }
|
45
40
|
)
|
46
41
|
@es.indices.refresh
|
47
42
|
end
|
@@ -68,12 +63,12 @@ describe "Unsupported actions testing...", :integration => true do
|
|
68
63
|
rejected_events = events.select { |event| !index_or_update.call(event) }
|
69
64
|
|
70
65
|
indexed_events.each do |event|
|
71
|
-
response = @es.get(:index => INDEX, :id => event.get("doc_id"), :refresh => true)
|
66
|
+
response = @es.get(:index => INDEX, :type => doc_type, :id => event.get("doc_id"), :refresh => true)
|
72
67
|
expect(response['_source']['message']).to eq(event.get("message"))
|
73
68
|
end
|
74
69
|
|
75
70
|
rejected_events.each do |event|
|
76
|
-
expect {@es.get(:index => INDEX, :id => event.get("doc_id"), :refresh => true)}.to raise_error(
|
71
|
+
expect {@es.get(:index => INDEX, :type => doc_type, :id => event.get("doc_id"), :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
77
72
|
end
|
78
73
|
end
|
79
74
|
end
|
@@ -22,12 +22,10 @@ describe "Update actions without scripts", :integration => true do
|
|
22
22
|
# This can fail if there are no indexes, ignore failure.
|
23
23
|
@es.indices.delete(:index => "*") rescue nil
|
24
24
|
@es.index(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:refresh => true
|
30
|
-
}
|
25
|
+
:index => 'logstash-update',
|
26
|
+
:type => doc_type,
|
27
|
+
:id => "123",
|
28
|
+
:body => { :message => 'Test', :counter => 1 }
|
31
29
|
)
|
32
30
|
@es.indices.refresh
|
33
31
|
end
|
@@ -42,14 +40,14 @@ describe "Update actions without scripts", :integration => true do
|
|
42
40
|
subject = get_es_output({ 'document_id' => "456" } )
|
43
41
|
subject.register
|
44
42
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
45
|
-
expect {@es.get(:index => 'logstash-update', :id =>
|
43
|
+
expect {@es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
46
44
|
end
|
47
45
|
|
48
46
|
it "should update existing document" do
|
49
47
|
subject = get_es_output({ 'document_id' => "123" })
|
50
48
|
subject.register
|
51
49
|
subject.multi_receive([LogStash::Event.new("message" => "updated message here")])
|
52
|
-
r = @es.get(:index => 'logstash-update', :id =>
|
50
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
|
53
51
|
expect(r["_source"]["message"]).to eq('updated message here')
|
54
52
|
end
|
55
53
|
|
@@ -59,7 +57,7 @@ describe "Update actions without scripts", :integration => true do
|
|
59
57
|
subject = get_es_output({ 'document_id' => "123" })
|
60
58
|
subject.register
|
61
59
|
subject.multi_receive([LogStash::Event.new("data" => "updated message here", "message" => "foo")])
|
62
|
-
r = @es.get(:index => 'logstash-update', :id =>
|
60
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
|
63
61
|
expect(r["_source"]["data"]).to eq('updated message here')
|
64
62
|
expect(r["_source"]["message"]).to eq('foo')
|
65
63
|
end
|
@@ -96,7 +94,7 @@ describe "Update actions without scripts", :integration => true do
|
|
96
94
|
subject = get_es_output({ 'document_id' => "456", 'upsert' => '{"message": "upsert message"}' })
|
97
95
|
subject.register
|
98
96
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
99
|
-
r = @es.get(:index => 'logstash-update', :id =>
|
97
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
100
98
|
expect(r["_source"]["message"]).to eq('upsert message')
|
101
99
|
end
|
102
100
|
|
@@ -104,7 +102,7 @@ describe "Update actions without scripts", :integration => true do
|
|
104
102
|
subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true })
|
105
103
|
subject.register
|
106
104
|
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
107
|
-
r = @es.get(:index => 'logstash-update', :id =>
|
105
|
+
r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
|
108
106
|
expect(r["_source"]["message"]).to eq('sample message here')
|
109
107
|
end
|
110
108
|
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,3 @@ end
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
config.include LogStash::Outputs::ElasticSearch::SpecHelper
|
10
10
|
end
|
11
|
-
|
12
|
-
# remove once plugin starts consuming elasticsearch-ruby v8 client
|
13
|
-
def elastic_ruby_v8_client_available?
|
14
|
-
Elasticsearch::Transport
|
15
|
-
false
|
16
|
-
rescue NameError # NameError: uninitialized constant Elasticsearch::Transport if Elastic Ruby client is not available
|
17
|
-
true
|
18
|
-
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2
|
+
# or more contributor license agreements. Licensed under the Elastic License;
|
3
|
+
# you may not use this file except in compliance with the Elastic License.
|
4
|
+
|
5
|
+
module Elasticsearch
|
6
|
+
module API
|
7
|
+
module Actions
|
8
|
+
|
9
|
+
# Retrieve the list of index lifecycle management policies
|
10
|
+
def get_alias(arguments={})
|
11
|
+
method = HTTP_GET
|
12
|
+
path = Utils.__pathify '_alias', Utils.__escape(arguments[:name])
|
13
|
+
params = {}
|
14
|
+
perform_request(method, path, params, nil).body
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2
|
+
# or more contributor license agreements. Licensed under the Elastic License;
|
3
|
+
# you may not use this file except in compliance with the Elastic License.
|
4
|
+
|
5
|
+
module Elasticsearch
|
6
|
+
module API
|
7
|
+
module Actions
|
8
|
+
|
9
|
+
# @option arguments [String] :name The name of the alias (*Required*)
|
10
|
+
# @option arguments [Hash] :The alias definition(*Required*)
|
11
|
+
|
12
|
+
def put_alias(arguments={})
|
13
|
+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
|
14
|
+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
15
|
+
method = HTTP_PUT
|
16
|
+
path = Utils.__pathify Utils.__escape(arguments[:name])
|
17
|
+
|
18
|
+
params = Utils.__validate_and_extract_params arguments
|
19
|
+
body = arguments[:body]
|
20
|
+
perform_request(method, path, params, body.to_json).body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|