fluent-plugin-elasticsearch 1.17.1 → 1.17.2

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: b520bf633ecbf621fb94e7f4bfa83fa1922d678a577ab343b5b4936d602ceb4e
4
- data.tar.gz: 9b05cb7ea5baffe76509387d61cb50c6ac1dffc097e273148ffae9b719f7cdf5
3
+ metadata.gz: 331ba0c76606e47fa96214c432b7c67bdeda5440cb45c8689f9b63052f372ec1
4
+ data.tar.gz: 68a57f20ce85df802931dc206c52874acb8bf8d49d5d30c020f43a295a8ffe26
5
5
  SHA512:
6
- metadata.gz: 3cf3aca2d2ed49e9807c17a7c740a001eb627575406f9336c69bdab6fe8a2f6156873a2488fda9947abc1c16332700497bcd2ebfe32eda53352acbdc1feb3b5e
7
- data.tar.gz: b243859f0956ef22a561d1755a3a73700fb1cc82a18b857aa0248d068e72e40afd3ca78eeb3356fc898ccc6d5271504073cedae7aaa73a0b478eb4c89bb1a4f3
6
+ metadata.gz: 45d64db8c27ba51856ad811ee09c509ee412bd715abfc7d63a1d0314e07d42295256e8b667df8f81ca2c48425cdc87b1a3808712493c7eb27bb0ab05d2706b3c
7
+ data.tar.gz: 473bc12ab5f0d3e0748f5ea0a1a419ca584a49b76df603e472411559892bf5c8d7beef25e25913270ad6dba1ac7435982955747f1bc53765c5dd6583e663bf3a
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.17.2
6
+ - add simple sniffer for simple proxy/lb cases (#459)
7
+
5
8
  ### 1.17.1
6
9
  - backport strictness-scheme (#447)
7
10
 
data/README.md CHANGED
@@ -56,6 +56,8 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
56
56
  + [Buffered output options](#buffered-output-options)
57
57
  + [Hash flattening](#hash-flattening)
58
58
  + [Generate Hash ID](#generate-hash-id)
59
+ + [sniffer_class_name](#sniffer_class_name)
60
+ + [reload_after](#reload_after)
59
61
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
60
62
  + [Dynamic configuration](#dynamic-configuration)
61
63
  * [Contact](#contact)
@@ -576,6 +578,29 @@ Here is a sample config:
576
578
  </match>
577
579
  ```
578
580
 
581
+ ### Sniffer Class Name
582
+
583
+ The default Sniffer used by the `Elasticsearch::Transport` class works well when Fluentd has a direct connection
584
+ to all of the Elasticsearch servers and can make effective use of the `_nodes` API. This doesn't work well
585
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
586
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
587
+ there is a new `Fluent::ElasticsearchSimpleSniffer` class which reuses the hosts given in the configuration, which
588
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
589
+ connections to `logging-es` to reload every 100 operations:
590
+
591
+ ```
592
+ host logging-es
593
+ port 9200
594
+ reload_connections true
595
+ sniffer_class_name Fluent::ElasticsearchSimpleSniffer
596
+ reload_after 100
597
+ ```
598
+
599
+ ### Reload After
600
+
601
+ When `reload_connections true`, this is the integer number of operations after which the plugin will
602
+ reload the connections. The default value is 10000.
603
+
579
604
  ### Not seeing a config you need?
580
605
 
581
606
  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 = '1.17.1'
6
+ s.version = '1.17.2'
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::ElasticsearchSimpleSniffer < Elasticsearch::Transport::Transport::Sniffer
4
+
5
+ def hosts
6
+ @transport.logger.debug "In Fluent::ElasticsearchSimpleSniffer hosts #{@transport.hosts}" if @transport.logger
7
+ @transport.hosts
8
+ end
9
+
10
+ end
@@ -34,6 +34,8 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
34
34
 
35
35
  Fluent::Plugin.register_output('elasticsearch', self)
36
36
 
37
+ DEFAULT_RELOAD_AFTER = -1
38
+
37
39
  config_param :host, :string, :default => 'localhost'
38
40
  config_param :port, :integer, :default => 9200
39
41
  config_param :user, :string, :default => nil
@@ -86,6 +88,8 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
86
88
  config_param :pipeline, :string, :default => nil
87
89
  config_param :with_transporter_log, :bool, :default => false
88
90
  config_param :emit_error_for_missing_id, :bool, :default => false
91
+ config_param :sniffer_class_name, :string, :default => nil
92
+ config_param :reload_after, :integer, :default => DEFAULT_RELOAD_AFTER
89
93
 
90
94
  include Fluent::ElasticsearchIndexTemplate
91
95
  include Fluent::ElasticsearchConstants
@@ -147,6 +151,13 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
147
151
  log.warn "Consider to specify log_level with @log_level." unless log_level
148
152
  end
149
153
 
154
+ @sniffer_class = nil
155
+ begin
156
+ @sniffer_class = Object.const_get(@sniffer_class_name) if @sniffer_class_name
157
+ rescue Exception => ex
158
+ raise Fluent::ConfigError, "Could not load sniffer class #{@sniffer_class_name}: #{ex}"
159
+ end
160
+
150
161
  end
151
162
 
152
163
  def create_meta_config_map
@@ -189,9 +200,13 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
189
200
  @_es ||= begin
190
201
  excon_options = { client_key: @client_key, client_cert: @client_cert, client_key_pass: @client_key_pass }
191
202
  adapter_conf = lambda {|f| f.adapter :excon, excon_options }
203
+ local_reload_connections = @reload_connections
204
+ if local_reload_connections && @reload_after > DEFAULT_RELOAD_AFTER
205
+ local_reload_connections = @reload_after
206
+ end
192
207
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(get_connection_options.merge(
193
208
  options: {
194
- reload_connections: @reload_connections,
209
+ reload_connections: local_reload_connections,
195
210
  reload_on_failure: @reload_on_failure,
196
211
  resurrect_after: @resurrect_after,
197
212
  retry_on_failure: 5,
@@ -204,7 +219,8 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
204
219
  http: {
205
220
  user: @user,
206
221
  password: @password
207
- }
222
+ },
223
+ sniffer_class: @sniffer_class,
208
224
  }), &adapter_conf)
209
225
  es = Elasticsearch::Client.new transport: transport
210
226
 
@@ -1716,4 +1716,20 @@ class ElasticsearchOutput < Test::Unit::TestCase
1716
1716
  assert(index_cmds[0].has_key?("create"))
1717
1717
  end
1718
1718
 
1719
+ def test_use_simple_sniffer
1720
+ require 'fluent/plugin/elasticsearch_simple_sniffer'
1721
+ driver.configure("sniffer_class_name Fluent::ElasticsearchSimpleSniffer
1722
+ log_level debug
1723
+ with_transporter_log true
1724
+ reload_connections true
1725
+ reload_after 1")
1726
+ stub_elastic_ping
1727
+ stub_elastic
1728
+ driver.emit(sample_record)
1729
+ driver.run
1730
+ log = driver.instance.router.emit_error_handler.log
1731
+ # 2 - one for the ping, one for the _bulk
1732
+ assert_logs_include(log.out.logs, /In Fluent::ElasticsearchSimpleSniffer hosts/, 2)
1733
+ end
1734
+
1719
1735
  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: 1.17.1
4
+ version: 1.17.2
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-07-20 00:00:00.000000000 Z
12
+ date: 2018-08-11 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