fluent-plugin-elasticsearch 5.3.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a475837f544383a6d7c59f43f31c9d79a7c6154b2b8c851c266a9bbbe393e50a
4
- data.tar.gz: 300ad2d07e3009f9d50433ceecee0e410fbd129d75c86d71646e659f58f19df3
3
+ metadata.gz: 4fc25cc0c5f9b35ce8ab9d733cbd4d908df838540f2bc5aad0fce57267f2c6d5
4
+ data.tar.gz: 1179e1275edf74186b41c3ff004236a940df58b4c7214f2fe6e3a7ae3852cd81
5
5
  SHA512:
6
- metadata.gz: d1b12f9ee8582952388aadb13e06ef2538677bb761e9e55f1ea41214442c224b3334252a2b78bc35db6a334c19fa2183fff4a9311bd55bf8edeb44cbab30a1b5
7
- data.tar.gz: eff7db364b8c307f01935b18221effc879e65d9ef300caba3cbdfc3a1c0fe7d84f3f4d8741fdb934bed553f58d0475a76b235598145e9f39c56c124766015540
6
+ metadata.gz: 43f42f1611c24eb8ef00c153bf8ed4acc07da4a02535f5df6eecc44d9a2d219a15de1551131e7efeb80c8b8e2c20ef203302d95a2c1fe369d3996920654ec381
7
+ data.tar.gz: 10de0f5a8e5c2179595a99b01a331cbc102c1d9529a59435d8f5c079236cf4132f86d05e552ae2e08e1bce88ec8eac8cd28c721c016a5cb17e13526cf5336d9e
@@ -16,7 +16,7 @@ jobs:
16
16
  - ubuntu-latest
17
17
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  - uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby }}
@@ -16,7 +16,7 @@ jobs:
16
16
  - macOS-latest
17
17
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  - uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby }}
@@ -16,7 +16,7 @@ jobs:
16
16
  - windows-latest
17
17
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v3
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,10 @@
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
+
5
9
  ### 5.3.0
6
10
 
7
11
  - Unpin `faraday` from v1, upgrade to v2. (#1012)
@@ -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.3.0'
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}
@@ -653,6 +653,14 @@ EOC
653
653
  end
654
654
  end
655
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
+
656
664
  def get_connection_options(con_host=nil)
657
665
 
658
666
  hosts = if con_host || @hosts
@@ -664,6 +672,21 @@ EOC
664
672
  port: (host_str.split(':')[1] || @port).to_i,
665
673
  scheme: @scheme.to_s
666
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
667
690
  else
668
691
  # New hosts format expects URLs such as http://logs.foo.com,https://john:pass@logs2.foo.com/elastic
669
692
  uri = URI(get_escaped_userinfo(host_str))
data/test/helper.rb CHANGED
@@ -15,7 +15,6 @@ end
15
15
 
16
16
  require 'test/unit'
17
17
  require 'fluent/test'
18
- require 'minitest/pride'
19
18
 
20
19
  require 'webmock/test_unit'
21
20
  WebMock.disable_net_connect!
@@ -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").