fluent-plugin-elasticsearch 5.3.0 → 5.4.1
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/.github/workflows/linux.yml +1 -1
- data/.github/workflows/macos.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/History.md +7 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_compat.rb +1 -0
- data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +9 -9
- data/lib/fluent/plugin/out_elasticsearch.rb +23 -0
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +4 -4
- data/test/helper.rb +0 -1
- data/test/plugin/test_elasticsearch_fallback_selector.rb +1 -1
- data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +9 -13
- data/test/plugin/test_in_elasticsearch.rb +10 -10
- data/test/plugin/test_out_elasticsearch.rb +443 -345
- data/test/plugin/test_out_elasticsearch_data_stream.rb +22 -26
- data/test/plugin/test_out_elasticsearch_dynamic.rb +13 -11
- metadata +3 -3
@@ -31,11 +31,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ilm_endpoint
|
34
|
-
|
35
|
-
'_enrich'.freeze
|
36
|
-
else
|
37
|
-
'_ilm'.freeze
|
38
|
-
end
|
34
|
+
'_ilm'.freeze
|
39
35
|
end
|
40
36
|
|
41
37
|
def driver(conf='', es_version=elasticsearch_version.to_i, client_version=elasticsearch_version)
|
@@ -92,40 +88,40 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
92
88
|
NONEXISTENT_DATA_STREAM_EXCEPTION = {"error": {}, "status": 404}
|
93
89
|
|
94
90
|
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])
|
91
|
+
stub_request(:put, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
96
92
|
end
|
97
93
|
|
98
94
|
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])
|
95
|
+
stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
100
96
|
end
|
101
97
|
|
102
98
|
def stub_data_stream(name="foo", url="http://localhost:9200")
|
103
|
-
stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
99
|
+
stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
104
100
|
end
|
105
101
|
|
106
102
|
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])
|
103
|
+
stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
108
104
|
end
|
109
105
|
|
110
106
|
def stub_existent_ilm?(name="foo_ilm_policy", url="http://localhost:9200")
|
111
107
|
|
112
|
-
stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
108
|
+
stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
113
109
|
end
|
114
110
|
|
115
111
|
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])
|
112
|
+
stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
117
113
|
end
|
118
114
|
|
119
115
|
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])
|
116
|
+
stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
121
117
|
end
|
122
118
|
|
123
119
|
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])
|
120
|
+
stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
125
121
|
end
|
126
122
|
|
127
123
|
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])
|
124
|
+
stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
129
125
|
end
|
130
126
|
|
131
127
|
|
@@ -141,7 +137,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
141
137
|
|
142
138
|
def stub_nonexistent_template_retry?(name="foo_tpl", url="http://localhost:9200")
|
143
139
|
stub_request(:get, "#{url}/_index_template/#{name}").
|
144
|
-
to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}' })
|
140
|
+
to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}', :headers => {'x-elastic-product' => 'Elasticsearch'} })
|
145
141
|
end
|
146
142
|
|
147
143
|
def stub_bulk_feed(datastream_name="foo", ilm_name="foo_ilm_policy", template_name="foo_tpl", url="http://localhost:9200")
|
@@ -150,19 +146,19 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
150
146
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
151
147
|
# {"@timestamp": ...}
|
152
148
|
push_bulk_request(req.body)
|
153
|
-
end
|
149
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
154
150
|
stub_request(:post, "#{url}/#{ilm_name}/_bulk").with do |req|
|
155
151
|
# bulk data must be pair of OP and records
|
156
152
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
157
153
|
# {"@timestamp": ...}
|
158
154
|
push_bulk_request(req.body)
|
159
|
-
end
|
155
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
160
156
|
stub_request(:post, "#{url}/#{template_name}/_bulk").with do |req|
|
161
157
|
# bulk data must be pair of OP and records
|
162
158
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
163
159
|
# {"@timestamp": ...}
|
164
160
|
push_bulk_request(req.body)
|
165
|
-
end
|
161
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
166
162
|
end
|
167
163
|
|
168
164
|
def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version, headers={})
|
@@ -189,7 +185,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
189
185
|
stub_request(:post, url).with do |req|
|
190
186
|
index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
191
187
|
@index_command_counts[url] += index_cmds.size
|
192
|
-
end
|
188
|
+
end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
193
189
|
end
|
194
190
|
|
195
191
|
def data_stream_supported?
|
@@ -588,7 +584,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
588
584
|
|
589
585
|
stub_default
|
590
586
|
stub_request(:post, "http://localhost:9200/foo/_bulk").
|
591
|
-
to_return(status: 200, body: "", headers: {})
|
587
|
+
to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
|
592
588
|
|
593
589
|
instance = driver(config).instance
|
594
590
|
|
@@ -626,7 +622,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
626
622
|
|
627
623
|
stub_default
|
628
624
|
stub_request(:post, "http://localhost:9200/foo/_bulk").
|
629
|
-
to_return(status: 200, body: "", headers: {})
|
625
|
+
to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
|
630
626
|
|
631
627
|
instance = driver(config).instance
|
632
628
|
|
@@ -849,7 +845,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
849
845
|
stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/foo_bar/_bulk")
|
850
846
|
stub_elastic_info("http://#{host}:#{port}/")
|
851
847
|
stub_request(:get, "http://#{host}:#{port}/_data_stream/foo_bar").
|
852
|
-
to_return(status: 200, body: "", headers: {})
|
848
|
+
to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
|
853
849
|
end
|
854
850
|
|
855
851
|
conf = config_element(
|
@@ -919,7 +915,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
919
915
|
|
920
916
|
stub_default
|
921
917
|
elastic_request = stub_request(:post, "http://localhost:9200/foo/_bulk").
|
922
|
-
to_return(:status => 200, :headers => {'Content-Type' => 'application/json'}, :body => compressed_body)
|
918
|
+
to_return(:status => 200, :headers => {'Content-Type' => 'application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body)
|
923
919
|
|
924
920
|
driver(config)
|
925
921
|
driver.run(default_tag: 'test') do
|
@@ -945,7 +941,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
945
941
|
stub_data_stream
|
946
942
|
|
947
943
|
stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
|
948
|
-
to_return(:status => 200, :body => "", :headers => {})
|
944
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
949
945
|
|
950
946
|
assert_nothing_raised {
|
951
947
|
driver(config)
|
@@ -970,7 +966,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
970
966
|
stub_data_stream
|
971
967
|
|
972
968
|
stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
|
973
|
-
to_return(:status => 200, :body => "", :headers => {})
|
969
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
974
970
|
|
975
971
|
assert_nothing_raised {
|
976
972
|
driver(config)
|
@@ -999,7 +995,7 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
999
995
|
stub_nonexistent_template?("foo_template")
|
1000
996
|
|
1001
997
|
stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy").
|
1002
|
-
to_return(:status => 200, :body => "", :headers => {})
|
998
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
1003
999
|
|
1004
1000
|
assert_nothing_raised {
|
1005
1001
|
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.
|
4
|
+
version: 5.4.1
|
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-
|
13
|
+
date: 2023-11-27 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.
|
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
|