fluent-plugin-elasticsearch 5.3.0 → 5.4.0

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.
@@ -92,40 +92,40 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
92
92
  NONEXISTENT_DATA_STREAM_EXCEPTION = {"error": {}, "status": 404}
93
93
 
94
94
  def stub_ilm_policy(name="foo_ilm_policy", url="http://localhost:9200")
95
- stub_request(:put, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
95
+ stub_request(:put, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
96
96
  end
97
97
 
98
98
  def stub_index_template(name="foo_tpl", url="http://localhost:9200")
99
- stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
99
+ stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
100
100
  end
101
101
 
102
102
  def stub_data_stream(name="foo", url="http://localhost:9200")
103
- stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
103
+ stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
104
104
  end
105
105
 
106
106
  def stub_existent_data_stream?(name="foo", url="http://localhost:9200")
107
- stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
107
+ stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
108
108
  end
109
109
 
110
110
  def stub_existent_ilm?(name="foo_ilm_policy", url="http://localhost:9200")
111
111
 
112
- stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
112
+ stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
113
113
  end
114
114
 
115
115
  def stub_existent_template?(name="foo_tpl", url="http://localhost:9200")
116
- stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
116
+ stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
117
117
  end
118
118
 
119
119
  def stub_nonexistent_data_stream?(name="foo", url="http://localhost:9200")
120
- stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound])
120
+ stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
121
121
  end
122
122
 
123
123
  def stub_nonexistent_ilm?(name="foo_ilm_policy", url="http://localhost:9200")
124
- stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound])
124
+ stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
125
125
  end
126
126
 
127
127
  def stub_nonexistent_template?(name="foo_tpl", url="http://localhost:9200")
128
- stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound])
128
+ stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
129
129
  end
130
130
 
131
131
 
@@ -141,7 +141,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
141
141
 
142
142
  def stub_nonexistent_template_retry?(name="foo_tpl", url="http://localhost:9200")
143
143
  stub_request(:get, "#{url}/_index_template/#{name}").
144
- to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}' })
144
+ to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}', :headers => {'x-elastic-product' => 'Elasticsearch'} })
145
145
  end
146
146
 
147
147
  def stub_bulk_feed(datastream_name="foo", ilm_name="foo_ilm_policy", template_name="foo_tpl", url="http://localhost:9200")
@@ -150,19 +150,19 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
150
150
  # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
151
151
  # {"@timestamp": ...}
152
152
  push_bulk_request(req.body)
153
- end
153
+ end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
154
154
  stub_request(:post, "#{url}/#{ilm_name}/_bulk").with do |req|
155
155
  # bulk data must be pair of OP and records
156
156
  # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
157
157
  # {"@timestamp": ...}
158
158
  push_bulk_request(req.body)
159
- end
159
+ end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
160
160
  stub_request(:post, "#{url}/#{template_name}/_bulk").with do |req|
161
161
  # bulk data must be pair of OP and records
162
162
  # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
163
163
  # {"@timestamp": ...}
164
164
  push_bulk_request(req.body)
165
- end
165
+ end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
166
166
  end
167
167
 
168
168
  def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version, headers={})
@@ -189,7 +189,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
189
189
  stub_request(:post, url).with do |req|
190
190
  index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
191
191
  @index_command_counts[url] += index_cmds.size
192
- end
192
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
193
193
  end
194
194
 
195
195
  def data_stream_supported?
@@ -588,7 +588,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
588
588
 
589
589
  stub_default
590
590
  stub_request(:post, "http://localhost:9200/foo/_bulk").
591
- to_return(status: 200, body: "", headers: {})
591
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
592
592
 
593
593
  instance = driver(config).instance
594
594
 
@@ -626,7 +626,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
626
626
 
627
627
  stub_default
628
628
  stub_request(:post, "http://localhost:9200/foo/_bulk").
629
- to_return(status: 200, body: "", headers: {})
629
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
630
630
 
631
631
  instance = driver(config).instance
632
632
 
@@ -849,7 +849,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
849
849
  stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/foo_bar/_bulk")
850
850
  stub_elastic_info("http://#{host}:#{port}/")
851
851
  stub_request(:get, "http://#{host}:#{port}/_data_stream/foo_bar").
852
- to_return(status: 200, body: "", headers: {})
852
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
853
853
  end
854
854
 
855
855
  conf = config_element(
@@ -919,7 +919,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
919
919
 
920
920
  stub_default
921
921
  elastic_request = stub_request(:post, "http://localhost:9200/foo/_bulk").
922
- to_return(:status => 200, :headers => {'Content-Type' => 'application/json'}, :body => compressed_body)
922
+ to_return(:status => 200, :headers => {'Content-Type' => 'application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body)
923
923
 
924
924
  driver(config)
925
925
  driver.run(default_tag: 'test') do
@@ -945,7 +945,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
945
945
  stub_data_stream
946
946
 
947
947
  stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
948
- to_return(:status => 200, :body => "", :headers => {})
948
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
949
949
 
950
950
  assert_nothing_raised {
951
951
  driver(config)
@@ -970,7 +970,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
970
970
  stub_data_stream
971
971
 
972
972
  stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
973
- to_return(:status => 200, :body => "", :headers => {})
973
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
974
974
 
975
975
  assert_nothing_raised {
976
976
  driver(config)
@@ -999,7 +999,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
999
999
  stub_nonexistent_template?("foo_template")
1000
1000
 
1001
1001
  stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
1002
- to_return(:status => 200, :body => "", :headers => {})
1002
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1003
1003
 
1004
1004
  assert_nothing_raised {
1005
1005
  driver(config)
@@ -67,7 +67,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
67
67
  def stub_elastic(url="http://localhost:9200/_bulk")
68
68
  stub_request(:post, url).with do |req|
69
69
  @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
70
- end
70
+ end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
71
71
  end
72
72
 
73
73
  def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version)
@@ -92,7 +92,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
92
92
  stub_request(:post, url).with do |req|
93
93
  index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
94
94
  @index_command_counts[url] += index_cmds.size
95
- end
95
+ end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
96
96
  end
97
97
 
98
98
  def assert_logs_include(logs, msg, exp_matches=1)
@@ -182,7 +182,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
182
182
  end
183
183
 
184
184
  stub_request(:post, "http://localhost:9200/_bulk").
185
- to_return(status: 200, body: "", headers: {})
185
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
186
186
  stub_elastic_info
187
187
  driver.run(default_tag: 'test') do
188
188
  driver.feed(sample_record)
@@ -215,7 +215,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
215
215
  end
216
216
 
217
217
  stub_request(:post, "http://localhost:9200/_bulk").
218
- to_return(status: 200, body: "", headers: {})
218
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
219
219
  stub_elastic_info
220
220
  driver.run(default_tag: 'test') do
221
221
  driver.feed(sample_record)
@@ -387,13 +387,15 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
387
387
 
388
388
  def test_content_type_header
389
389
  stub_request(:head, "http://localhost:9200/").
390
- to_return(:status => 200, :body => "", :headers => {})
390
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
391
391
  if Elasticsearch::VERSION >= "6.0.2"
392
392
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
393
- with(headers: { "Content-Type" => "application/x-ndjson" })
393
+ with(headers: { "Content-Type" => "application/x-ndjson"}).
394
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
394
395
  else
395
396
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
396
- with(headers: { "Content-Type" => "application/json" })
397
+ with(headers: { "Content-Type" => "application/json"}).
398
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
397
399
  end
398
400
  stub_elastic_info('http://localhost:9200')
399
401
 
@@ -444,7 +446,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
444
446
  compressed_body = gzip(bodystr, Zlib::DEFAULT_COMPRESSION)
445
447
 
446
448
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
447
- to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body)
449
+ to_return(:status => 200, :headers => {'Content-Type' => 'Application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body)
448
450
  stub_elastic_info
449
451
 
450
452
  driver(config)
@@ -1122,7 +1124,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1122
1124
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
1123
1125
  connection_resets += 1
1124
1126
  raise Faraday::ConnectionFailed, "Test message"
1125
- end
1127
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1126
1128
  stub_elastic_info
1127
1129
 
1128
1130
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
@@ -1139,7 +1141,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1139
1141
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
1140
1142
  connection_resets += 1
1141
1143
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
1142
- end
1144
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1143
1145
  stub_elastic_info
1144
1146
 
1145
1147
  driver.configure("reconnect_on_error true\n")
@@ -1166,7 +1168,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1166
1168
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
1167
1169
  connection_resets += 1
1168
1170
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
1169
- end
1171
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1170
1172
  stub_elastic_info
1171
1173
 
1172
1174
  driver.configure("reconnect_on_error false\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-04-11 00:00:00.000000000 Z
13
+ date: 2023-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.3.26
254
+ rubygems_version: 3.4.6
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Elasticsearch output plugin for Fluent event collector