logstash-output-elasticsearch 12.0.2-java → 12.0.3-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54628286a20d2e1aef727ec2bb59ff32b0e56458451743ac36b1e30cc072328c
4
- data.tar.gz: a9e90e4192ef149fa85fce4caa3aa720b6f9b01df1f29885bdeb3883619c7ca0
3
+ metadata.gz: f5b6e330ff67352acd72041d917885768b47d2808bce5d116e555d61eb89e6b5
4
+ data.tar.gz: f450de9ab1542645aea2072702252d0c1ecba00110ebbf035571319e83dd1468
5
5
  SHA512:
6
- metadata.gz: e063a4a3796e8955a1d6ee1dc17f599e5fd3142f61e35956371ae43a2b47496180a687fb232e3abccaeab8fde646c67ba07a4191b90cd10bc119f9c7c9f35fe6
7
- data.tar.gz: d664044b3ef0c9132c65a3af99bf55f84c1b3e59785078a4c46476e9b42bda542f3d94c0c4fb73b1106cae1f90cce144296e98abd86f8edc61de710a4a1dab9c
6
+ metadata.gz: 14a820573d8d16ea69ad91e281c36a0c4c4aac863053596a50c72b065803f7e2afa3f849f662d185e2baebd089605c8dc77d445985ddf7a43afceb7e9d20b1be
7
+ data.tar.gz: 58b5159e08b621602b892f3ea7d7911f47f1236144e35980582e6dda511edd81350d850c3ae73abde6cd298c664f737ba0a64de61a5c35a963e40bec28f692f2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 12.0.3
2
+ - Demote connection log entry from WARN to INFO connection during register phase [#1211](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1211)
3
+
1
4
  ## 12.0.2
2
5
  - Properly handle http code 413 (Payload Too Large) [#1199](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1199)
3
6
 
@@ -286,7 +286,11 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
286
286
  raise root_bad_code_err if root_bad_code_err
287
287
 
288
288
  # If no exception was raised it must have succeeded!
289
- logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
289
+ if register_phase
290
+ logger.info("Connected to ES instance", url: url.sanitized.to_s)
291
+ else
292
+ logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
293
+ end
290
294
 
291
295
  # We check its ES version
292
296
  es_version, build_flavor = parse_es_version(root_response)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '12.0.2'
3
+ s.version = '12.0.3'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -1,15 +1,18 @@
1
1
  require_relative './spec_helper'
2
2
 
3
3
  require 'elasticsearch'
4
- require_relative "support/elasticsearch/api/actions/delete_ilm_policy"
5
- require_relative "support/elasticsearch/api/actions/get_alias"
6
- require_relative "support/elasticsearch/api/actions/put_alias"
7
- require_relative "support/elasticsearch/api/actions/get_ilm_policy"
8
- require_relative "support/elasticsearch/api/actions/put_ilm_policy"
9
4
 
10
5
  require 'json'
11
6
  require 'cabin'
12
7
 
8
+ # remove this condition and support package once plugin starts consuming elasticsearch-ruby v8 client
9
+ # in elasticsearch-ruby v7, ILM APIs were in a separate xpack gem, now directly available
10
+ unless elastic_ruby_v8_client_available?
11
+ require_relative "support/elasticsearch/api/actions/delete_ilm_policy"
12
+ require_relative "support/elasticsearch/api/actions/get_ilm_policy"
13
+ require_relative "support/elasticsearch/api/actions/put_ilm_policy"
14
+ end
15
+
13
16
  module ESHelper
14
17
  def get_host_port
15
18
  if ENV["INTEGRATION"] == "true"
@@ -20,8 +23,12 @@ module ESHelper
20
23
  end
21
24
 
22
25
  def get_client
23
- Elasticsearch::Client.new(:hosts => [get_host_port]).tap do |client|
24
- allow(client).to receive(:verify_elasticsearch).and_return(true) # bypass client side version checking
26
+ if elastic_ruby_v8_client_available?
27
+ Elasticsearch::Client.new(:hosts => [get_host_port])
28
+ else
29
+ Elasticsearch::Client.new(:hosts => [get_host_port]).tap do |client|
30
+ allow(client).to receive(:verify_elasticsearch).and_return(true) # bypass client side version checking
31
+ end
25
32
  end
26
33
  end
27
34
 
@@ -126,31 +133,36 @@ module ESHelper
126
133
  end
127
134
 
128
135
  def get_policy(client, policy_name)
129
- client.get_ilm_policy(name: policy_name)
136
+ if elastic_ruby_v8_client_available?
137
+ client.index_lifecycle_management.get_lifecycle(policy: policy_name)
138
+ else
139
+ client.get_ilm_policy(name: policy_name)
140
+ end
130
141
  end
131
142
 
132
143
  def put_policy(client, policy_name, policy)
133
- client.put_ilm_policy({:name => policy_name, :body=> policy})
134
- end
135
-
136
- def put_alias(client, the_alias, index)
137
- body = {
138
- "aliases" => {
139
- index => {
140
- "is_write_index"=> true
141
- }
142
- }
143
- }
144
- client.put_alias({name: the_alias, body: body})
144
+ if elastic_ruby_v8_client_available?
145
+ client.index_lifecycle_management.put_lifecycle({:policy => policy_name, :body=> policy})
146
+ else
147
+ client.put_ilm_policy({:name => policy_name, :body=> policy})
148
+ end
145
149
  end
146
150
 
147
151
  def clean_ilm(client)
148
- client.get_ilm_policy.each_key { |key| client.delete_ilm_policy(name: key) if key =~ /logstash-policy/ }
152
+ if elastic_ruby_v8_client_available?
153
+ client.index_lifecycle_management.get_lifecycle.each_key { |key| client.index_lifecycle_management.delete_lifecycle(policy: key) if key =~ /logstash-policy/ }
154
+ else
155
+ client.get_ilm_policy.each_key { |key| client.delete_ilm_policy(name: key) if key =~ /logstash-policy/ }
156
+ end
149
157
  end
150
158
 
151
159
  def supports_ilm?(client)
152
160
  begin
153
- client.get_ilm_policy
161
+ if elastic_ruby_v8_client_available?
162
+ client.index_lifecycle_management.get_lifecycle
163
+ else
164
+ client.get_ilm_policy
165
+ end
154
166
  true
155
167
  rescue
156
168
  false
@@ -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', :type => doc_type, :id => id, :refresh => true)
42
+ r = es.get(:index => 'logstash-delete', :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', :type => doc_type, :id => id, :refresh => true)
47
+ r2 = es.get(:index => 'logstash-delete', :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', :type => doc_type, :id => id, :refresh => true)
55
+ r = es.get(:index => 'logstash-delete', :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', :type => doc_type, :id => id, :refresh => true) }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
60
+ expect { es.get(:index => 'logstash-delete', :id => id, :refresh => true) }.to raise_error(get_expected_error_class)
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(Elasticsearch::Transport::Transport::Errors::NotFound)
105
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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.get_alias(name: "logstash")).to include("logstash-000001")
285
+ expect(@es.indices.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(Elasticsearch::Transport::Transport::Errors::NotFound)
290
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001")
301
+ expect(@es.indices.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(Elasticsearch::Transport::Transport::Errors::NotFound)
343
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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(Elasticsearch::Transport::Transport::Errors::NotFound)
350
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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(Elasticsearch::Transport::Transport::Errors::NotFound)
360
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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(Elasticsearch::Transport::Transport::Errors::NotFound)
367
+ expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class)
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.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001")
377
+ expect(@es.indices.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,17 +443,18 @@ 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.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
446
+ expect(@es.indices.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
- put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias)
452
+ @es.indices.create(index: "#{ilm_rollover_alias}-#{todays_date}-000001")
453
+ @es.indices.put_alias(name: ilm_rollover_alias, index: "#{ilm_rollover_alias}-#{todays_date}-000001")
453
454
  expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy
454
455
  subject.register
455
456
  sleep(1)
456
- expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
457
+ expect(@es.indices.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001")
457
458
  end
458
459
 
459
460
  end
@@ -532,3 +533,8 @@ describe 'Elasticsearch has index lifecycle management enabled', :integration =>
532
533
  end
533
534
 
534
535
  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
@@ -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', :type => doc_type, :id => "123", :refresh => true)
39
+ r = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => "123", :refresh => true)
43
+ r2 = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => id, :refresh => true)
66
+ r = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => id, :refresh => true)
74
+ r = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => id, :refresh => true)
79
+ r2 = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => id, :refresh => true)
87
+ r = es.get(:index => 'logstash-index', :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', :type => doc_type, :id => id, :refresh => true)
92
+ r2 = es.get(:index => 'logstash-index', :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,11 +22,12 @@ 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
- :index => 'logstash-update',
26
- :type => doc_type,
27
- :id => "123",
28
- :body => { :message => 'Test', :counter => 1 }
29
- )
25
+ {
26
+ :index => 'logstash-update',
27
+ :id => '123',
28
+ :body => { :message => 'Test', :counter => 1 },
29
+ :refresh => true
30
+ })
30
31
  @es.indices.refresh
31
32
  end
32
33
 
@@ -46,7 +47,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
46
47
  subject = get_es_output(plugin_parameters)
47
48
  subject.register
48
49
  subject.multi_receive([LogStash::Event.new("count" => 4 )])
49
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
50
+ r = @es.get(:index => 'logstash-update', :id => "123", :refresh => true)
50
51
  expect(r["_source"]["counter"]).to eq(5)
51
52
  end
52
53
  end
@@ -57,7 +58,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
57
58
  subject = get_es_output({ 'document_id' => "456", 'upsert' => '{"message": "upsert message"}' })
58
59
  subject.register
59
60
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
60
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
61
+ r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
61
62
  expect(r["_source"]["message"]).to eq('upsert message')
62
63
  end
63
64
 
@@ -65,7 +66,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
65
66
  subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true })
66
67
  subject.register
67
68
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
68
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
69
+ r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
69
70
  expect(r["_source"]["message"]).to eq('sample message here')
70
71
  end
71
72
 
@@ -82,7 +83,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
82
83
  subject.register
83
84
 
84
85
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
85
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
86
+ r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
86
87
  expect(r["_source"]["message"]).to eq('upsert message')
87
88
  end
88
89
 
@@ -91,7 +92,7 @@ describe "Update actions using painless scripts", :integration => true, :update_
91
92
  subject.register
92
93
  subject.multi_receive([LogStash::Event.new("counter" => 1)])
93
94
  @es.indices.refresh
94
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
95
+ r = @es.get(:index => 'logstash-update', :id => "456", :refresh => true)
95
96
  expect(r["_source"]["counter"]).to eq(1)
96
97
  end
97
98
  end
@@ -27,16 +27,21 @@ 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
- :index => INDEX,
31
- :type => doc_type,
32
- :id => "2",
33
- :body => { :message => 'Test to doc indexing', :counter => 1 }
30
+ {
31
+ :index => INDEX,
32
+ :id => '2',
33
+ :body => { :message => 'Test to doc indexing', :counter => 1 },
34
+ :refresh => true
35
+ }
34
36
  )
37
+
35
38
  @es.index(
36
- :index => INDEX,
37
- :type => doc_type,
38
- :id => "3",
39
- :body => { :message => 'Test to doc deletion', :counter => 2 }
39
+ {
40
+ :index => INDEX,
41
+ :id => '3',
42
+ :body => { :message => 'Test to doc deletion', :counter => 2 },
43
+ :refresh => true
44
+ }
40
45
  )
