fluent-plugin-elasticsearch 1.12.0 → 1.13.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0d19458ba42dc0503bcbc2d1d5d83f58f125ba5
|
4
|
+
data.tar.gz: c3ca62e3b1801ed4b507ce61efca73a662836445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e919bbe4e67ed88809331b3b1e2c5db6c4f57e03b48bfc0df97edc2980bbf6f0a076e61749acc8f19e9f7ba415836d4d506789a41dc475d5b91d85ee6878b68f
|
7
|
+
data.tar.gz: f4ee41cb99098a2de2a3a98a90b1ebd3977d28dfa9b7c7c52127e1446c73c6dc7b2839489d972d067bfdefde9f1658b11abead46fcaab4efa16c48f10ff6e81b
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -32,6 +32,7 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
|
|
32
32
|
+ [target_type_key](#target_type_key)
|
33
33
|
+ [template_name](#template_name)
|
34
34
|
+ [template_file](#template_file)
|
35
|
+
+ [template_overwrite](#template_overwrite)
|
35
36
|
+ [templates](#templates)
|
36
37
|
+ [request_timeout](#request_timeout)
|
37
38
|
+ [reload_connections](#reload_connections)
|
@@ -279,7 +280,7 @@ Similar to `target_index_key` config, find the type name to write to in the reco
|
|
279
280
|
|
280
281
|
### template_name
|
281
282
|
|
282
|
-
The name of the template to define. If a template by the name given is already present, it will be left unchanged.
|
283
|
+
The name of the template to define. If a template by the name given is already present, it will be left unchanged, unless [template_overwrite](#template_overwrite) is set, in which case the template will be updated.
|
283
284
|
|
284
285
|
This parameter along with template_file allow the plugin to behave similarly to Logstash (it installs a template at creation time) so that raw records are available. See [https://github.com/uken/fluent-plugin-elasticsearch/issues/33](https://github.com/uken/fluent-plugin-elasticsearch/issues/33).
|
285
286
|
|
@@ -301,6 +302,16 @@ templates { "templane_name_1": "path_to_template_1_file", "templane_name_2": "pa
|
|
301
302
|
|
302
303
|
If `template_file` and `template_name` are set, then this parameter will be ignored.
|
303
304
|
|
305
|
+
### template_overwrite
|
306
|
+
|
307
|
+
Always update the template, even if it already exists.
|
308
|
+
|
309
|
+
```
|
310
|
+
template_overwrite true # defaults to false
|
311
|
+
```
|
312
|
+
|
313
|
+
One of [template_file](#template_file) or [templates](#templates) must also be specified if this is set.
|
314
|
+
|
304
315
|
### request_timeout
|
305
316
|
|
306
317
|
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 = '1.
|
6
|
+
s.version = '1.13.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}
|
@@ -19,7 +19,12 @@ module Fluent::ElasticsearchIndexTemplate
|
|
19
19
|
client.indices.put_template(:name => name, :body => template)
|
20
20
|
end
|
21
21
|
|
22
|
-
def template_install(name, template_file)
|
22
|
+
def template_install(name, template_file, overwrite)
|
23
|
+
if overwrite
|
24
|
+
template_put(name, get_template(template_file))
|
25
|
+
log.info("Template '#{name}' overwritten with #{template_file}.")
|
26
|
+
return
|
27
|
+
end
|
23
28
|
if !template_exists?(name)
|
24
29
|
template_put(name, get_template(template_file))
|
25
30
|
log.info("Template configured, but no template installed. Installed '#{name}' from #{template_file}.")
|
@@ -28,9 +33,9 @@ module Fluent::ElasticsearchIndexTemplate
|
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
|
-
def templates_hash_install
|
36
|
+
def templates_hash_install(templates, overwrite)
|
32
37
|
templates.each do |key, value|
|
33
|
-
template_install(key, value)
|
38
|
+
template_install(key, value, overwrite)
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
@@ -62,6 +62,7 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
|
|
62
62
|
config_param :flatten_hashes_separator, :string, :default => "_"
|
63
63
|
config_param :template_name, :string, :default => nil
|
64
64
|
config_param :template_file, :string, :default => nil
|
65
|
+
config_param :template_overwrite, :bool, :default => false
|
65
66
|
config_param :templates, :hash, :default => nil
|
66
67
|
config_param :include_tag_key, :bool, :default => false
|
67
68
|
config_param :tag_key, :string, :default => 'tag'
|
@@ -98,9 +99,9 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
|
|
98
99
|
end
|
99
100
|
|
100
101
|
if @template_name && @template_file
|
101
|
-
template_install(@template_name, @template_file)
|
102
|
+
template_install(@template_name, @template_file, @template_overwrite)
|
102
103
|
elsif @templates
|
103
|
-
templates_hash_install
|
104
|
+
templates_hash_install(@templates, @template_overwrite)
|
104
105
|
end
|
105
106
|
|
106
107
|
@meta_config_map = create_meta_config_map
|
@@ -239,6 +239,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
239
239
|
to_return(:status => 200, :body => "", :headers => {})
|
240
240
|
|
241
241
|
driver('test', config)
|
242
|
+
|
243
|
+
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash")
|
242
244
|
end
|
243
245
|
|
244
246
|
def test_template_create
|
@@ -267,6 +269,39 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
267
269
|
to_return(:status => 200, :body => "", :headers => {})
|
268
270
|
|
269
271
|
driver('test', config)
|
272
|
+
|
273
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_template_overwrite
|
277
|
+
cwd = File.dirname(__FILE__)
|
278
|
+
template_file = File.join(cwd, 'test_template.json')
|
279
|
+
|
280
|
+
config = %{
|
281
|
+
host logs.google.com
|
282
|
+
port 777
|
283
|
+
scheme https
|
284
|
+
path /es/
|
285
|
+
user john
|
286
|
+
password doe
|
287
|
+
template_name logstash
|
288
|
+
template_file #{template_file}
|
289
|
+
template_overwrite true
|
290
|
+
}
|
291
|
+
|
292
|
+
# connection start
|
293
|
+
stub_request(:head, "https://john:doe@logs.google.com:777/es//").
|
294
|
+
to_return(:status => 200, :body => "", :headers => {})
|
295
|
+
# check if template exists
|
296
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
|
297
|
+
to_return(:status => 200, :body => "", :headers => {})
|
298
|
+
# creation
|
299
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash").
|
300
|
+
to_return(:status => 200, :body => "", :headers => {})
|
301
|
+
|
302
|
+
driver('test', config)
|
303
|
+
|
304
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
|
270
305
|
end
|
271
306
|
|
272
307
|
|
@@ -332,6 +367,44 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
332
367
|
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3") #exists
|
333
368
|
end
|
334
369
|
|
370
|
+
def test_templates_overwrite
|
371
|
+
cwd = File.dirname(__FILE__)
|
372
|
+
template_file = File.join(cwd, 'test_template.json')
|
373
|
+
config = %{
|
374
|
+
host logs.google.com
|
375
|
+
port 777
|
376
|
+
scheme https
|
377
|
+
path /es/
|
378
|
+
user john
|
379
|
+
password doe
|
380
|
+
templates {"logstash1":"#{template_file}", "logstash2":"#{template_file}","logstash3":"#{template_file}" }
|
381
|
+
template_overwrite true
|
382
|
+
}
|
383
|
+
|
384
|
+
stub_request(:head, "https://john:doe@logs.google.com:777/es//").
|
385
|
+
to_return(:status => 200, :body => "", :headers => {})
|
386
|
+
# check if template exists
|
387
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
|
388
|
+
to_return(:status => 200, :body => "", :headers => {})
|
389
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
|
390
|
+
to_return(:status => 200, :body => "", :headers => {})
|
391
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash3").
|
392
|
+
to_return(:status => 200, :body => "", :headers => {}) #exists
|
393
|
+
|
394
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
|
395
|
+
to_return(:status => 200, :body => "", :headers => {})
|
396
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
|
397
|
+
to_return(:status => 200, :body => "", :headers => {})
|
398
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3").
|
399
|
+
to_return(:status => 200, :body => "", :headers => {})
|
400
|
+
|
401
|
+
driver('test', config)
|
402
|
+
|
403
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
|
404
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2", times: 1)
|
405
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3", times: 1)
|
406
|
+
end
|
407
|
+
|
335
408
|
def test_templates_not_used
|
336
409
|
cwd = File.dirname(__FILE__)
|
337
410
|
template_file = File.join(cwd, 'test_template.json')
|