fluent-plugin-elasticsearch 4.1.3 → 4.1.4

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: 6b4183d1e2afbcf9e0e5f78b6cb6ed2fff3206f495a8676d38eb1dbc1ff7267f
4
- data.tar.gz: 2f1644d04286ae42c51e869c6aadd928ec00b678a405dce838cb1d1802ebf5b1
3
+ metadata.gz: c7923225803a37c0076c7cb4c4d6e94c1ec9ccf120ce4067b45db8c0fc19f17f
4
+ data.tar.gz: f1ce4098fb1e4e563e00aae9fe8d30b2bc9cfcb08100616f0ff00b3dfa210667
5
5
  SHA512:
6
- metadata.gz: bc88d00e8800e7062dff4fdb9b6bc67c509ee851f5e726321783bec8902df6b548a2533d7c278151882b6f534e5adc680ba83964885d7bb9fd520340484c8478
7
- data.tar.gz: 07f4379b3bfee4b22bb50f60c441fa60c87ee65967fa70523c3a6fdc7d0cc80c0fced8fd92958227eb64e353c8e623293f5c1e3d17fba848cdab707969d4f3d4
6
+ metadata.gz: '0579350a7eba583c7c4784f5500d9faa6df4e398b4b0d0e4aacf230502751a39fb9591d189217c869a82f6da689ffb435445aea7bd5920332787e787170b37d7'
7
+ data.tar.gz: 8d150716862d82b313a31b104842b368aac3f945bece0a11074bf43a25830c91e6b5ee0556a23e93fdc2159ab20185e08847b4c94bb10033fe7b259741b332b6
data/History.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 4.1.4
6
+ - ElasticsearchGenID update docs for hash_type (#809)
7
+ - Handle api key header (#808)
8
+ - index_template: Handle error object entirely on index creation failure (#807)
9
+
5
10
  ### 4.1.3
6
11
  - Load multiple templates even if template_name and template_file given (#799)
7
12
  - Handle elasticsearch-ruby 7.9.0 using HTTP method changes (#795)
@@ -26,7 +26,7 @@ In your Fluentd configuration, use `@type elasticsearch_genid`. Additional confi
26
26
  use_entire_record false
27
27
  record_keys []
28
28
  separator _
29
- hash_type md5
29
+ hash_type sha1
30
30
  </match>
31
31
  ```
32
32
 
@@ -95,7 +95,7 @@ You can specify separator charactor to creating seed for hash generation.
95
95
  hash_type sha1
96
96
  ```
97
97
 
98
- You can specify hash algorithm.
98
+ You can specify hash algorithm. Support algorithms `md5`, `sha1`, `sha256`, `sha512`. Default: `sha1`
99
99
 
100
100
  ## Advanced Usage
101
101
 
data/README.md CHANGED
@@ -85,6 +85,7 @@ Current maintainers: @cosmo0920
85
85
  + [verify_es version at startup](#verify_es_version_at_startup)
86
86
  + [default_elasticsearch_version](#default_elasticsearch_version)
87
87
  + [custom_headers](#custom_headers)
88
+ + [api_key](#api_key)
88
89
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
89
90
  + [Dynamic configuration](#dynamic-configuration)
90
91
  + [Placeholders](#placeholders)
@@ -1106,6 +1107,14 @@ This parameter adds additional headers to request. The default value is `{}`.
1106
1107
  custom_headers {"token":"secret"}
1107
1108
  ```
1108
1109
 
1110
+ ### api_key
1111
+
1112
+ This parameter adds authentication header. The default value is `nil`.
1113
+
1114
+ ```
1115
+ api_key "ElasticsearchAPIKEY"
1116
+ ```
1117
+
1109
1118
  ### Not seeing a config you need?
1110
1119
 
1111
1120
  We try to keep the scope of this plugin small and not add too many configuration options. If you think an option would be useful to others, feel free to open an issue or contribute a Pull Request.
@@ -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 = '4.1.3'
6
+ s.version = '4.1.4'
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}
@@ -61,7 +61,7 @@ module Fluent::ElasticsearchIndexTemplate
61
61
  if e.message =~ /"already exists"/ || e.message =~ /resource_already_exists_exception/
62
62
  log.debug("Index #{index_name} already exists")
63
63
  else
64
- log.error("Error while index creation - #{index_name}: #{e.inspect}")
64
+ log.error("Error while index creation - #{index_name}", error: e)
65
65
  end
66
66
  end
67
67
 
@@ -8,6 +8,7 @@ rescue LoadError
8
8
  end
9
9
  require 'json'
10
10
  require 'uri'
11
+ require 'base64'
11
12
  begin
12
13
  require 'strptime'
13
14
  rescue LoadError
@@ -57,6 +58,7 @@ module Fluent::Plugin
57
58
  attr_reader :template_names
58
59
  attr_reader :ssl_version_options
59
60
  attr_reader :compressable_connection
61
+ attr_reader :api_key_header
60
62
 
61
63
  helpers :event_emitter, :compat_parameters, :record_accessor, :timer
62
64
 
@@ -155,6 +157,7 @@ EOC
155
157
  config_param :default_elasticsearch_version, :integer, :default => DEFAULT_ELASTICSEARCH_VERSION
156
158
  config_param :log_es_400_reason, :bool, :default => false
157
159
  config_param :custom_headers, :hash, :default => {}
160
+ config_param :api_key, :string, :default => nil, :secret => true
158
161
  config_param :suppress_doc_wrap, :bool, :default => false
159
162
  config_param :ignore_exceptions, :array, :default => [], value_type: :string, :desc => "Ignorable exception list"
160
163
  config_param :exception_backup, :bool, :default => true, :desc => "Chunk backup flag when ignore exception occured"
@@ -212,6 +215,8 @@ EOC
212
215
  @remove_keys_on_update = @remove_keys_on_update.split ','
213
216
  end
214
217
 
218
+ @api_key_header = setup_api_key
219
+
215
220
  raise Fluent::ConfigError, "'max_retry_putting_template' must be greater than or equal to zero." if @max_retry_putting_template < 0
216
221
  raise Fluent::ConfigError, "'max_retry_get_es_version' must be greater than or equal to zero." if @max_retry_get_es_version < 0
217
222
 
@@ -398,6 +403,12 @@ EOC
398
403
  end
399
404
  end
400
405
 
406
+ def setup_api_key
407
+ return {} unless @api_key
408
+
409
+ { "Authorization" => "ApiKey " + Base64.strict_encode64(@api_key) }
410
+ end
411
+
401
412
  def dry_run?
402
413
  if Fluent::Engine.respond_to?(:dry_run_mode)
403
414
  Fluent::Engine.dry_run_mode
@@ -558,7 +569,10 @@ EOC
558
569
  else
559
570
  {}
560
571
  end
561
- headers = { 'Content-Type' => @content_type.to_s }.merge(@custom_headers).merge(gzip_headers)
572
+ headers = { 'Content-Type' => @content_type.to_s }
573
+ .merge(@custom_headers)
574
+ .merge(@api_key_header)
575
+ .merge(gzip_headers)
562
576
  ssl_options = { verify: @ssl_verify, ca_file: @ca_file}.merge(@ssl_version_options)
563
577
 
564
578
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(connection_options.merge(
@@ -252,6 +252,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
252
252
  assert_false instance.compression
253
253
  assert_equal :no_compression, instance.compression_level
254
254
  assert_true instance.http_backend_excon_nonblock
255
+ assert_equal({}, instance.api_key_header)
255
256
  end
256
257
 
257
258
  test 'configure compression' do
@@ -2910,6 +2911,18 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2910
2911
  assert_requested(elastic_request)
2911
2912
  end
2912
2913
 
2914
+ def test_api_key_header
2915
+ stub_request(:head, "http://localhost:9200/").
2916
+ to_return(:status => 200, :body => "", :headers => {})
2917
+ elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
2918
+ with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='})
2919
+ driver.configure(%[api_key testauthheader])
2920
+ driver.run(default_tag: 'test') do
2921
+ driver.feed(sample_record)
2922
+ end
2923
+ assert_requested(elastic_request)
2924
+ end
2925
+
2913
2926
  def test_write_message_with_bad_chunk
2914
2927
  driver.configure("target_index_key bad_value\n@log_level debug\n")
2915
2928
  stub_elastic
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: 4.1.3
4
+ version: 4.1.4
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: 2020-09-08 00:00:00.000000000 Z
13
+ date: 2020-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd