fluent-plugin-elasticsearch 2.2.0 → 2.3.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: af3f58b827423bdfc292675d045d0e88f3bcc051
|
4
|
+
data.tar.gz: 63d6cdcdf4f23cac1c7e932e633df607cc3ac7fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38fdabbdd290f4d03f5cc26eae8643c8a7e6a922ebf6d294fc46b3b4a085b77155776c6c48c44d9fa4ca03ffbad4e91c0f3587d34999610fa0214d5635d61c1b
|
7
|
+
data.tar.gz: de3e9167b99936945d290da18400074b9def208d59b6ae01b2a506e644d972d4e5551717f32a77fb969074c6a09c153490ceb940ae88fece749266192d08a45c
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,7 @@ Current maintainers: @cosmo0920
|
|
34
34
|
+ [target_type_key](#target_type_key)
|
35
35
|
+ [template_name](#template_name)
|
36
36
|
+ [template_file](#template_file)
|
37
|
+
+ [template_overwrite](#template_overwrite)
|
37
38
|
+ [templates](#templates)
|
38
39
|
+ [request_timeout](#request_timeout)
|
39
40
|
+ [reload_connections](#reload_connections)
|
@@ -294,7 +295,7 @@ Similar to `target_index_key` config, find the type name to write to in the reco
|
|
294
295
|
|
295
296
|
### template_name
|
296
297
|
|
297
|
-
The name of the template to define. If a template by the name given is already present, it will be left unchanged.
|
298
|
+
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.
|
298
299
|
|
299
300
|
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).
|
300
301
|
|
@@ -316,6 +317,16 @@ templates { "templane_name_1": "path_to_template_1_file", "templane_name_2": "pa
|
|
316
317
|
|
317
318
|
If `template_file` and `template_name` are set, then this parameter will be ignored.
|
318
319
|
|
320
|
+
### template_overwrite
|
321
|
+
|
322
|
+
Always update the template, even if it already exists.
|
323
|
+
|
324
|
+
```
|
325
|
+
template_overwrite true # defaults to false
|
326
|
+
```
|
327
|
+
|
328
|
+
One of [template_file](#template_file) or [templates](#templates) must also be specified if this is set.
|
329
|
+
|
319
330
|
### request_timeout
|
320
331
|
|
321
332
|
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 = '2.
|
6
|
+
s.version = '2.3.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
|
|
@@ -67,6 +67,7 @@ module Fluent::Plugin
|
|
67
67
|
config_param :flatten_hashes_separator, :string, :default => "_"
|
68
68
|
config_param :template_name, :string, :default => nil
|
69
69
|
config_param :template_file, :string, :default => nil
|
70
|
+
config_param :template_overwrite, :bool, :default => false
|
70
71
|
config_param :templates, :hash, :default => nil
|
71
72
|
config_param :include_tag_key, :bool, :default => false
|
72
73
|
config_param :tag_key, :string, :default => 'tag'
|
@@ -114,9 +115,9 @@ module Fluent::Plugin
|
|
114
115
|
end
|
115
116
|
|
116
117
|
if @template_name && @template_file
|
117
|
-
template_install(@template_name, @template_file)
|
118
|
+
template_install(@template_name, @template_file, @template_overwrite)
|
118
119
|
elsif @templates
|
119
|
-
templates_hash_install
|
120
|
+
templates_hash_install(@templates, @template_overwrite)
|
120
121
|
end
|
121
122
|
|
122
123
|
@meta_config_map = create_meta_config_map
|
@@ -262,6 +262,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
262
262
|
to_return(:status => 200, :body => "", :headers => {})
|
263
263
|
|
264
264
|
driver(config)
|
265
|
+
|
266
|
+
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash")
|
265
267
|
end
|
266
268
|
|
267
269
|
def test_template_create
|
@@ -290,6 +292,39 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
290
292
|
to_return(:status => 200, :body => "", :headers => {})
|
291
293
|
|
292
294
|
driver(config)
|
295
|
+
|
296
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_template_overwrite
|
300
|
+
cwd = File.dirname(__FILE__)
|
301
|
+
template_file = File.join(cwd, 'test_template.json')
|
302
|
+
|
303
|
+
config = %{
|
304
|
+
host logs.google.com
|
305
|
+
port 777
|
306
|
+
scheme https
|
307
|
+
path /es/
|
308
|
+
user john
|
309
|
+
password doe
|
310
|
+
template_name logstash
|
311
|
+
template_file #{template_file}
|
312
|
+
template_overwrite true
|
313
|
+
}
|
314
|
+
|
315
|
+
# connection start
|
316
|
+
stub_request(:head, "https://john:doe@logs.google.com:777/es//").
|
317
|
+
to_return(:status => 200, :body => "", :headers => {})
|
318
|
+
# check if template exists
|
319
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash").
|
320
|
+
to_return(:status => 200, :body => "", :headers => {})
|
321
|
+
# creation
|
322
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash").
|
323
|
+
to_return(:status => 200, :body => "", :headers => {})
|
324
|
+
|
325
|
+
driver(config)
|
326
|
+
|
327
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash", times: 1)
|
293
328
|
end
|
294
329
|
|
295
330
|
|
@@ -355,6 +390,44 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
355
390
|
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3") #exists
|
356
391
|
end
|
357
392
|
|
393
|
+
def test_templates_overwrite
|
394
|
+
cwd = File.dirname(__FILE__)
|
395
|
+
template_file = File.join(cwd, 'test_template.json')
|
396
|
+
config = %{
|
397
|
+
host logs.google.com
|
398
|
+
port 777
|
399
|
+
scheme https
|
400
|
+
path /es/
|
401
|
+
user john
|
402
|
+
password doe
|
403
|
+
templates {"logstash1":"#{template_file}", "logstash2":"#{template_file}","logstash3":"#{template_file}" }
|
404
|
+
template_overwrite true
|
405
|
+
}
|
406
|
+
|
407
|
+
stub_request(:head, "https://john:doe@logs.google.com:777/es//").
|
408
|
+
to_return(:status => 200, :body => "", :headers => {})
|
409
|
+
# check if template exists
|
410
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash1").
|
411
|
+
to_return(:status => 200, :body => "", :headers => {})
|
412
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash2").
|
413
|
+
to_return(:status => 200, :body => "", :headers => {})
|
414
|
+
stub_request(:get, "https://john:doe@logs.google.com:777/es//_template/logstash3").
|
415
|
+
to_return(:status => 200, :body => "", :headers => {}) #exists
|
416
|
+
|
417
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1").
|
418
|
+
to_return(:status => 200, :body => "", :headers => {})
|
419
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2").
|
420
|
+
to_return(:status => 200, :body => "", :headers => {})
|
421
|
+
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3").
|
422
|
+
to_return(:status => 200, :body => "", :headers => {})
|
423
|
+
|
424
|
+
driver(config)
|
425
|
+
|
426
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
|
427
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2", times: 1)
|
428
|
+
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3", times: 1)
|
429
|
+
end
|
430
|
+
|
358
431
|
def test_templates_not_used
|
359
432
|
cwd = File.dirname(__FILE__)
|
360
433
|
template_file = File.join(cwd, 'test_template.json')
|