fluent-plugin-elasticsearch 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/README.md +14 -1
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +2 -0
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +34 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95d97728c587e2328005541d5a56a93c935456d
|
4
|
+
data.tar.gz: 27731b0037a18c63b94ed8264bc9845f52cf7d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e9a5268a43192926f48f8429a766bf16af0102d604cb2b2d436357b72d421a4eecbb01a175a6f0b93627f89d77ebea3832aaf39a2464e7888364b81db6942d4
|
7
|
+
data.tar.gz: 7a11dc8ef1a2af5730f03a556c1b1112ddb8ef2ff708be775d3943674fef680069b707ccf5407f486176c7442b459c86a610b543af95e78f2f42b8312498da1a
|
data/History.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
### Future
|
4
4
|
|
5
|
+
### 1.2.0
|
6
|
+
- out_elasticsearch_dynamic get memory improvement and fix for race condition (#133)
|
7
|
+
- Add `resurrect_after` option (#136)
|
8
|
+
|
5
9
|
### 1.1.0
|
6
10
|
- Support SSL client verification and custom CA file (#123)
|
7
11
|
- Release experimental `type elasticsearch_dynamic` (#127)
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/uken/fluent-plugin-elasticsearch/badge.png)](https://coveralls.io/r/uken/fluent-plugin-elasticsearch)
|
7
7
|
[![Code Climate](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch.png)](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch)
|
8
8
|
|
9
|
-
|
9
|
+
Send your logs to ElasticSearch (and search them with Kibana maybe?)
|
10
|
+
|
11
|
+
Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-elasticsearch-service](https://github.com/atomita/fluent-plugin-aws-elasticsearch-service)
|
10
12
|
|
11
13
|
* [Installation](#installation)
|
12
14
|
* [Usage](#usage)
|
@@ -22,6 +24,7 @@ I wrote this so you can search logs routed through Fluentd.
|
|
22
24
|
+ [request_timeout](#request_timeout)
|
23
25
|
+ [reload_connections](#reload_connections)
|
24
26
|
+ [reload_on_failure](#reload_on_failure)
|
27
|
+
+ [resurrect_after](#resurrect_after)
|
25
28
|
+ [include_tag_key, tag_key](#include_tag_key-tag_key)
|
26
29
|
+ [id_key](#id_key)
|
27
30
|
+ [Client/host certificate options](#clienthost-certificate-options)
|
@@ -176,6 +179,14 @@ reload_on_failure true # defaults to false
|
|
176
179
|
Indicates that the elasticsearch-transport will try to reload the nodes addresses if there is a failure while making the
|
177
180
|
request, this can be useful to quickly remove a dead node from the list of addresses.
|
178
181
|
|
182
|
+
### resurrect_after
|
183
|
+
|
184
|
+
You can set in the elasticsearch-transport how often dead connections from the elasticsearch-transport's pool will be resurrected.
|
185
|
+
|
186
|
+
```
|
187
|
+
resurrect_after 5 # defaults to 60s
|
188
|
+
```
|
189
|
+
|
179
190
|
### include_tag_key, tag_key
|
180
191
|
|
181
192
|
```
|
@@ -240,6 +251,8 @@ retry_wait 1.0
|
|
240
251
|
num_threads 1
|
241
252
|
```
|
242
253
|
|
254
|
+
The value for option `buffer_chunk_limit` should not exceed value `http.max_content_length` in your Elasticsearch setup (by default it is 104857600 bytes).
|
255
|
+
|
243
256
|
### Not seeing a config you need?
|
244
257
|
|
245
258
|
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.
|
6
|
+
s.version = '1.2.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}
|
@@ -27,6 +27,7 @@ class Fluent::ElasticsearchOutput < Fluent::BufferedOutput
|
|
27
27
|
config_param :request_timeout, :time, :default => 5
|
28
28
|
config_param :reload_connections, :bool, :default => true
|
29
29
|
config_param :reload_on_failure, :bool, :default => false
|
30
|
+
config_param :resurrect_after, :time, :default => 60
|
30
31
|
config_param :time_key, :string, :default => nil
|
31
32
|
config_param :ssl_verify , :bool, :default => true
|
32
33
|
config_param :client_key, :string, :default => nil
|
@@ -57,6 +58,7 @@ class Fluent::ElasticsearchOutput < Fluent::BufferedOutput
|
|
57
58
|
options: {
|
58
59
|
reload_connections: @reload_connections,
|
59
60
|
reload_on_failure: @reload_on_failure,
|
61
|
+
resurrect_after: @resurrect_after,
|
60
62
|
retry_on_failure: 5,
|
61
63
|
transport_options: {
|
62
64
|
request: { timeout: @request_timeout },
|
@@ -13,20 +13,19 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
13
13
|
config_param :utc_index, :string, :default => "true"
|
14
14
|
config_param :reload_connections, :string, :default => "true"
|
15
15
|
config_param :reload_on_failure, :string, :default => "false"
|
16
|
+
config_param :resurrect_after, :string, :default => "60"
|
16
17
|
config_param :ssl_verify, :string, :dfeault => "true"
|
17
18
|
|
18
19
|
def configure(conf)
|
19
20
|
super
|
20
21
|
|
21
22
|
# evaluate all configurations here
|
23
|
+
@dynamic_params = self.instance_variables.select { |var| is_valid_expand_param_type(var) }
|
22
24
|
@dynamic_config = Hash.new
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
var = var.to_s.gsub(/@(.+)/){ $1 }
|
28
|
-
@dynamic_config[var] = value
|
29
|
-
end
|
25
|
+
@dynamic_params.each { |var|
|
26
|
+
value = expand_param(self.instance_variable_get(var), nil, nil, nil)
|
27
|
+
var = var[1..-1]
|
28
|
+
@dynamic_config[var] = value
|
30
29
|
}
|
31
30
|
# end eval all configs
|
32
31
|
@current_config = nil
|
@@ -47,6 +46,7 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
47
46
|
options: {
|
48
47
|
reload_connections: @dynamic_config['reload_connections'],
|
49
48
|
reload_on_failure: @dynamic_config['reload_on_failure'],
|
49
|
+
resurrect_after: @dynamic_config['resurrect_after'],
|
50
50
|
retry_on_failure: 5,
|
51
51
|
transport_options: {
|
52
52
|
request: { timeout: @dynamic_config['request_timeout'] },
|
@@ -105,64 +105,63 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
105
105
|
attributes[:password] = 'obfuscated' if attributes.has_key?(:password)
|
106
106
|
attributes.inspect
|
107
107
|
end.join(', ')
|
108
|
-
end
|
108
|
+
end
|
109
109
|
|
110
110
|
def write(chunk)
|
111
|
-
|
112
111
|
bulk_message = Hash.new { |h,k| h[k] = [] }
|
112
|
+
dynamic_conf = @dynamic_config.clone
|
113
113
|
|
114
114
|
chunk.msgpack_each do |tag, time, record|
|
115
115
|
next unless record.is_a? Hash
|
116
116
|
|
117
117
|
# evaluate all configurations here
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
118
|
+
@dynamic_params.each { |var|
|
119
|
+
k = var[1..-1]
|
120
|
+
v = self.instance_variable_get(var)
|
121
|
+
# check here to determine if we should evaluate
|
122
|
+
if dynamic_conf[k] != v
|
123
|
+
value = expand_param(v, tag, time, record)
|
124
|
+
dynamic_conf[k] = value
|
126
125
|
end
|
127
126
|
}
|
128
127
|
# end eval all configs
|
129
128
|
|
130
|
-
if eval(
|
129
|
+
if eval(dynamic_conf['logstash_format'])
|
131
130
|
if record.has_key?("@timestamp")
|
132
131
|
time = Time.parse record["@timestamp"]
|
133
|
-
elsif record.has_key?(
|
134
|
-
time = Time.parse record[
|
135
|
-
record['@timestamp'] = record[
|
132
|
+
elsif record.has_key?(dynamic_conf['time_key'])
|
133
|
+
time = Time.parse record[dynamic_conf['time_key']]
|
134
|
+
record['@timestamp'] = record[dynamic_conf['time_key']]
|
136
135
|
else
|
137
136
|
record.merge!({"@timestamp" => Time.at(time).to_datetime.to_s})
|
138
137
|
end
|
139
138
|
|
140
|
-
if eval(
|
141
|
-
target_index = "#{
|
139
|
+
if eval(dynamic_conf['utc_index'])
|
140
|
+
target_index = "#{dynamic_conf['logstash_prefix']}-#{Time.at(time).getutc.strftime("#{dynamic_conf['logstash_dateformat']}")}"
|
142
141
|
else
|
143
|
-
target_index = "#{
|
142
|
+
target_index = "#{dynamic_conf['logstash_prefix']}-#{Time.at(time).strftime("#{dynamic_conf['logstash_dateformat']}")}"
|
144
143
|
end
|
145
144
|
else
|
146
|
-
target_index =
|
145
|
+
target_index = dynamic_conf['index_name']
|
147
146
|
end
|
148
147
|
|
149
148
|
if @include_tag_key
|
150
|
-
record.merge!(
|
149
|
+
record.merge!(dynamic_conf['tag_key'] => tag)
|
151
150
|
end
|
152
151
|
|
153
|
-
meta = { "index" => {"_index" => target_index, "_type" =>
|
154
|
-
if
|
155
|
-
meta['index']['_id'] = record[
|
152
|
+
meta = { "index" => {"_index" => target_index, "_type" => dynamic_conf['type_name']} }
|
153
|
+
if dynamic_conf['id_key'] && record[dynamic_conf['id_key']]
|
154
|
+
meta['index']['_id'] = record[dynamic_conf['id_key']]
|
156
155
|
end
|
157
156
|
|
158
|
-
if
|
159
|
-
meta['index']['_parent'] = record[
|
157
|
+
if dynamic_conf['parent_key'] && record[dynamic_conf['parent_key']]
|
158
|
+
meta['index']['_parent'] = record[dynamic_conf['parent_key']]
|
160
159
|
end
|
161
160
|
|
162
|
-
if
|
163
|
-
host =
|
161
|
+
if dynamic_conf['hosts']
|
162
|
+
host = dynamic_conf['hosts']
|
164
163
|
else
|
165
|
-
host = "#{
|
164
|
+
host = "#{dynamic_conf['host']}:#{dynamic_conf['port']}"
|
166
165
|
end
|
167
166
|
|
168
167
|
bulk_message[host] << meta
|
@@ -174,7 +173,6 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
174
173
|
send(array, hKey) unless array.empty?
|
175
174
|
array.clear
|
176
175
|
end
|
177
|
-
|
178
176
|
end
|
179
177
|
|
180
178
|
def send(data, host)
|
@@ -222,6 +220,7 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
|
|
222
220
|
end
|
223
221
|
|
224
222
|
def is_valid_expand_param_type(param)
|
223
|
+
return false if [:@buffer_type].include?(param)
|
225
224
|
return self.instance_variable_get(param).is_a?(String)
|
226
225
|
end
|
227
226
|
|
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.
|
4
|
+
version: 1.2.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: 2015-
|
12
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|