41
46
  @es.indices.refresh
42
47
  end
@@ -63,12 +68,12 @@ describe "Unsupported actions testing...", :integration => true do
63
68
  rejected_events = events.select { |event| !index_or_update.call(event) }
64
69
 
65
70
  indexed_events.each do |event|
66
- response = @es.get(:index => INDEX, :type => doc_type, :id => event.get("doc_id"), :refresh => true)
71
+ response = @es.get(:index => INDEX, :id => event.get("doc_id"), :refresh => true)
67
72
  expect(response['_source']['message']).to eq(event.get("message"))
68
73
  end
69
74
 
70
75
  rejected_events.each do |event|
71
- expect {@es.get(:index => INDEX, :type => doc_type, :id => event.get("doc_id"), :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
76
+ expect {@es.get(:index => INDEX, :id => event.get("doc_id"), :refresh => true)}.to raise_error(get_expected_error_class)
72
77
  end
73
78
  end
74
79
  end
@@ -22,10 +22,12 @@ 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
- :index => 'logstash-update',
26
- :type => doc_type,
27
- :id => "123",
28
- :body => { :message => 'Test', :counter => 1 }
25
+ {
26
+ :index => 'logstash-update',
27
+ :id => '123',
28
+ :body => { :message => 'Test', :counter => 1 },
29
+ :refresh => true
30
+ }
29
31
  )
30
32
  @es.indices.refresh
31
33
  end
@@ -40,14 +42,14 @@ describe "Update actions without scripts", :integration => true do
40
42
  subject = get_es_output({ 'document_id' => "456" } )
41
43
  subject.register
42
44
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
43
- expect {@es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
45
+ expect {@es.get(:index => 'logstash-update', :id => '456', :refresh => true)}.to raise_error(get_expected_error_class)
44
46
  end
45
47
 
46
48
  it "should update existing document" do
47
49
  subject = get_es_output({ 'document_id' => "123" })
48
50
  subject.register
49
51
  subject.multi_receive([LogStash::Event.new("message" => "updated message here")])
50
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
52
+ r = @es.get(:index => 'logstash-update', :id => '123', :refresh => true)
51
53
  expect(r["_source"]["message"]).to eq('updated message here')
52
54
  end
53
55
 
@@ -57,7 +59,7 @@ describe "Update actions without scripts", :integration => true do
57
59
  subject = get_es_output({ 'document_id' => "123" })
58
60
  subject.register
59
61
  subject.multi_receive([LogStash::Event.new("data" => "updated message here", "message" => "foo")])
60
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "123", :refresh => true)
62
+ r = @es.get(:index => 'logstash-update', :id => '123', :refresh => true)
61
63
  expect(r["_source"]["data"]).to eq('updated message here')
62
64
  expect(r["_source"]["message"]).to eq('foo')
63
65
  end
@@ -94,7 +96,7 @@ describe "Update actions without scripts", :integration => true do
94
96
  subject = get_es_output({ 'document_id' => "456", 'upsert' => '{"message": "upsert message"}' })
95
97
  subject.register
96
98
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
97
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
99
+ r = @es.get(:index => 'logstash-update', :id => '456', :refresh => true)
98
100
  expect(r["_source"]["message"]).to eq('upsert message')
99
101
  end
100
102
 
@@ -102,7 +104,7 @@ describe "Update actions without scripts", :integration => true do
102
104
  subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true })
