fluent-plugin-elasticsearch 2.12.4 → 2.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +3 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +8 -6
- data/test/plugin/test_out_elasticsearch.rb +29 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e61b71d57d8dcc1f75180c40f8e926804b694004b30cb0ecff73407fb1c647c
|
4
|
+
data.tar.gz: b1503054bd7fe71e15bc3aa0c9f0fd90e320926ae40138924ddae9511e1bde8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf3115fb1d7e434cb7bf986bc4c3f2ef91af0eeeddab5b49bf5603089b4ce48919eb56a60a5f07222be8695caf03ea1d9017ff54a6e0c8e96fcd7adec2dfbec
|
7
|
+
data.tar.gz: a5a2b1ee4a2bcf33406e3c754547d0b8de41082a334c196c4ab7b4a9f410770bcf018064ddf5375ceea9e5e935a23e5d88b3b9e17e4a27e9cfc43e1fa6d1acee
|
data/History.md
CHANGED
@@ -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.12.
|
6
|
+
s.version = '2.12.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}
|
@@ -218,6 +218,14 @@ EOC
|
|
218
218
|
log_level = conf['@log_level'] || conf['log_level']
|
219
219
|
log.warn "Consider to specify log_level with @log_level." unless log_level
|
220
220
|
end
|
221
|
+
# Specify @sniffer_class before calling #client.
|
222
|
+
# #detect_es_major_version uses #client.
|
223
|
+
@sniffer_class = nil
|
224
|
+
begin
|
225
|
+
@sniffer_class = Object.const_get(@sniffer_class_name) if @sniffer_class_name
|
226
|
+
rescue Exception => ex
|
227
|
+
raise Fluent::ConfigError, "Could not load sniffer class #{@sniffer_class_name}: #{ex}"
|
228
|
+
end
|
221
229
|
|
222
230
|
@last_seen_major_version =
|
223
231
|
if @verify_es_version_at_startup
|
@@ -256,12 +264,6 @@ EOC
|
|
256
264
|
end
|
257
265
|
end
|
258
266
|
end
|
259
|
-
@sniffer_class = nil
|
260
|
-
begin
|
261
|
-
@sniffer_class = Object.const_get(@sniffer_class_name) if @sniffer_class_name
|
262
|
-
rescue Exception => ex
|
263
|
-
raise Fluent::ConfigError, "Could not load sniffer class #{@sniffer_class_name}: #{ex}"
|
264
|
-
end
|
265
267
|
end
|
266
268
|
|
267
269
|
def backend_options
|
@@ -23,10 +23,14 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
23
23
|
# For request stub to detect compatibility.
|
24
24
|
@es_version ||= es_version
|
25
25
|
@client_version ||= client_version
|
26
|
+
if @es_version
|
27
|
+
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
28
|
+
def detect_es_major_version
|
29
|
+
#{@es_version}
|
30
|
+
end
|
31
|
+
CODE
|
32
|
+
end
|
26
33
|
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
27
|
-
def detect_es_major_version
|
28
|
-
#{@es_version}
|
29
|
-
end
|
30
34
|
def client_library_version
|
31
35
|
#{@client_version}
|
32
36
|
end
|
@@ -59,6 +63,11 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
59
63
|
stub_request(:head, url).to_return(:status => 200, :body => "", :headers => {})
|
60
64
|
end
|
61
65
|
|
66
|
+
def stub_elastic_info(url="http://localhost:9200/", version="6.4.2")
|
67
|
+
body ="{\"version\":{\"number\":\"#{version}\"}}"
|
68
|
+
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json' } })
|
69
|
+
end
|
70
|
+
|
62
71
|
def stub_elastic(url="http://localhost:9200/_bulk")
|
63
72
|
stub_request(:post, url).with do |req|
|
64
73
|
@index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
@@ -191,6 +200,11 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
191
200
|
assert_equal(exp_matches, matches.length, "Logs do not contain '#{msg}' '#{logs}'")
|
192
201
|
end
|
193
202
|
|
203
|
+
def assert_logs_include_compare_size(exp_matches=1, operator="<=", logs="", msg="")
|
204
|
+
matches = logs.grep /#{msg}/
|
205
|
+
assert_compare(exp_matches, operator, matches.length, "Logs do not contain '#{msg}' '#{logs}'")
|
206
|
+
end
|
207
|
+
|
194
208
|
def test_configure
|
195
209
|
config = %{
|
196
210
|
host logs.google.com
|
@@ -2395,19 +2409,24 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
2395
2409
|
|
2396
2410
|
def test_use_simple_sniffer
|
2397
2411
|
require 'fluent/plugin/elasticsearch_simple_sniffer'
|
2398
|
-
driver.configure("sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
|
2399
|
-
log_level debug
|
2400
|
-
with_transporter_log true
|
2401
|
-
reload_connections true
|
2402
|
-
reload_after 1")
|
2403
2412
|
stub_elastic_ping
|
2413
|
+
stub_elastic_info
|
2404
2414
|
stub_elastic
|
2415
|
+
config = %[
|
2416
|
+
sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
|
2417
|
+
log_level debug
|
2418
|
+
with_transporter_log true
|
2419
|
+
reload_connections true
|
2420
|
+
reload_after 1
|
2421
|
+
]
|
2422
|
+
driver(config, nil)
|
2405
2423
|
driver.run(default_tag: 'test') do
|
2406
2424
|
driver.feed(sample_record)
|
2407
2425
|
end
|
2408
2426
|
log = driver.logs
|
2409
|
-
# 2 - one for the ping, one for the _bulk
|
2410
|
-
|
2427
|
+
# 2 or 3 - one for the ping, one for the _bulk, (and client.info)
|
2428
|
+
assert_logs_include_compare_size(4, ">", log, /In Fluent::Plugin::ElasticsearchSimpleSniffer hosts/)
|
2429
|
+
assert_logs_include_compare_size(2, "<=", log, /In Fluent::Plugin::ElasticsearchSimpleSniffer hosts/)
|
2411
2430
|
end
|
2412
2431
|
|
2413
2432
|
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.12.
|
4
|
+
version: 2.12.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-12-
|
12
|
+
date: 2018-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|