fluent-plugin-elasticsearch 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/README.md +15 -3
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_error.rb +5 -0
- data/lib/fluent/plugin/elasticsearch_index_template.rb +5 -5
- data/lib/fluent/plugin/out_elasticsearch.rb +5 -6
- data/test/plugin/test_out_elasticsearch.rb +46 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 848660aa041feaaebb21f90db0da0a9e2e4b5dc912ba83c58d452607f9d1e982
|
4
|
+
data.tar.gz: e2c4dfedd7458cab2146b5e3939720b2fca6ce69d58be2ffbe0cc966929a2943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4addc8de17edeb5b1a698d21180e314789e56284576f37eed8d645d6af5bc9f7afe310fed1c16f9d63b68683d005364e0bc18324984a9029d120fcde5ee05c1d
|
7
|
+
data.tar.gz: 83dd202ec5ec3ad1d1cbffd14e5cdb49e90e84ec764d129a7b45fa080fa5646e56b0363241fc6cf9a0f4c7403fa43812ae45137e6499cb3014e8f84e0629d9d5
|
data/History.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
4
|
|
5
|
+
### 3.1.0
|
6
|
+
- Retry obtaining Elasticsearch version (#532)
|
7
|
+
- Fix broken id links (#530)
|
8
|
+
|
5
9
|
### 3.0.2
|
6
10
|
- appveyor: Remove Ruby 2.1 CI targets on AppVeyor (#524)
|
7
11
|
- Follow removal of _routing field change on recent Elasticsearch (#523)
|
data/README.md
CHANGED
@@ -42,6 +42,7 @@ Current maintainers: @cosmo0920
|
|
42
42
|
+ [index_prefix](#index_prefix)
|
43
43
|
+ [templates](#templates)
|
44
44
|
+ [max_retry_putting_template](#max_retry_putting_template)
|
45
|
+
+ [max_retry_get_es_version](#max_retry_get_es_version)
|
45
46
|
+ [request_timeout](#request_timeout)
|
46
47
|
+ [reload_connections](#reload_connections)
|
47
48
|
+ [reload_on_failure](#reload_on_failure)
|
@@ -67,8 +68,8 @@ Current maintainers: @cosmo0920
|
|
67
68
|
+ [Buffer options](#buffer-options)
|
68
69
|
+ [Hash flattening](#hash-flattening)
|
69
70
|
+ [Generate Hash ID](#generate-hash-id)
|
70
|
-
+ [sniffer_class_name](#
|
71
|
-
+ [reload_after](#
|
71
|
+
+ [sniffer_class_name](#sniffer-class-name)
|
72
|
+
+ [reload_after](#reload-after)
|
72
73
|
+ [validate_client_version](#validate-client-version)
|
73
74
|
+ [unrecoverable_error_types](#unrecoverable-error-types)
|
74
75
|
+ [verify_es version at startup](#verify_es_version_at_startup)
|
@@ -77,7 +78,7 @@ Current maintainers: @cosmo0920
|
|
77
78
|
+ [Dynamic configuration](#dynamic-configuration)
|
78
79
|
+ [Placeholders](#placeholders)
|
79
80
|
+ [Multi workers](#multi-workers)
|
80
|
-
+ [log_es_400_reason](#
|
81
|
+
+ [log_es_400_reason](#log_es_400_reason)
|
81
82
|
* [Troubleshooting](#troubleshooting)
|
82
83
|
+ [Cannot send events to elasticsearch](#cannot-send-events-to-elasticsearch)
|
83
84
|
+ [Cannot see detailed failure log](#cannot-see-detailed-failure-log)
|
@@ -431,6 +432,17 @@ Usually, booting up clustered Elasticsearch containers are much slower than laun
|
|
431
432
|
max_retry_putting_template 15 # defaults to 10
|
432
433
|
```
|
433
434
|
|
435
|
+
### max_retry_get_es_version
|
436
|
+
|
437
|
+
You can specify times of retry obtaining Elasticsearch version.
|
438
|
+
|
439
|
+
This is useful when Elasticsearch plugin cannot connect Elasticsearch to obtain Elasticsearch version.
|
440
|
+
Usually, booting up clustered Elasticsearch containers are much slower than launching Fluentd container.
|
441
|
+
|
442
|
+
```
|
443
|
+
max_retry_get_es_version 17 # defaults to 15
|
444
|
+
```
|
445
|
+
|
434
446
|
### request_timeout
|
435
447
|
|
436
448
|
You can specify HTTP request timeout.
|
@@ -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.0
|
6
|
+
s.version = '3.1.0'
|
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}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'fluent/error'
|
2
|
+
require_relative './elasticsearch_error'
|
2
3
|
|
3
4
|
module Fluent::ElasticsearchIndexTemplate
|
4
|
-
class TemplateInstallationFailure < Fluent::UnrecoverableError; end
|
5
|
-
|
6
5
|
def get_template(template_file)
|
7
6
|
if !File.exists?(template_file)
|
8
7
|
raise "If you specify a template_name you must specify a valid template file (checked '#{template_file}')!"
|
@@ -29,7 +28,7 @@ module Fluent::ElasticsearchIndexTemplate
|
|
29
28
|
return false
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
31
|
+
def retry_operate(max_retries)
|
33
32
|
return unless block_given?
|
34
33
|
retries = 0
|
35
34
|
begin
|
@@ -40,10 +39,11 @@ module Fluent::ElasticsearchIndexTemplate
|
|
40
39
|
if retries < max_retries
|
41
40
|
retries += 1
|
42
41
|
sleep 2**retries
|
43
|
-
log.warn "Could not
|
42
|
+
log.warn "Could not communicate to Elasticsearch, resetting connection and trying again. #{e.message}"
|
44
43
|
retry
|
45
44
|
end
|
46
|
-
raise
|
45
|
+
raise Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure,
|
46
|
+
"Could not communicate to Elasticsearch after #{retries} retries. #{e.message}"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -13,6 +13,7 @@ require 'fluent/plugin/output'
|
|
13
13
|
require 'fluent/event'
|
14
14
|
require 'fluent/error'
|
15
15
|
require_relative 'elasticsearch_constants'
|
16
|
+
require_relative 'elasticsearch_error'
|
16
17
|
require_relative 'elasticsearch_error_handler'
|
17
18
|
require_relative 'elasticsearch_index_template'
|
18
19
|
begin
|
@@ -106,6 +107,7 @@ EOC
|
|
106
107
|
config_param :application_name, :string, :default => "default"
|
107
108
|
config_param :templates, :hash, :default => nil
|
108
109
|
config_param :max_retry_putting_template, :integer, :default => 10
|
110
|
+
config_param :max_retry_get_es_version, :integer, :default => 15
|
109
111
|
config_param :include_tag_key, :bool, :default => false
|
110
112
|
config_param :tag_key, :string, :default => 'tag'
|
111
113
|
config_param :time_parse_error_tag, :string, :default => 'Fluent::ElasticsearchOutput::TimeParser.error'
|
@@ -170,7 +172,7 @@ EOC
|
|
170
172
|
raise Fluent::ConfigError, "'max_retry_putting_template' must be positive number." if @max_retry_putting_template < 0
|
171
173
|
|
172
174
|
if @template_name && @template_file
|
173
|
-
|
175
|
+
retry_operate(@max_retry_putting_template) do
|
174
176
|
if @customize_template
|
175
177
|
if @rollover_index
|
176
178
|
raise Fluent::ConfigError, "'deflector_alias' must be provided if 'rollover_index' is set true ." if not @deflector_alias
|
@@ -181,7 +183,7 @@ EOC
|
|
181
183
|
end
|
182
184
|
end
|
183
185
|
elsif @templates
|
184
|
-
|
186
|
+
retry_operate(@max_retry_putting_template) do
|
185
187
|
templates_hash_install(@templates, @template_overwrite)
|
186
188
|
end
|
187
189
|
end
|
@@ -229,11 +231,8 @@ EOC
|
|
229
231
|
|
230
232
|
@last_seen_major_version =
|
231
233
|
if @verify_es_version_at_startup
|
232
|
-
|
234
|
+
retry_operate(@max_retry_get_es_version) do
|
233
235
|
detect_es_major_version
|
234
|
-
rescue
|
235
|
-
log.warn "Could not connect Elasticsearch or obtain version. Assuming Elasticsearch #{@default_elasticsearch_version}."
|
236
|
-
@default_elasticsearch_version
|
237
236
|
end
|
238
237
|
else
|
239
238
|
@default_elasticsearch_version
|
@@ -350,6 +350,51 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
353
|
+
class GetElasticsearchVersionTest < self
|
354
|
+
def create_driver(conf='', client_version="\"5.0\"")
|
355
|
+
# For request stub to detect compatibility.
|
356
|
+
@client_version ||= client_version
|
357
|
+
# Ensure original implementation existence.
|
358
|
+
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
359
|
+
def detect_es_major_version
|
360
|
+
@_es_info ||= client.info
|
361
|
+
@_es_info["version"]["number"].to_i
|
362
|
+
end
|
363
|
+
CODE
|
364
|
+
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
365
|
+
def client_library_version
|
366
|
+
#{@client_version}
|
367
|
+
end
|
368
|
+
CODE
|
369
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::ElasticsearchOutput).configure(conf)
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_retry_get_es_version
|
373
|
+
config = %{
|
374
|
+
host logs.google.com
|
375
|
+
port 778
|
376
|
+
scheme https
|
377
|
+
path /es/
|
378
|
+
user john
|
379
|
+
password doe
|
380
|
+
verify_es_version_at_startup true
|
381
|
+
max_retry_get_es_version 3
|
382
|
+
}
|
383
|
+
|
384
|
+
connection_resets = 0
|
385
|
+
stub_request(:get, "https://john:doe@logs.google.com:778/es//").with do |req|
|
386
|
+
connection_resets += 1
|
387
|
+
raise Faraday::ConnectionFailed, "Test message"
|
388
|
+
end
|
389
|
+
|
390
|
+
assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
|
391
|
+
create_driver(config)
|
392
|
+
end
|
393
|
+
|
394
|
+
assert_equal(connection_resets, 4)
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
353
398
|
def test_template_already_present
|
354
399
|
config = %{
|
355
400
|
host logs.google.com
|
@@ -636,7 +681,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
636
681
|
raise Faraday::ConnectionFailed, "Test message"
|
637
682
|
end
|
638
683
|
|
639
|
-
assert_raise(Fluent::
|
684
|
+
assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
|
640
685
|
driver(config)
|
641
686
|
end
|
642
687
|
|
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.0
|
4
|
+
version: 3.1.0
|
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-01-
|
12
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- appveyor.yml
|
146
146
|
- fluent-plugin-elasticsearch.gemspec
|
147
147
|
- lib/fluent/plugin/elasticsearch_constants.rb
|
148
|
+
- lib/fluent/plugin/elasticsearch_error.rb
|
148
149
|
- lib/fluent/plugin/elasticsearch_error_handler.rb
|
149
150
|
- lib/fluent/plugin/elasticsearch_index_template.rb
|
150
151
|
- lib/fluent/plugin/elasticsearch_simple_sniffer.rb
|