fluent-plugin-elasticsearch 3.5.5 → 3.5.6

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: 15eef0c037d870e4d2aed6f8be745c091c2ee2afbb0f43b65f1de5950fd5d2f6
4
- data.tar.gz: 46b5d7cfd290ff1a8ef538b508f657a82eab00ec56efdad2367fc3edddff022f
3
+ metadata.gz: 91343c74b95ee9133fd8323079dbbdd89e539f07942dd936d7107df9dfc5bf8f
4
+ data.tar.gz: f51a62e66164d542e7aa2d21cfa6565085e3bf6be1db92cc31adb4ad5709588f
5
5
  SHA512:
6
- metadata.gz: 8b25f7061cf50d0eb7bc9cf0f157de35c528726c356decbd633ad65b58a8494eaeb15c2ab61476d85231e947d85c2e3a738c94cd10ba5d30196882d8c00f5591
7
- data.tar.gz: d0a82495ab8ed69725bb9581bf04983db8359fe5c5fbc401e5e8be9b16773942f2f6b58167ed051ec65624ac2daa28344ff1319f97d42d3a8c7c2ae68a944c9d
6
+ metadata.gz: 283d651e87233d84bd871df3f1d8b472d91f47dc53953ac47b282cfee654762b0199c7779a398485c24eb89885a01aff5204481a660ed6d7e0fb5243ccbfb2ef
7
+ data.tar.gz: 6ae7ab7dac0721dd82082e01ca9de3bc969949159d9b263cf53e43d62d01a543cb84ba6992d46189f16ab4b9b1c63de2ac8dd49b45e9778e7a9ec01fa66395c8
data/History.md CHANGED
@@ -1,6 +1,13 @@
1
1
  ## Changelog [[tags]](https://github.com/uken/fluent-plugin-elasticsearch/tags)
2
2
 
3
3
  ### [Unreleased]
4
+ ### 3.5.6
5
+ - Support elasticsearch8 removal of mapping types (#656)
6
+ - Upgrade webmock to 3 (#652)
7
+ - Suppress `ruby -c` warnings (#649)
8
+ - Add tips for sniffer class (#644)
9
+ - Make `client_key_pass` secret (#637)
10
+ - Validate `user` and `password` early (#636)
4
11
 
5
12
  ### 3.5.5
6
13
  - Fix arguments order of `assert_equal` (#635)
data/README.md CHANGED
@@ -132,6 +132,10 @@ In your Fluentd configuration, use `@type elasticsearch`. Additional configurati
132
132
  </match>
133
133
  ```
134
134
 
135
+ NOTE: `type_name` parameter will be used fixed `_doc` value for Elasticsearch 7.
136
+
137
+ NOTE: `type_name` parameter will make no effect for Elasticsearch 8.
138
+
135
139
  ### Index templates
136
140
 
137
141
  This plugin creates Elasticsearch indices by merely writing to them. Consider using [Index Templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) to gain control of what get indexed and how. See [this example](https://github.com/uken/fluent-plugin-elasticsearch/issues/33#issuecomment-38693282) for a good starting point.
@@ -894,6 +898,25 @@ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
894
898
  reload_after 100
895
899
  ```
896
900
 
901
+ #### Tips
902
+
903
+ The included sniffer class does not required `out_elasticsearch`.
904
+ You should tell Fluentd where the sniffer class exists.
905
+
906
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
907
+
908
+ ```
909
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
910
+ TD_AGENT_OPTIONS="--use-v1-config -r $sniffer"
911
+ ```
912
+
913
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
914
+
915
+ ```
916
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
917
+ $ fluentd -r $sniffer" [AND YOUR OTHER OPTIONS]
918
+ ```
919
+
897
920
  ### Reload After
898
921
 
899
922
  When `reload_connections true`, this is the integer number of operations after which the plugin will
@@ -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 = '3.5.5'
6
+ s.version = '3.5.6'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
9
9
  s.description = %q{Elasticsearch output plugin for Fluent event collector}
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
 
26
26
  s.add_development_dependency 'rake', '>= 0'
27
- s.add_development_dependency 'webmock', '~> 1'
27
+ s.add_development_dependency 'webmock', '~> 3'
28
28
  s.add_development_dependency 'test-unit', '~> 3.1.0'
29
29
  s.add_development_dependency 'minitest', '~> 5.8'
30
30
  s.add_development_dependency 'flexmock', '~> 2.0'
@@ -27,7 +27,7 @@ class Fluent::Plugin::ElasticsearchErrorHandler
27
27
  if @plugin.log_es_400_reason
28
28
  block.call
29
29
  else
30
- @plugin.log.on_debug &block
30
+ @plugin.log.on_debug(&block)
31
31
  end
32
32
  end
33
33
 
@@ -57,7 +57,7 @@ module Fluent::ElasticsearchIndexTemplate
57
57
 
58
58
  def indexcreation(index_name)
59
59
  client.indices.create(:index => index_name)
60
- rescue Elasticsearch::Transport::Transport::Error => e
60
+ rescue Elasticsearch::Transport::Transport::Error => e
61
61
  log.error("Error while index creation - #{index_name}: #{e.inspect}")
62
62
  end
63
63
 
@@ -91,7 +91,7 @@ EOC
91
91
  config_param :ssl_verify , :bool, :default => true
92
92
  config_param :client_key, :string, :default => nil
93
93
  config_param :client_cert, :string, :default => nil
94
- config_param :client_key_pass, :string, :default => nil
94
+ config_param :client_key_pass, :string, :default => nil, :secret => true
95
95
  config_param :ca_file, :string, :default => nil
96
96
  config_param :ssl_version, :enum, list: [:SSLv23, :TLSv1, :TLSv1_1, :TLSv1_2], :default => :TLSv1
97
97
  config_param :remove_keys, :string, :default => nil
@@ -218,6 +218,8 @@ EOC
218
218
  @dump_proc = Yajl.method(:dump)
219
219
  end
220
220
 
221
+ raise Fluent::ConfigError, "`password` must be present if `user` is present" if @user && @password.nil?
222
+
221
223
  if @user && m = @user.match(/%{(?<user>.*)}/)
222
224
  @user = URI.encode_www_form_component(m["user"])
223
225
  end
@@ -251,10 +253,14 @@ EOC
251
253
  if @last_seen_major_version == 6 && @type_name != DEFAULT_TYPE_NAME_ES_7x
252
254
  log.info "Detected ES 6.x: ES 7.x will only accept `_doc` in type_name."
253
255
  end
254
- if @last_seen_major_version >= 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
255
- log.warn "Detected ES 7.x or above: `_doc` will be used as the document `_type`."
256
+ if @last_seen_major_version == 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
257
+ log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
256
258
  @type_name = '_doc'.freeze
257
259
  end
260
+ if @last_seen_major_version >= 8 && @type_name != DEFAULT_TYPE_NAME_ES_7x
261
+ log.info "Detected ES 8.x or above: This parameter has no effect."
262
+ @type_name = nil
263
+ end
258
264
 
259
265
  if @validate_client_version && !Fluent::Engine.dry_run_mode
260
266
  if @last_seen_major_version != client_library_version.to_i
@@ -454,7 +460,6 @@ EOC
454
460
  end
455
461
 
456
462
  def get_connection_options(con_host=nil)
457
- raise "`password` must be present if `user` is present" if @user && !@password
458
463
 
459
464
  hosts = if con_host || @hosts
460
465
  (con_host || @hosts).split(',').map do |host_str|
@@ -569,7 +574,11 @@ EOC
569
574
  def expand_placeholders(chunk)
570
575
  logstash_prefix = extract_placeholders(@logstash_prefix, chunk)
571
576
  index_name = extract_placeholders(@index_name, chunk)
572
- type_name = extract_placeholders(@type_name, chunk)
577
+ if @type_name
578
+ type_name = extract_placeholders(@type_name, chunk)
579
+ else
580
+ type_name = nil
581
+ end
573
582
  return logstash_prefix, index_name, type_name
574
583
  end
575
584
 
@@ -688,14 +697,20 @@ EOC
688
697
  if @last_seen_major_version == 6
689
698
  log.warn "Detected ES 6.x: `@type_name` will be used as the document `_type`."
690
699
  target_type = type_name
691
- elsif @last_seen_major_version >= 7
692
- log.warn "Detected ES 7.x or above: `_doc` will be used as the document `_type`."
700
+ elsif @last_seen_major_version == 7
701
+ log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
693
702
  target_type = '_doc'.freeze
703
+ elsif @last_seen_major_version >=8
704
+ log.warn "Detected ES 8.x or above: document type will not be used."
705
+ target_type = nil
694
706
  end
695
707
  else
696
- if @last_seen_major_version >= 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
697
- log.warn "Detected ES 7.x or above: `_doc` will be used as the document `_type`."
708
+ if @last_seen_major_version == 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
709
+ log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
698
710
  target_type = '_doc'.freeze
711
+ elsif @last_seen_major_version >= 8
712
+ log.warn "Detected ES 8.x or above: document type will not be used."
713
+ target_type = nil
699
714
  else
700
715
  target_type = type_name
701
716
  end
@@ -703,7 +718,7 @@ EOC
703
718
 
704
719
  meta.clear
705
720
  meta["_index".freeze] = target_index
706
- meta["_type".freeze] = target_type
721
+ meta["_type".freeze] = target_type unless @last_seen_major_version >= 8
707
722
 
708
723
  if @pipeline
709
724
  meta["pipeline".freeze] = @pipeline
@@ -277,6 +277,14 @@ class ElasticsearchOutput < Test::Unit::TestCase
277
277
  assert_equal '_doc', instance.type_name
278
278
  end
279
279
 
280
+ test 'Detected Elasticsearch 8' do
281
+ config = %{
282
+ type_name noeffect
283
+ }
284
+ instance = driver(config, 8).instance
285
+ assert_equal nil, instance.type_name
286
+ end
287
+
280
288
  test 'Detected Elasticsearch 6 and insecure security' do
281
289
  config = %{
282
290
  ssl_version TLSv1_1
@@ -329,7 +337,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
329
337
  'scheme' => 'https',
330
338
  'path' => '/es/',
331
339
  'user' => 'john',
332
- 'pasword' => 'doe',
340
+ 'password' => 'doe',
333
341
  }, [
334
342
  Fluent::Config::Element.new('buffer', 'mykey', {
335
343
  'chunk_keys' => 'mykey'
@@ -349,7 +357,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
349
357
  'scheme' => 'https',
350
358
  'path' => '/es/',
351
359
  'user' => 'john',
352
- 'pasword' => 'doe',
360
+ 'password' => 'doe',
353
361
  }, [
354
362
  Fluent::Config::Element.new('buffer', 'tag', {
355
363
  }, [])
@@ -392,7 +400,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
392
400
  }
393
401
 
394
402
  connection_resets = 0
395
- stub_request(:get, "https://john:doe@logs.google.com:778/es//").with do |req|
403
+ stub_request(:get, "https://logs.google.com:778/es//").
404
+ with(basic_auth: ['john', 'doe']) do |req|
396
405
  connection_resets += 1
397
406
  raise Faraday::ConnectionFailed, "Test message"
398
407
  end
@@ -418,15 +427,17 @@ class ElasticsearchOutput < Test::Unit::TestCase
418
427
  }
419
428
 
420
429
  # connection start
421
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
430
+ stub_request(:head, "https://logs.google.com:777/es//").
431
+ with(basic_auth: ['john', 'doe']).
422
432
  to_return(:status => 200, :body => "", :headers => {})
423
433
  # check if template exists
424
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
434
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
435
+ with(basic_auth: ['john', 'doe']).
425
436
  to_return(:status => 200, :body => "", :headers => {})
426
437
 
427
438
  driver(config)
428
439
 
429
- assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash")
440
+ assert_not_requested(:put, "https://logs.google.com:777/es//_template/logstash")
430
441
  end
431
442
 
432
443
  def test_template_create
@@ -445,18 +456,21 @@ class ElasticsearchOutput < Test::Unit::TestCase
445
456
  }
446
457
 
447
458
  # connection start
448
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
459
+ stub_request(:head, "https://logs.google.com:777/es//").
460
+ with(basic_auth: ['john', 'doe']).
449
461
  to_return(:status => 200, :body => "", :headers => {})
450
462
  # check if template exists
451
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
463
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
464
+ with(basic_auth: ['john', 'doe']).
452
465
  to_return(:status => 404, :body => "", :headers => {})
453
466
  # creation
454
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash").
467
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash").
468
+ with(basic_auth: ['john', 'doe']).
455
469
  to_return(:status => 200, :body => "", :headers => {})
456
470
 
457
471
  driver(config)
458
472
 
459
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
473
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash", times: 1)
460
474
  end
461
475
 
462
476
  def test_custom_template_create
@@ -476,18 +490,21 @@ class ElasticsearchOutput < Test::Unit::TestCase
476
490
  }
477
491
 
478
492
  # connection start
479
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
493
+ stub_request(:head, "https://logs.google.com:777/es//").
494
+ with(basic_auth: ['john', 'doe']).
480
495
  to_return(:status => 200, :body => "", :headers => {})
481
496
  # check if template exists
482
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
497
+ stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
498
+ with(basic_auth: ['john', 'doe']).
483
499
  to_return(:status => 404, :body => "", :headers => {})
484
500
  # creation
485
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
501
+ stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
502
+ with(basic_auth: ['john', 'doe']).
486
503
  to_return(:status => 200, :body => "", :headers => {})
487
504
 
488
505
  driver(config)
489
506
 
490
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template", times: 1)
507
+ assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_alias_template", times: 1)
491
508
  end
492
509
 
493
510
  def test_custom_template_with_rollover_index_create
@@ -512,27 +529,33 @@ class ElasticsearchOutput < Test::Unit::TestCase
512
529
  }
513
530
 
514
531
  # connection start
515
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
532
+ stub_request(:head, "https://logs.google.com:777/es//").
533
+ with(basic_auth: ['john', 'doe']).
516
534
  to_return(:status => 200, :body => "", :headers => {})
517
535
  # check if template exists
518
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
536
+ stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
537
+ with(basic_auth: ['john', 'doe']).
519
538
  to_return(:status => 404, :body => "", :headers => {})
520
539
  # creation
521
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
540
+ stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
541
+ with(basic_auth: ['john', 'doe']).
522
542
  to_return(:status => 200, :body => "", :headers => {})
523
543
  # creation of index which can rollover
524
- stub_request(:put, "https://john:doe@logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
544
+ stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
545
+ with(basic_auth: ['john', 'doe']).
525
546
  to_return(:status => 200, :body => "", :headers => {})
526
547
  # check if alias exists
527
- stub_request(:head, "https://john:doe@logs.google.com:777/es//_alias/myapp_deflector").
548
+ stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
549
+ with(basic_auth: ['john', 'doe']).
528
550
  to_return(:status => 404, :body => "", :headers => {})
529
551
  # put the alias for the index
530
- stub_request(:put, "https://john:doe@logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/_alias/myapp_deflector").
552
+ stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/_alias/myapp_deflector").
553
+ with(basic_auth: ['john', 'doe']).
531
554
  to_return(:status => 200, :body => "", :headers => {})
532
555
 
533
556
  driver(config)
534
557
 
535
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template", times: 1)
558
+ assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_alias_template", times: 1)
536
559
  end
537
560
 
538
561
 
@@ -553,18 +576,21 @@ class ElasticsearchOutput < Test::Unit::TestCase
553
576
  }
554
577
 
555
578
  # connection start
556
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
579
+ stub_request(:head, "https://logs.google.com:777/es//").
580
+ with(basic_auth: ['john', 'doe']).
557
581
  to_return(:status => 200, :body => "", :headers => {})
558
582
  # check if template exists
559
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
583
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
584
+ with(basic_auth: ['john', 'doe']).
560
585
  to_return(:status => 200, :body => "", :headers => {})
561
586
  # creation
562
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash").
587
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash").
588
+ with(basic_auth: ['john', 'doe']).
563
589
  to_return(:status => 200, :body => "", :headers => {})
564
590
 
565
591
  driver(config)
566
592
 
567
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
593
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash", times: 1)
568
594
  end
569
595
 
570
596
  def test_custom_template_overwrite
@@ -585,18 +611,21 @@ class ElasticsearchOutput < Test::Unit::TestCase
585
611
  }
586
612
 
587
613
  # connection start
588
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
614
+ stub_request(:head, "https://logs.google.com:777/es//").
615
+ with(basic_auth: ['john', 'doe']).
589
616
  to_return(:status => 200, :body => "", :headers => {})
590
617
  # check if template exists
591
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
618
+ stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
619
+ with(basic_auth: ['john', 'doe']).
592
620
  to_return(:status => 200, :body => "", :headers => {})
593
621
  # creation
594
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
622
+ stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
623
+ with(basic_auth: ['john', 'doe']).
595
624
  to_return(:status => 200, :body => "", :headers => {})
596
625
 
597
626
  driver(config)
598
627
 
599
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template", times: 1)
628
+ assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_alias_template", times: 1)
600
629
  end
601
630
 
602
631
  def test_custom_template_with_rollover_index_overwrite
@@ -621,27 +650,33 @@ class ElasticsearchOutput < Test::Unit::TestCase
621
650
  }
622
651
 
623
652
  # connection start
624
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
653
+ stub_request(:head, "https://logs.google.com:777/es//").
654
+ with(basic_auth: ['john', 'doe']).
625
655
  to_return(:status => 200, :body => "", :headers => {})
626
656
  # check if template exists
627
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
657
+ stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
658
+ with(basic_auth: ['john', 'doe']).
628
659
  to_return(:status => 200, :body => "", :headers => {})
629
660
  # creation
630
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template").
661
+ stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
662
+ with(basic_auth: ['john', 'doe']).
631
663
  to_return(:status => 200, :body => "", :headers => {})
632
664
  # creation of index which can rollover
633
- stub_request(:put, "https://john:doe@logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E").
665
+ stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E").
666
+ with(basic_auth: ['john', 'doe']).
634
667
  to_return(:status => 200, :body => "", :headers => {})
635
668
  # check if alias exists
636
- stub_request(:head, "https://john:doe@logs.google.com:777/es//_alias/myapp_deflector").
669
+ stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
670
+ with(basic_auth: ['john', 'doe']).
637
671
  to_return(:status => 404, :body => "", :headers => {})
638
672
  # put the alias for the index
639
- stub_request(:put, "https://john:doe@logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/_alias/myapp_deflector").
673
+ stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/_alias/myapp_deflector").
674
+ with(basic_auth: ['john', 'doe']).
640
675
  to_return(:status => 200, :body => "", :headers => {})
641
676
 
642
677
  driver(config)
643
678
 
644
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/myapp_alias_template", times: 1)
679
+ assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_alias_template", times: 1)
645
680
  end
646
681
 
647
682
  def test_template_create_invalid_filename
@@ -657,10 +692,12 @@ class ElasticsearchOutput < Test::Unit::TestCase
657
692
  }
658
693
 
659
694
  # connection start
660
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
695
+ stub_request(:head, "https://logs.google.com:777/es//").
696
+ with(basic_auth: ['john', 'doe']).
661
697
  to_return(:status => 200, :body => "", :headers => {})
662
698
  # check if template exists
663
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
699
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
700
+ with(basic_auth: ['john', 'doe']).
664
701
  to_return(:status => 404, :body => "", :headers => {})
665
702
 
666
703
  assert_raise(RuntimeError) {
@@ -706,7 +743,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
706
743
 
707
744
  connection_resets = 0
708
745
  # check if template exists
709
- stub_request(:get, "https://john:doe@logs.google.com:778/es//_template/logstash").with do |req|
746
+ stub_request(:get, "https://logs.google.com:778/es//_template/logstash")
747
+ .with(basic_auth: ['john', 'doe']) do |req|
710
748
  connection_resets += 1
711
749
  raise Faraday::ConnectionFailed, "Test message"
712
750
  end
@@ -737,7 +775,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
737
775
 
738
776
  connection_resets = 0
739
777
  # check if template exists
740
- stub_request(:get, "https://john:doe@logs.google.com:778/es//_template/logstash").with do |req|
778
+ stub_request(:get, "https://logs.google.com:778/es//_template/logstash")
779
+ .with(basic_auth: ['john', 'doe']) do |req|
741
780
  connection_resets += 1
742
781
  raise Faraday::ConnectionFailed, "Test message"
743
782
  end
@@ -760,29 +799,36 @@ class ElasticsearchOutput < Test::Unit::TestCase
760
799
  templates {"logstash1":"#{template_file}", "logstash2":"#{template_file}","logstash3":"#{template_file}" }
761
800
  }
762
801
 
763
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
802
+ stub_request(:head, "https://logs.google.com:777/es//").
803
+ with(basic_auth: ['john', 'doe']).
764
804
  to_return(:status => 200, :body => "", :headers => {})
765
805
  # check if template exists
766
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
806
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash1").
807
+ with(basic_auth: ['john', 'doe']).
767
808
  to_return(:status => 404, :body => "", :headers => {})
768
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
809
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash2").
810
+ with(basic_auth: ['john', 'doe']).
769
811
  to_return(:status => 404, :body => "", :headers => {})
770
812
 
771
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash3").
813
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash3").
814
+ with(basic_auth: ['john', 'doe']).
772
815
  to_return(:status => 200, :body => "", :headers => {}) #exists
773
816
 
774
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
817
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash1").
818
+ with(basic_auth: ['john', 'doe']).
775
819
  to_return(:status => 200, :body => "", :headers => {})
776
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
820
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash2").
821
+ with(basic_auth: ['john', 'doe']).
777
822
  to_return(:status => 200, :body => "", :headers => {})
778
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3").
823
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash3").
824
+ with(basic_auth: ['john', 'doe']).
779
825
  to_return(:status => 200, :body => "", :headers => {})
780
826
 
781
827
  driver(config)
782
828
 
783
- assert_requested( :put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
784
- assert_requested( :put, "https://john:doe@logs.google.com:777/es//_template/logstash2", times: 1)
785
- assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3") #exists
829
+ assert_requested( :put, "https://logs.google.com:777/es//_template/logstash1", times: 1)
830
+ assert_requested( :put, "https://logs.google.com:777/es//_template/logstash2", times: 1)
831
+ assert_not_requested(:put, "https://logs.google.com:777/es//_template/logstash3") #exists
786
832
  end
787
833
 
788
834
  def test_templates_overwrite
@@ -799,28 +845,35 @@ class ElasticsearchOutput < Test::Unit::TestCase
799
845
  template_overwrite true
800
846
  }
801
847
 
802
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
848
+ stub_request(:head, "https://logs.google.com:777/es//").
849
+ with(basic_auth: ['john', 'doe']).
803
850
  to_return(:status => 200, :body => "", :headers => {})
804
851
  # check if template exists
805
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
852
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash1").
853
+ with(basic_auth: ['john', 'doe']).
806
854
  to_return(:status => 200, :body => "", :headers => {})
807
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
855
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash2").
856
+ with(basic_auth: ['john', 'doe']).
808
857
  to_return(:status => 200, :body => "", :headers => {})
809
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash3").
858
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash3").
859
+ with(basic_auth: ['john', 'doe']).
810
860
  to_return(:status => 200, :body => "", :headers => {}) #exists
811
861
 
812
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
862
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash1").
863
+ with(basic_auth: ['john', 'doe']).
813
864
  to_return(:status => 200, :body => "", :headers => {})
814
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
865
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash2").
866
+ with(basic_auth: ['john', 'doe']).
815
867
  to_return(:status => 200, :body => "", :headers => {})
816
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3").
868
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash3").
869
+ with(basic_auth: ['john', 'doe']).
817
870
  to_return(:status => 200, :body => "", :headers => {})
818
871
 
819
872
  driver(config)
820
873
 
821
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
822
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2", times: 1)
823
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3", times: 1)
874
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash1", times: 1)
875
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash2", times: 1)
876
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash3", times: 1)
824
877
  end
825
878
 
826
879
  def test_templates_not_used
@@ -839,29 +892,36 @@ class ElasticsearchOutput < Test::Unit::TestCase
839
892
  templates {"logstash1":"#{template_file}", "logstash2":"#{template_file}" }
840
893
  }
841
894
  # connection start
842
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
895
+ stub_request(:head, "https://logs.google.com:777/es//").
896
+ with(basic_auth: ['john', 'doe']).
843
897
  to_return(:status => 200, :body => "", :headers => {})
844
898
  # check if template exists
845
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
899
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
900
+ with(basic_auth: ['john', 'doe']).
846
901
  to_return(:status => 404, :body => "", :headers => {})
847
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
902
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash1").
903
+ with(basic_auth: ['john', 'doe']).
848
904
  to_return(:status => 404, :body => "", :headers => {})
849
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
905
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash2").
906
+ with(basic_auth: ['john', 'doe']).
850
907
  to_return(:status => 404, :body => "", :headers => {})
851
908
  #creation
852
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash").
909
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash").
910
+ with(basic_auth: ['john', 'doe']).
853
911
  to_return(:status => 200, :body => "", :headers => {})
854
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
912
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash1").
913
+ with(basic_auth: ['john', 'doe']).
855
914
  to_return(:status => 200, :body => "", :headers => {})
856
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
915
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash2").
916
+ with(basic_auth: ['john', 'doe']).
857
917
  to_return(:status => 200, :body => "", :headers => {})
858
918
 
859
919
  driver(config)
860
920
 
861
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
921
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash", times: 1)
862
922
 
863
- assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1")
864
- assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2")
923
+ assert_not_requested(:put, "https://logs.google.com:777/es//_template/logstash1")
924
+ assert_not_requested(:put, "https://logs.google.com:777/es//_template/logstash2")
865
925
  end
866
926
 
867
927
  def test_templates_can_be_partially_created_if_error_occurs
@@ -876,25 +936,30 @@ class ElasticsearchOutput < Test::Unit::TestCase
876
936
  password doe
877
937
  templates {"logstash1":"#{template_file}", "logstash2":"/abc" }
878
938
  }
879
- stub_request(:head, "https://john:doe@logs.google.com:777/es//").
939
+ stub_request(:head, "https://logs.google.com:777/es//").
940
+ with(basic_auth: ['john', 'doe']).
880
941
  to_return(:status => 200, :body => "", :headers => {})
881
942
  # check if template exists
882
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
943
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash1").
944
+ with(basic_auth: ['john', 'doe']).
883
945
  to_return(:status => 404, :body => "", :headers => {})
884
- stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
946
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash2").
947
+ with(basic_auth: ['john', 'doe']).
885
948
  to_return(:status => 404, :body => "", :headers => {})
886
949
 
887
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
950
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash1").
951
+ with(basic_auth: ['john', 'doe']).
888
952
  to_return(:status => 200, :body => "", :headers => {})
889
- stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
953
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash2").
954
+ with(basic_auth: ['john', 'doe']).
890
955
  to_return(:status => 200, :body => "", :headers => {})
891
956
 
892
957
  assert_raise(RuntimeError) {
893
958
  driver(config)
894
959
  }
895
960
 
896
- assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
897
- assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2")
961
+ assert_requested(:put, "https://logs.google.com:777/es//_template/logstash1", times: 1)
962
+ assert_not_requested(:put, "https://logs.google.com:777/es//_template/logstash2")
898
963
  end
899
964
 
900
965
  def test_legacy_hosts_list
@@ -1024,6 +1089,16 @@ class ElasticsearchOutput < Test::Unit::TestCase
1024
1089
  assert(ports.none? { |p| p == 9200 })
1025
1090
  end
1026
1091
 
1092
+ def test_password_is_required_if_specify_user
1093
+ config = %{
1094
+ user john
1095
+ }
1096
+
1097
+ assert_raise(Fluent::ConfigError) do
1098
+ driver(config)
1099
+ end
1100
+ end
1101
+
1027
1102
  def test_content_type_header
1028
1103
  stub_request(:head, "http://localhost:9200/").
1029
1104
  to_return(:status => 200, :body => "", :headers => {})
@@ -1063,20 +1138,32 @@ class ElasticsearchOutput < Test::Unit::TestCase
1063
1138
  assert_logs_include(error_log, /(input string invalid)|(invalid byte sequence in UTF-8)/)
1064
1139
  end
1065
1140
 
1066
- def test_writes_to_default_index
1141
+ data('Elasticsearch 6' => [6, 'fluentd'],
1142
+ 'Elasticsearch 7' => [7, 'fluentd'],
1143
+ 'Elasticsearch 8' => [8, 'fluentd'],
1144
+ )
1145
+ def test_writes_to_default_index(data)
1146
+ version, index_name = data
1067
1147
  stub_elastic
1148
+ driver("", version)
1068
1149
  driver.run(default_tag: 'test') do
1069
1150
  driver.feed(sample_record)
1070
1151
  end
1071
- assert_equal('fluentd', index_cmds.first['index']['_index'])
1152
+ assert_equal(index_name, index_cmds.first['index']['_index'])
1072
1153
  end
1073
1154
 
1074
- def test_writes_to_default_type
1155
+ data('Elasticsearch 6' => [6, Fluent::Plugin::ElasticsearchOutput::DEFAULT_TYPE_NAME],
1156
+ 'Elasticsearch 7' => [7, Fluent::Plugin::ElasticsearchOutput::DEFAULT_TYPE_NAME_ES_7x],
1157
+ 'Elasticsearch 8' => [8, nil],
1158
+ )
1159
+ def test_writes_to_default_type(data)
1160
+ version, index_type = data
1075
1161
  stub_elastic
1162
+ driver("", version)
1076
1163
  driver.run(default_tag: 'test') do
1077
1164
  driver.feed(sample_record)
1078
1165
  end
1079
- assert_equal(default_type_name, index_cmds.first['index']['_type'])
1166
+ assert_equal(index_type, index_cmds.first['index']['_type'])
1080
1167
  end
1081
1168
 
1082
1169
  def test_writes_to_speficied_index
@@ -141,7 +141,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
141
141
  'scheme' => 'https',
142
142
  'path' => '/es/',
143
143
  'user' => 'john',
144
- 'pasword' => 'doe',
144
+ 'password' => 'doe',
145
145
  }, [
146
146
  Fluent::Config::Element.new('buffer', 'tag', {
147
147
  }, [])
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: 3.5.5
4
+ version: 3.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-26 00:00:00.000000000 Z
12
+ date: 2019-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1'
76
+ version: '3'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '1'
83
+ version: '3'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: test-unit
86
86
  requirement: !ruby/object:Gem::Requirement