103
105
  subject.register
104
106
  subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
105
- r = @es.get(:index => 'logstash-update', :type => doc_type, :id => "456", :refresh => true)
107
+ r = @es.get(:index => 'logstash-update', :id => '456', :refresh => true)
106
108
  expect(r["_source"]["message"]).to eq('sample message here')
107
109
  end
108
110
 
data/spec/spec_helper.rb CHANGED
@@ -8,3 +8,11 @@ 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
@@ -4,7 +4,6 @@ require_relative "../../../spec/es_spec_helper"
4
4
  describe "whitelisting error types in expected behavior" do
5
5
  let(:template) { '{"template" : "not important, will be updated by :index"}' }
6
6
  let(:event1) { LogStash::Event.new("somevalue" => 100, "@timestamp" => "2014-11-17T20:37:17.223Z") }
7
- let(:action1) { ["index", {:_id=>1, :routing=>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event1] }
8
7
  let(:settings) { {"manage_template" => true, "index" => "logstash-2014.11.17", "template_overwrite" => true, "hosts" => get_host_port() } }
9
8
 
10
9
  subject { LogStash::Outputs::ElasticSearch.new(settings) }
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: 12.0.2
4
+ version: 12.0.3
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -322,9 +322,7 @@ files:
322
322
  - spec/integration/outputs/update_spec.rb
323
323
  - spec/spec_helper.rb
324
324
  - spec/support/elasticsearch/api/actions/delete_ilm_policy.rb
325
- - spec/support/elasticsearch/api/actions/get_alias.rb
326
325
  - spec/support/elasticsearch/api/actions/get_ilm_policy.rb
327
- - spec/support/elasticsearch/api/actions/put_alias.rb
328
326
  - spec/support/elasticsearch/api/actions/put_ilm_policy.rb
329
327
  - spec/unit/http_client_builder_spec.rb
330
328
  - spec/unit/outputs/elasticsearch/data_stream_support_spec.rb
@@ -409,9 +407,7 @@ test_files:
409
407
  - spec/integration/outputs/update_spec.rb
410
408
  - spec/spec_helper.rb
411
409
  - spec/support/elasticsearch/api/actions/delete_ilm_policy.rb
412
- - spec/support/elasticsearch/api/actions/get_alias.rb
413
410
  - spec/support/elasticsearch/api/actions/get_ilm_policy.rb
414
- - spec/support/elasticsearch/api/actions/put_alias.rb
415
411
  - spec/support/elasticsearch/api/actions/put_ilm_policy.rb
416
412
  - spec/unit/http_client_builder_spec.rb
417
413
  - spec/unit/outputs/elasticsearch/data_stream_support_spec.rb
@@ -1,18 +0,0 @@
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
@@ -1,24 +0,0 @@
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