fluent-plugin-elasticsearch 2.11.6 → 2.11.7

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: 1a97d5261421d51521687b644f6f6b02555ad0f1fd592b24a40f876a8702ba4e
4
- data.tar.gz: b31b34473d410112dd2d1d6e05ac51d277953bb2d33e411eaa6621731cbc5052
3
+ metadata.gz: 4a8adf956e53ac370bbabdb66572a3a61cfe3d27220532ff773ee7cffe53c600
4
+ data.tar.gz: 57d22aa95d06ca181f0f55a7c2f0be4b19f5050bb01e4cb9bf2df17c7a2c710e
5
5
  SHA512:
6
- metadata.gz: d9708a487c86d1cdb367789fccf3ae0ff9a7900710e803e4ca2bcc22f5216334775ae806a86e9b08c09f473bda7c15fa3ba3a5df71ccd95a2de6f3a19fc6d3c5
7
- data.tar.gz: 541256741abbb757a29ba855a19f1d880240f1b6a05d3583017b3f23b600b1bd987f8f8734f627e34868b4ba8d7083c0534d8c10878c5f0ea6216a47722416d1
6
+ metadata.gz: 596ba2952540acad16e8c49b60992382c0947c0d834375016560cd29b3d2ae7f29d18fd98006e2bda3dc3c9038d45dcf565084af6161c9abbbdb1d19f7e9ec48
7
+ data.tar.gz: 903f77f656774e464e0f230f7d18669374965d1a8391307f91a3470df92213a0c545211c9da4ea18a5c40e08d3af04d756c9582e4d36ee5ac61e4e5053ba70ce
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 2.11.7
6
+ - Add mechanism to detect ES and its client version mismatch (#463)
7
+
5
8
  ### 2.11.6
6
9
  - 355 customize template (#431)
7
10
 
data/README.md CHANGED
@@ -66,6 +66,7 @@ Current maintainers: @cosmo0920
66
66
  + [Generate Hash ID](#generate-hash-id)
67
67
  + [sniffer_class_name](#sniffer_class_name)
68
68
  + [reload_after](#reload_after)
69
+ + [validate_client_version](#validate-client-version)
69
70
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
70
71
  + [Dynamic configuration](#dynamic-configuration)
71
72
  + [Placeholders](#placeholders)
@@ -763,6 +764,14 @@ reload_after 100
763
764
  When `reload_connections true`, this is the integer number of operations after which the plugin will
764
765
  reload the connections. The default value is 10000.
765
766
 
767
+ ### Validate Client Version
768
+
769
+ When you use mismatched Elasticsearch server and client libraries, fluent-plugin-elasticsearch cannot send data into Elasticsearch. The default value is `false`.
770
+
771
+ ```
772
+ validate_client_version true
773
+ ```
774
+
766
775
  ### Not seeing a config you need?
767
776
 
768
777
  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 = '2.11.6'
6
+ s.version = '2.11.7'
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}
@@ -113,6 +113,7 @@ see: https://github.com/elastic/elasticsearch-ruby/pull/514
113
113
  EOC
114
114
  config_param :include_index_in_url, :bool, :default => false
115
115
  config_param :http_backend, :enum, list: [:excon, :typhoeus], :default => :excon
116
+ config_param :validate_client_version, :bool, :default => false
116
117
 
117
118
  config_section :buffer do
118
119
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -207,6 +208,15 @@ EOC
207
208
  @type_name = '_doc'.freeze
208
209
  end
209
210
 
211
+ if @validate_client_version
212
+ if @last_seen_major_version != client_library_version.to_i
213
+ raise Fluent::ConfigError, <<-EOC
214
+ Detected ES #{@last_seen_major_version} but you use ES client #{client_library_version}.
215
+ Please consider to use #{@last_seen_major_version}.x series ES client.
216
+ EOC
217
+ end
218
+ end
219
+
210
220
  if @last_seen_major_version >= 6
211
221
  case @ssl_version
212
222
  when :SSLv23, :TLSv1, :TLSv1_1
@@ -241,6 +251,10 @@ EOC
241
251
  @_es_info["version"]["number"].to_i
242
252
  end
243
253
 
254
+ def client_library_version
255
+ Elasticsearch::VERSION
256
+ end
257
+
244
258
  def convert_compat_id_key(key)
245
259
  if key.include?('.') && !key.start_with?('$[')
246
260
  key = "$.#{key}" unless key.start_with?('$.')
@@ -19,13 +19,17 @@ class ElasticsearchOutput < Test::Unit::TestCase
19
19
  log.out.logs.slice!(0, log.out.logs.length)
20
20
  end
21
21
 
22
- def driver(conf='', es_version=5)
22
+ def driver(conf='', es_version=5, client_version="\"5.0\"")
23
23
  # For request stub to detect compatibility.
24
24
  @es_version ||= es_version
25
+ @client_version ||= client_version
25
26
  Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
26
27
  def detect_es_major_version
27
28
  #{@es_version}
28
29
  end
30
+ def client_library_version
31
+ #{@client_version}
32
+ end
29
33
  CODE
30
34
  @driver ||= Fluent::Test::Driver::Output.new(Fluent::Plugin::ElasticsearchOutput) {
31
35
  # v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
@@ -266,6 +270,26 @@ class ElasticsearchOutput < Test::Unit::TestCase
266
270
  assert_logs_include(logs, /Detected ES 6.x or above and enabled insecure security/, 0)
267
271
  end
268
272
 
273
+ test 'Pass Elasticsearch and client library are same' do
274
+ config = %{
275
+ @log_level warn
276
+ validate_client_version true
277
+ }
278
+ assert_nothing_raised do
279
+ driver(config, 6, "\"6.1.0\"").instance
280
+ end
281
+ end
282
+
283
+ test 'Detected Elasticsearch and client library mismatch' do
284
+ config = %{
285
+ @log_level warn
286
+ validate_client_version true
287
+ }
288
+ assert_raise_message(/Detected ES 7 but you use ES client 5.0/) do
289
+ driver(config, 7, "\"5.0.5\"").instance
290
+ end
291
+ end
292
+
269
293
  test 'lack of tag in chunk_keys' do
270
294
  assert_raise_message(/'tag' in chunk_keys is required./) do
271
295
  driver(Fluent::Config::Element.new(
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: 2.11.6
4
+ version: 2.11.7
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: 2018-08-26 00:00:00.000000000 Z
12
+ date: 2018-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd