fluent-plugin-elasticsearch 1.9.1 → 1.9.2
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/.travis.yml +4 -0
- data/Gemfile.v0.12 +11 -0
- data/History.md +3 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +24 -32
- data/test/plugin/test_out_elasticsearch.rb +8 -2
- data/test/plugin/test_out_elasticsearch_dynamic.rb +16 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f1361244893fa6e604c50f5b85d8627fa4422d
|
4
|
+
data.tar.gz: 6adfbf2916a9383e11865724a8400c3a0d6ea208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc662aea89454d7136e056eacfcfcbcd12a704afa23ed45b4998642e5922eac524cea113c3afd0b0124ba15709e9b6844d9910a2e88e39b7fc07ec8202b5067a
|
7
|
+
data.tar.gz: 6cea6d23ae9c9fb779dab7492cf2dd444252de7cb586813c0cd3807a36d0b0a97ab07ba95e0da26e52a129e932a1b3ff3981397cbae67ac3def53046bc2610df
|
data/.travis.yml
CHANGED
data/Gemfile.v0.12
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in fluent-plugin-elasticsearch.gemspec
|
4
|
+
gem 'fluentd', '~> 0.12.0'
|
5
|
+
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
|
9
|
+
gem 'simplecov', require: false
|
10
|
+
gem 'coveralls', require: false
|
11
|
+
gem 'strptime', require: false if RUBY_ENGINE == "ruby" && RUBY_VERSION =~ /^2/
|
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 = '1.9.
|
6
|
+
s.version = '1.9.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}
|
@@ -7,28 +7,20 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
7
7
|
|
8
8
|
config_param :delimiter, :string, :default => "."
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
config_param :time_key_exclude_timestamp, :bool, :default => false
|
15
|
-
config_param :reload_connections, :string, :default => "true"
|
16
|
-
config_param :reload_on_failure, :string, :default => "false"
|
17
|
-
config_param :resurrect_after, :string, :default => "60"
|
18
|
-
config_param :ssl_verify, :string, :default => "true"
|
19
|
-
config_param :reconnect_on_error, :bool, :default => false
|
10
|
+
DYNAMIC_PARAM_NAMES = %W[hosts host port logstash_format logstash_prefix logstash_dateformat time_key utc_index index_name tag_key type_name id_key parent_key routing_key write_operation]
|
11
|
+
DYNAMIC_PARAM_SYMBOLS = DYNAMIC_PARAM_NAMES.map { |n| "@#{n}".to_sym }
|
12
|
+
|
13
|
+
attr_reader :dynamic_config
|
20
14
|
|
21
15
|
def configure(conf)
|
22
16
|
super
|
23
17
|
|
24
18
|
# evaluate all configurations here
|
25
|
-
@
|
26
|
-
|
27
|
-
@dynamic_config = Hash.new
|
28
|
-
@dynamic_params.each { |var|
|
19
|
+
@dynamic_config = {}
|
20
|
+
DYNAMIC_PARAM_SYMBOLS.each_with_index { |var, i|
|
29
21
|
value = expand_param(self.instance_variable_get(var), nil, nil, nil)
|
30
|
-
|
31
|
-
@dynamic_config[
|
22
|
+
key = DYNAMIC_PARAM_NAMES[i]
|
23
|
+
@dynamic_config[key] = value.to_s
|
32
24
|
}
|
33
25
|
# end eval all configs
|
34
26
|
@current_config = nil
|
@@ -47,17 +39,17 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
47
39
|
|
48
40
|
@_es ||= begin
|
49
41
|
@current_config = connection_options[:hosts].clone
|
50
|
-
excon_options = { client_key: @
|
42
|
+
excon_options = { client_key: @client_key, client_cert: @client_cert, client_key_pass: @client_key_pass }
|
51
43
|
adapter_conf = lambda {|f| f.adapter :excon, excon_options }
|
52
44
|
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(connection_options.merge(
|
53
45
|
options: {
|
54
|
-
reload_connections:
|
55
|
-
reload_on_failure:
|
56
|
-
resurrect_after: @
|
46
|
+
reload_connections: @reload_connections,
|
47
|
+
reload_on_failure: @reload_on_failure,
|
48
|
+
resurrect_after: @resurrect_after,
|
57
49
|
retry_on_failure: 5,
|
58
50
|
transport_options: {
|
59
|
-
request: { timeout: @
|
60
|
-
ssl: { verify: @
|
51
|
+
request: { timeout: @request_timeout },
|
52
|
+
ssl: { verify: @ssl_verify, ca_file: @ca_file }
|
61
53
|
}
|
62
54
|
}), &adapter_conf)
|
63
55
|
es = Elasticsearch::Client.new transport: transport
|
@@ -74,16 +66,16 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
74
66
|
end
|
75
67
|
|
76
68
|
def get_connection_options(con_host)
|
77
|
-
raise "`password` must be present if `user` is present" if @
|
69
|
+
raise "`password` must be present if `user` is present" if @user && !@password
|
78
70
|
|
79
|
-
hosts = if con_host || @
|
80
|
-
(con_host || @
|
71
|
+
hosts = if con_host || @hosts
|
72
|
+
(con_host || @hosts).split(',').map do |host_str|
|
81
73
|
# Support legacy hosts format host:port,host:port,host:port...
|
82
74
|
if host_str.match(%r{^[^:]+(\:\d+)?$})
|
83
75
|
{
|
84
76
|
host: host_str.split(':')[0],
|
85
|
-
port: (host_str.split(':')[1] || @
|
86
|
-
scheme: @
|
77
|
+
port: (host_str.split(':')[1] || @port).to_i,
|
78
|
+
scheme: @scheme
|
87
79
|
}
|
88
80
|
else
|
89
81
|
# New hosts format expects URLs such as http://logs.foo.com,https://john:pass@logs2.foo.com/elastic
|
@@ -95,10 +87,10 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
95
87
|
end
|
96
88
|
end.compact
|
97
89
|
else
|
98
|
-
[{host: @
|
90
|
+
[{host: @host, port: @port.to_i, scheme: @scheme}]
|
99
91
|
end.each do |host|
|
100
|
-
host.merge!(user: @
|
101
|
-
host.merge!(path: @
|
92
|
+
host.merge!(user: @user, password: @password) if !host[:user] && @user
|
93
|
+
host.merge!(path: @path) if !host[:path] && @path
|
102
94
|
end
|
103
95
|
|
104
96
|
{
|
@@ -129,8 +121,8 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
129
121
|
next unless record.is_a? Hash
|
130
122
|
|
131
123
|
# evaluate all configurations here
|
132
|
-
|
133
|
-
k =
|
124
|
+
DYNAMIC_PARAM_SYMBOLS.each_with_index { |var, i|
|
125
|
+
k = DYNAMIC_PARAM_NAMES[i]
|
134
126
|
v = self.instance_variable_get(var)
|
135
127
|
# check here to determine if we should evaluate
|
136
128
|
if dynamic_conf[k] != v
|
@@ -13,7 +13,14 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def driver(tag='test', conf='')
|
16
|
-
@driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutput, tag)
|
16
|
+
@driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutput, tag) {
|
17
|
+
# v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
|
18
|
+
if !defined?(Fluent::Plugin::Output)
|
19
|
+
def format(tag, time, record)
|
20
|
+
[time, record].to_msgpack
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}.configure(conf)
|
17
24
|
end
|
18
25
|
|
19
26
|
def sample_record
|
@@ -1134,5 +1141,4 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1134
1141
|
driver.run
|
1135
1142
|
assert(index_cmds[0].has_key?("create"))
|
1136
1143
|
end
|
1137
|
-
|
1138
1144
|
end
|
@@ -11,7 +11,14 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def driver(tag='test', conf='')
|
14
|
-
@driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutputDynamic, tag)
|
14
|
+
@driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutputDynamic, tag) {
|
15
|
+
# v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
|
16
|
+
if !defined?(Fluent::Plugin::Output)
|
17
|
+
def format(tag, time, record)
|
18
|
+
[time, record].to_msgpack
|
19
|
+
end
|
20
|
+
end
|
21
|
+
}.configure(conf)
|
15
22
|
end
|
16
23
|
|
17
24
|
def sample_record
|
@@ -55,12 +62,12 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
55
62
|
}
|
56
63
|
instance = driver('test', config).instance
|
57
64
|
|
58
|
-
|
59
|
-
assert_equal
|
60
|
-
assert_equal '
|
61
|
-
assert_equal '/es/', instance.path
|
65
|
+
conf = instance.dynamic_config
|
66
|
+
assert_equal 'logs.google.com', conf['host']
|
67
|
+
assert_equal "777", conf['port']
|
62
68
|
assert_equal 'john', instance.user
|
63
69
|
assert_equal 'doe', instance.password
|
70
|
+
assert_equal '/es/', instance.path
|
64
71
|
end
|
65
72
|
|
66
73
|
def test_defaults
|
@@ -73,14 +80,11 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
73
80
|
}
|
74
81
|
instance = driver('test', config).instance
|
75
82
|
|
76
|
-
|
77
|
-
assert_equal "
|
78
|
-
assert_equal "
|
83
|
+
conf = instance.dynamic_config
|
84
|
+
assert_equal "9200", conf['port']
|
85
|
+
assert_equal "false", conf['logstash_format']
|
86
|
+
assert_equal "true", conf['utc_index']
|
79
87
|
assert_equal false, instance.time_key_exclude_timestamp
|
80
|
-
assert_equal "true", instance.reload_connections
|
81
|
-
assert_equal "false", instance.reload_on_failure
|
82
|
-
assert_equal "60", instance.resurrect_after
|
83
|
-
assert_equal "true", instance.ssl_verify
|
84
88
|
end
|
85
89
|
|
86
90
|
def test_legacy_hosts_list
|
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.9.
|
4
|
+
version: 1.9.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: 2016-12-
|
12
|
+
date: 2016-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- ".gitignore"
|
123
123
|
- ".travis.yml"
|
124
124
|
- Gemfile
|
125
|
+
- Gemfile.v0.12
|
125
126
|
- History.md
|
126
127
|
- ISSUE_TEMPLATE.md
|
127
128
|
- LICENSE.txt
|