fluent-plugin-elasticsearch 5.2.5 → 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.
- checksums.yaml +4 -4
- data/.github/workflows/linux.yml +2 -2
- data/.github/workflows/macos.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/History.md +10 -0
- data/README.md +2 -0
- data/fluent-plugin-elasticsearch.gemspec +3 -2
- data/lib/fluent/plugin/in_elasticsearch.rb +1 -0
- data/lib/fluent/plugin/out_elasticsearch.rb +26 -1
- 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 +6 -6
- data/test/plugin/test_in_elasticsearch.rb +10 -10
- data/test/plugin/test_out_elasticsearch.rb +440 -330
- data/test/plugin/test_out_elasticsearch_data_stream.rb +21 -21
- data/test/plugin/test_out_elasticsearch_dynamic.rb +13 -11
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fc25cc0c5f9b35ce8ab9d733cbd4d908df838540f2bc5aad0fce57267f2c6d5
|
4
|
+
data.tar.gz: 1179e1275edf74186b41c3ff004236a940df58b4c7214f2fe6e3a7ae3852cd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f42f1611c24eb8ef00c153bf8ed4acc07da4a02535f5df6eecc44d9a2d219a15de1551131e7efeb80c8b8e2c20ef203302d95a2c1fe369d3996920654ec381
|
7
|
+
data.tar.gz: 10de0f5a8e5c2179595a99b01a331cbc102c1d9529a59435d8f5c079236cf4132f86d05e552ae2e08e1bce88ec8eac8cd28c721c016a5cb17e13526cf5336d9e
|
data/.github/workflows/linux.yml
CHANGED
@@ -11,12 +11,12 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [ '
|
14
|
+
ruby: [ '3.0', '3.1', '3.2' ]
|
15
15
|
os:
|
16
16
|
- ubuntu-latest
|
17
17
|
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
18
18
|
steps:
|
19
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v4
|
20
20
|
- uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
data/.github/workflows/macos.yml
CHANGED
@@ -11,12 +11,12 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [ '
|
14
|
+
ruby: [ '3.0', '3.1', '3.2' ]
|
15
15
|
os:
|
16
16
|
- macOS-latest
|
17
17
|
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
18
18
|
steps:
|
19
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v4
|
20
20
|
- uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
@@ -11,12 +11,12 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [ '
|
14
|
+
ruby: [ '3.0', '3.1', '3.2' ]
|
15
15
|
os:
|
16
16
|
- windows-latest
|
17
17
|
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
18
18
|
steps:
|
19
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v4
|
20
20
|
- uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
data/History.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
4
|
|
5
|
+
### 5.4.0
|
6
|
+
- Fix support for host/hosts placeholders for ipv6 addresses (#1030)
|
7
|
+
- Handle newer es library (#1032)
|
8
|
+
|
9
|
+
### 5.3.0
|
10
|
+
|
11
|
+
- Unpin `faraday` from v1, upgrade to v2. (#1012)
|
12
|
+
Note that if you can't migrate other plugins from `faraday` v1 yet, need to keep
|
13
|
+
fluent-plugin-elasticsearch v5.2.5.
|
14
|
+
|
5
15
|
### 5.2.5
|
6
16
|
|
7
17
|
- Update the name of parameter about `thread_pool`.
|
data/README.md
CHANGED
@@ -125,6 +125,8 @@ Current maintainers: [Hiroshi Hatake | @cosmo0920](https://github.com/cosmo0920)
|
|
125
125
|
| >= 2.0.0 && < 3.2.3 | >= v0.14.20 | >= 2.1 |
|
126
126
|
| < 2.0.0 | >= v0.12.0 | >= 1.9 |
|
127
127
|
|
128
|
+
NOTE: Since fluent-plugin-elasticsearch 5.3.0, it requires faraday 2.0 or later.
|
129
|
+
|
128
130
|
NOTE: For v0.12 version, you should use 1.x.y version. Please send patch into v0.12 branch if you encountered 1.x version's bug.
|
129
131
|
|
130
132
|
NOTE: This documentation is for fluent-plugin-elasticsearch 2.x or later. For 1.x documentation, please see [v0.12 branch](https://github.com/uken/fluent-plugin-elasticsearch/tree/v0.12).
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'fluent-plugin-elasticsearch'
|
6
|
-
s.version = '5.
|
6
|
+
s.version = '5.4.0'
|
7
7
|
s.authors = ['diogo', 'pitr', 'Hiroshi Hatake']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com', 'cosmo0920.wp@gmail.com']
|
9
9
|
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
@@ -23,7 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3".freeze)
|
24
24
|
|
25
25
|
s.add_runtime_dependency 'fluentd', '>= 0.14.22'
|
26
|
-
s.add_runtime_dependency
|
26
|
+
s.add_runtime_dependency 'faraday', '>= 2.0.0'
|
27
|
+
s.add_runtime_dependency 'faraday-excon', '>= 2.0.0'
|
27
28
|
s.add_runtime_dependency 'excon', '>= 0'
|
28
29
|
s.add_runtime_dependency 'elasticsearch'
|
29
30
|
|
@@ -32,6 +32,8 @@ begin
|
|
32
32
|
rescue LoadError
|
33
33
|
end
|
34
34
|
|
35
|
+
require 'faraday/excon'
|
36
|
+
|
35
37
|
module Fluent::Plugin
|
36
38
|
class ElasticsearchOutput < Output
|
37
39
|
class RecoverableRequestFailure < StandardError; end
|
@@ -471,7 +473,7 @@ EOC
|
|
471
473
|
when :excon
|
472
474
|
{ client_key: @client_key, client_cert: @client_cert, client_key_pass: @client_key_pass, nonblock: @http_backend_excon_nonblock }
|
473
475
|
when :typhoeus
|
474
|
-
require 'typhoeus'
|
476
|
+
require 'faraday/typhoeus'
|
475
477
|
{ sslkey: @client_key, sslcert: @client_cert, keypasswd: @client_key_pass }
|
476
478
|
end
|
477
479
|
rescue LoadError => ex
|
@@ -651,6 +653,14 @@ EOC
|
|
651
653
|
end
|
652
654
|
end
|
653
655
|
|
656
|
+
def is_ipv6_host(host_str)
|
657
|
+
begin
|
658
|
+
IPAddr.new(host_str).ipv6?
|
659
|
+
rescue IPAddr::InvalidAddressError
|
660
|
+
return false
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
654
664
|
def get_connection_options(con_host=nil)
|
655
665
|
|
656
666
|
hosts = if con_host || @hosts
|
@@ -662,6 +672,21 @@ EOC
|
|
662
672
|
port: (host_str.split(':')[1] || @port).to_i,
|
663
673
|
scheme: @scheme.to_s
|
664
674
|
}
|
675
|
+
# Support ipv6 for host/host placeholders
|
676
|
+
elsif is_ipv6_host(host_str)
|
677
|
+
if Resolv::IPv6::Regex.match(host_str)
|
678
|
+
{
|
679
|
+
host: "[#{host_str}]",
|
680
|
+
port: @port.to_i,
|
681
|
+
scheme: @scheme.to_s
|
682
|
+
}
|
683
|
+
else
|
684
|
+
{
|
685
|
+
host: host_str,
|
686
|
+
port: @port.to_i,
|
687
|
+
scheme: @scheme.to_s
|
688
|
+
}
|
689
|
+
end
|
665
690
|
else
|
666
691
|
# New hosts format expects URLs such as http://logs.foo.com,https://john:pass@logs2.foo.com/elastic
|
667
692
|
uri = URI(get_escaped_userinfo(host_str))
|
data/test/helper.rb
CHANGED
@@ -15,7 +15,7 @@ class ElasticsearchFallbackSelectorTest < Test::Unit::TestCase
|
|
15
15
|
def stub_elastic(url="http://localhost:9200/_bulk")
|
16
16
|
stub_request(:post, url).with do |req|
|
17
17
|
@index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
18
|
-
end
|
18
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
19
19
|
end
|
20
20
|
|
21
21
|
def elasticsearch_version
|
@@ -60,7 +60,7 @@ class TestElasticsearchIndexLifecycleManagement < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
def test_xpack_info
|
62
62
|
stub_request(:get, "http://localhost:9200/_xpack").
|
63
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json" })
|
63
|
+
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' })
|
64
64
|
stub_elastic_info
|
65
65
|
expected = {"features"=>{"ilm"=>{"available"=>true, "enabled"=>true}}}
|
66
66
|
if xpack_info.is_a?(Elasticsearch::API::Response)
|
@@ -72,32 +72,32 @@ class TestElasticsearchIndexLifecycleManagement < Test::Unit::TestCase
|
|
72
72
|
|
73
73
|
def test_verify_ilm_working
|
74
74
|
stub_request(:get, "http://localhost:9200/_xpack").
|
75
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json" })
|
75
|
+
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' })
|
76
76
|
stub_elastic_info
|
77
77
|
assert_nothing_raised { verify_ilm_working }
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_ilm_policy_doesnt_exists
|
81
81
|
stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluentd-policy")}").
|
82
|
-
to_return(:status => 404, :body => "", :headers => {})
|
82
|
+
to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
83
83
|
stub_elastic_info
|
84
84
|
assert_false(ilm_policy_exists?("fluentd-policy"))
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_ilm_policy_exists
|
88
88
|
stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluent-policy")}").
|
89
|
-
to_return(:status => 200, :body => "", :headers => {})
|
89
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
90
90
|
stub_elastic_info
|
91
91
|
assert_true(ilm_policy_exists?("fluent-policy"))
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_create_ilm_policy
|
95
95
|
stub_request(:get, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}").
|
96
|
-
to_return(:status => 404, :body => "", :headers => {})
|
96
|
+
to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
97
97
|
stub_request(:put, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}").
|
98
98
|
with(:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}",
|
99
99
|
:headers => {'Content-Type'=>'application/json'}).
|
100
|
-
to_return(:status => 200, :body => "", :headers => {})
|
100
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
101
101
|
stub_elastic_info
|
102
102
|
create_ilm_policy("fluent-policy")
|
103
103
|
|
@@ -334,7 +334,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
334
334
|
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
335
335
|
with(body: "{\"sort\":[\"_doc\"]}").
|
336
336
|
to_return(status: 200, body: sample_response.to_s,
|
337
|
-
headers: {'Content-Type' => 'application/json'})
|
337
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
338
338
|
stub_elastic_info
|
339
339
|
|
340
340
|
driver(CONFIG)
|
@@ -350,7 +350,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
350
350
|
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
351
351
|
with(body: "{\"sort\":[\"_doc\"]}").
|
352
352
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
353
|
-
headers: {'Content-Type' => 'application/json'})
|
353
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
354
354
|
stub_elastic_info
|
355
355
|
|
356
356
|
driver(CONFIG + %[index_name #{index_name}])
|
@@ -366,7 +366,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
366
366
|
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
367
367
|
with(body: "{\"sort\":[\"_doc\"]}").
|
368
368
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
369
|
-
headers: {'Content-Type' => 'application/json'})
|
369
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
370
370
|
stub_elastic_info
|
371
371
|
|
372
372
|
driver(CONFIG + %[parse_timestamp])
|
@@ -385,7 +385,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
385
385
|
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
386
386
|
with(body: "{\"sort\":[\"_doc\"]}").
|
387
387
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
388
|
-
headers: {'Content-Type' => 'application/json'})
|
388
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
389
389
|
stub_elastic_info
|
390
390
|
|
391
391
|
driver(CONFIG + %[parse_timestamp true
|
@@ -405,7 +405,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
405
405
|
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
406
406
|
with(body: "{\"sort\":[\"_doc\"]}").
|
407
407
|
to_return(status: 200, body: sample_response.to_s,
|
408
|
-
headers: {'Content-Type' => 'application/json'})
|
408
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
409
409
|
stub_elastic_info
|
410
410
|
|
411
411
|
driver(CONFIG + %[docinfo true])
|
@@ -425,11 +425,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
425
425
|
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
426
426
|
with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":0,\"max\":2}}").
|
427
427
|
to_return(status: 200, body: sample_response.to_s,
|
428
|
-
headers: {'Content-Type' => 'application/json'})
|
428
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
429
429
|
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
430
430
|
with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":1,\"max\":2}}").
|
431
431
|
to_return(status: 200, body: sample_response.to_s,
|
432
|
-
headers: {'Content-Type' => 'application/json'})
|
432
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
433
433
|
stub_elastic_info
|
434
434
|
|
435
435
|
driver(CONFIG + %[num_slices 2])
|
@@ -446,7 +446,7 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
446
446
|
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1").
|
447
447
|
with(body: "{\"sort\":[\"_doc\"]}").
|
448
448
|
to_return(status: 200, body: sample_scroll_response.to_s,
|
449
|
-
headers: {'Content-Type' => 'application/json'})
|
449
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
450
450
|
connection = 0
|
451
451
|
scroll_request = stub_request(@http_method, "http://localhost:9200/_search/scroll?scroll=1m").
|
452
452
|
with(
|
@@ -457,10 +457,10 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
457
457
|
scroll_request.to_return(lambda do |req|
|
458
458
|
if connection <= 1
|
459
459
|
{status: 200, body: sample_scroll_response_2.to_s,
|
460
|
-
headers: {'Content-Type' => 'application/json'}}
|
460
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}}
|
461
461
|
else
|
462
462
|
{status: 200, body: sample_scroll_response_terminate.to_s,
|
463
|
-
headers: {'Content-Type' => 'application/json'}}
|
463
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}}
|
464
464
|
end
|
465
465
|
end)
|
466
466
|
stub_request(:delete, "http://localhost:9200/_search/scroll/WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz").
|