fluent-plugin-elasticsearch 2.11.4 → 2.11.5

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: ee8aaeedb5eda1f4857a091853a1c479e7d455d0e44db13eea8591aa93424ee0
4
- data.tar.gz: 96dd085e19d9ee4e22d5f3844a366c7fe1e737a5426240259911295758d735ad
3
+ metadata.gz: 36408493fd7023fcd54d9c3e1ad98f3fa897d7f43dcb0a2d8ebc2e789bbd9518
4
+ data.tar.gz: 1cf82341e33dc2b713a94181b9450bbdaaf82f02c025b69b7008eb4e45a7314f
5
5
  SHA512:
6
- metadata.gz: b460e08f99c4c663e432ffa8adafb065b005680d5a534b67ae9485ae01552bc14c0f6fe11b9c0afc714987871977c8e7a751ab980b54df63704d8238405d282f
7
- data.tar.gz: e6a83a30052a48a8c6986fd47fec45b1e6c700d0b2a9a39d7d8379d897907df08a648ec348cc445d91f2e2ebd399506a3aad6a4553b91a45ff110b11f1680992
6
+ metadata.gz: 9cfe34fbe403a4ef5233a1e34a42e02e184228a22bf20a79698912176a1bfb4ab03f21fd2be0015a666ced2be46106218013e6946bd5b5351b30d08993c08aca
7
+ data.tar.gz: 9712390a2f6be181cf642583d01af895469183a5198513c40493fa61982c9e05198a670bbe74cb4e79e545f145c0330e45f463c1f928572b5421703d19344ff8
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 2.11.5
6
+ - Uplift Merge pull request #459 from richm/v0.12-simple-sniffer (#461)
7
+
5
8
  ### 2.11.4
6
9
  - Persistent backend (#456)
7
10
 
data/README.md CHANGED
@@ -62,6 +62,8 @@ Current maintainers: @cosmo0920
62
62
  + [Buffer options](#buffer-options)
63
63
  + [Hash flattening](#hash-flattening)
64
64
  + [Generate Hash ID](#generate-hash-id)
65
+ + [sniffer_class_name](#sniffer_class_name)
66
+ + [reload_after](#reload_after)
65
67
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
66
68
  + [Dynamic configuration](#dynamic-configuration)
67
69
  + [Placeholders](#placeholders)
@@ -716,6 +718,29 @@ Here is a sample config:
716
718
  </match>
717
719
  ```
718
720
 
721
+ ### Sniffer Class Name
722
+
723
+ The default Sniffer used by the `Elasticsearch::Transport` class works well when Fluentd has a direct connection
724
+ to all of the Elasticsearch servers and can make effective use of the `_nodes` API. This doesn't work well
725
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
726
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
727
+ there is a new `Fluent::Plugin::ElasticsearchSimpleSniffer` class which reuses the hosts given in the configuration, which
728
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
729
+ connections to `logging-es` to reload every 100 operations:
730
+
731
+ ```
732
+ host logging-es
733
+ port 9200
734
+ reload_connections true
735
+ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
736
+ reload_after 100
737
+ ```
738
+
739
+ ### Reload After
740
+
741
+ When `reload_connections true`, this is the integer number of operations after which the plugin will
742
+ reload the connections. The default value is 10000.
743
+
719
744
  ### Not seeing a config you need?
720
745
 
721
746
  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.4'
6
+ s.version = '2.11.5'
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}
@@ -0,0 +1,10 @@
1
+ require 'elasticsearch'
2
+
3
+ class Fluent::Plugin::ElasticsearchSimpleSniffer < Elasticsearch::Transport::Transport::Sniffer
4
+
5
+ def hosts
6
+ @transport.logger.debug "In Fluent::Plugin::ElasticsearchSimpleSniffer hosts #{@transport.hosts}" if @transport.logger
7
+ @transport.hosts
8
+ end
9
+
10
+ end
@@ -44,6 +44,7 @@ module Fluent::Plugin
44
44
  DEFAULT_ELASTICSEARCH_VERSION = 5 # For compatibility.
45
45
  DEFAULT_TYPE_NAME_ES_7x = "_doc".freeze
46
46
  DEFAULT_TYPE_NAME = "fluentd".freeze
47
+ DEFAULT_RELOAD_AFTER = -1
47
48
 
48
49
  config_param :host, :string, :default => 'localhost'
49
50
  config_param :port, :integer, :default => 9200
@@ -101,6 +102,8 @@ EOC
101
102
  config_param :pipeline, :string, :default => nil
102
103
  config_param :with_transporter_log, :bool, :default => false
103
104
  config_param :emit_error_for_missing_id, :bool, :default => false
105
+ config_param :sniffer_class_name, :string, :default => nil
106
+ config_param :reload_after, :integer, :default => DEFAULT_RELOAD_AFTER
104
107
  config_param :content_type, :enum, list: [:"application/json", :"application/x-ndjson"], :default => :"application/json",
105
108
  :deprecated => <<EOC
106
109
  elasticsearch gem v6.0.2 starts to use correct Content-Type. Please upgrade elasticserach gem and stop to use this option.
@@ -207,6 +210,12 @@ EOC
207
210
  end
208
211
  end
209
212
  end
213
+ @sniffer_class = nil
214
+ begin
215
+ @sniffer_class = Object.const_get(@sniffer_class_name) if @sniffer_class_name
216
+ rescue Exception => ex
217
+ raise Fluent::ConfigError, "Could not load sniffer class #{@sniffer_class_name}: #{ex}"
218
+ end
210
219
  end
211
220
 
212
221
  def backend_options
@@ -272,9 +281,13 @@ EOC
272
281
  def client
273
282
  @_es ||= begin
274
283
  adapter_conf = lambda {|f| f.adapter @http_backend, @backend_options }
284
+ local_reload_connections = @reload_connections
285
+ if local_reload_connections && @reload_after > DEFAULT_RELOAD_AFTER
286
+ local_reload_connections = @reload_after
287
+ end
275
288
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(get_connection_options.merge(
276
289
  options: {
277
- reload_connections: @reload_connections,
290
+ reload_connections: local_reload_connections,
278
291
  reload_on_failure: @reload_on_failure,
279
292
  resurrect_after: @resurrect_after,
280
293
  retry_on_failure: 5,
@@ -287,7 +300,8 @@ EOC
287
300
  http: {
288
301
  user: @user,
289
302
  password: @password
290
- }
303
+ },
304
+ sniffer_class: @sniffer_class,
291
305
  }), &adapter_conf)
292
306
  es = Elasticsearch::Client.new transport: transport
293
307
 
@@ -2189,4 +2189,21 @@ class ElasticsearchOutput < Test::Unit::TestCase
2189
2189
  assert_equal(index_cmds.first['index']['_index'], nil)
2190
2190
  end
2191
2191
 
2192
+ def test_use_simple_sniffer
2193
+ require 'fluent/plugin/elasticsearch_simple_sniffer'
2194
+ driver.configure("sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
2195
+ log_level debug
2196
+ with_transporter_log true
2197
+ reload_connections true
2198
+ reload_after 1")
2199
+ stub_elastic_ping
2200
+ stub_elastic
2201
+ driver.run(default_tag: 'test') do
2202
+ driver.feed(sample_record)
2203
+ end
2204
+ log = driver.logs
2205
+ # 2 - one for the ping, one for the _bulk
2206
+ assert_logs_include(log, /In Fluent::Plugin::ElasticsearchSimpleSniffer hosts/, 2)
2207
+ end
2208
+
2192
2209
  end
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.4
4
+ version: 2.11.5
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-08 00:00:00.000000000 Z
12
+ date: 2018-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -147,6 +147,7 @@ files:
147
147
  - lib/fluent/plugin/elasticsearch_constants.rb
148
148
  - lib/fluent/plugin/elasticsearch_error_handler.rb
149
149
  - lib/fluent/plugin/elasticsearch_index_template.rb
150
+ - lib/fluent/plugin/elasticsearch_simple_sniffer.rb
150
151
  - lib/fluent/plugin/filter_elasticsearch_genid.rb
151
152
  - lib/fluent/plugin/out_elasticsearch.rb
152
153
  - lib/fluent/plugin/out_elasticsearch_dynamic.rb