fluent-plugin-elasticsearch 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +4 -0
- data/ISSUE_TEMPLATE.md +5 -1
- data/README.md +67 -17
- data/fluent-plugin-elasticsearch.gemspec +3 -3
- data/lib/fluent/plugin/out_elasticsearch.rb +20 -6
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +4 -2
- data/test/plugin/test_out_elasticsearch.rb +102 -0
- data/test/plugin/test_out_elasticsearch_dynamic.rb +102 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d722819bc4644442e84bd13acbd6d1fe7845d6fc01119d3a4c8475321d1195d
|
4
|
+
data.tar.gz: a4956fa749f46343aa3609cc319cff6c5e28797b50384ece1284566ee773045f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55cb3916853e0a3ad24bc450aecd577f13cbcb20f8d9a4b446ffa4beb7dce6df5fcd8ca4583846f53921b69404421f3bd8a714dedaac596745600a4b7084744e
|
7
|
+
data.tar.gz: e46f86ba7109bce5f51628f3209497c3a5ec706641f25cb267391a173384acc26c626bce2f1280d1d72f1cebb7e9188f76afa6baf1246e2b01f6f5e3c913b3f5
|
data/History.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
- Log ES response errors (#230)
|
5
5
|
- Use latest elasticsearch-ruby (#240)
|
6
6
|
|
7
|
+
### 2.5.0
|
8
|
+
- Using nested record in `id_key`, `parent_key`, and `routing_key` (#351
|
9
|
+
- Fix inverted case of a proper noun "Elasticsearch" (#349)
|
10
|
+
|
7
11
|
### 2.4.1
|
8
12
|
- Add config parameter to enable elasticsearch-ruby's transporter logging (#342)
|
9
13
|
|
data/ISSUE_TEMPLATE.md
CHANGED
@@ -16,5 +16,9 @@ Provide example config and message
|
|
16
16
|
|
17
17
|
#### Using Fluentd and ES plugin versions
|
18
18
|
|
19
|
-
*
|
19
|
+
* OS version
|
20
|
+
* Fluentd v0.12 or v0.14/v1.0
|
21
|
+
* paste result of ``fluentd --version`` or ``td-agent --version``
|
20
22
|
* ES plugin 2.x.y or 1.x.y
|
23
|
+
* paste boot log of fluentd or td-agent
|
24
|
+
* paste result of ``fluent-gem list``, ``td-agent-gem list`` or your Gemfile.lock
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[![Issue Stats](http://issuestats.com/github/uken/fluent-plugin-elasticsearch/badge/pr)](http://issuestats.com/github/uken/fluent-plugin-elasticsearch)
|
8
8
|
[![Issue Stats](http://issuestats.com/github/uken/fluent-plugin-elasticsearch/badge/issue)](http://issuestats.com/github/uken/fluent-plugin-elasticsearch)
|
9
9
|
|
10
|
-
Send your logs to
|
10
|
+
Send your logs to Elasticsearch (and search them with Kibana maybe?)
|
11
11
|
|
12
12
|
Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-elasticsearch-service](https://github.com/atomita/fluent-plugin-aws-elasticsearch-service)
|
13
13
|
|
@@ -68,7 +68,7 @@ Current maintainers: @cosmo0920
|
|
68
68
|
|
69
69
|
| fluent-plugin-elasticsearch | fluentd | ruby |
|
70
70
|
|-------------------|---------|------|
|
71
|
-
| >= 2.0.0 | >= v0.14.
|
71
|
+
| >= 2.0.0 | >= v0.14.20 | >= 2.1 |
|
72
72
|
| < 2.0.0 | >= v0.12.0 | >= 1.9 |
|
73
73
|
|
74
74
|
NOTE: For v0.12 version, you should use 1.x.y version. Please send patch into v0.12 branch if you encountered 1.x version's bug.
|
@@ -95,7 +95,7 @@ In your Fluentd configuration, use `@type elasticsearch`. Additional configurati
|
|
95
95
|
|
96
96
|
### Index templates
|
97
97
|
|
98
|
-
This plugin creates
|
98
|
+
This plugin creates Elasticsearch indices by merely writing to them. Consider using [Index Templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) to gain control of what get indexed and how. See [this example](https://github.com/uken/fluent-plugin-elasticsearch/issues/33#issuecomment-38693282) for a good starting point.
|
99
99
|
|
100
100
|
## Configuration
|
101
101
|
|
@@ -107,9 +107,9 @@ hosts host1:port1,host2:port2,host3:port3
|
|
107
107
|
hosts https://customhost.com:443/path,https://username:password@host-failover.com:443
|
108
108
|
```
|
109
109
|
|
110
|
-
You can specify multiple
|
110
|
+
You can specify multiple Elasticsearch hosts with separator ",".
|
111
111
|
|
112
|
-
If you specify multiple hosts, this plugin will load balance updates to
|
112
|
+
If you specify multiple hosts, this plugin will load balance updates to Elasticsearch. This is an [elasticsearch-ruby](https://github.com/elasticsearch/elasticsearch-ruby) feature, the default strategy is round-robin.
|
113
113
|
|
114
114
|
And this plugin will escape required URL encoded characters within `%{}` placeholders.
|
115
115
|
|
@@ -145,7 +145,7 @@ Specify `ssl_verify false` to skip ssl verification (defaults to true)
|
|
145
145
|
logstash_format true # defaults to false
|
146
146
|
```
|
147
147
|
|
148
|
-
This is meant to make writing data into
|
148
|
+
This is meant to make writing data into Elasticsearch indices compatible to what [Logstash](https://www.elastic.co/products/logstash) calls them. By doing this, one could take advantage of [Kibana](https://www.elastic.co/products/kibana). See logstash_prefix and logstash_dateformat to customize this index name pattern. The index name will be `#{logstash_prefix}-#{formated_date}`
|
149
149
|
|
150
150
|
:warning: Setting this option to `true` will ignore the `index_name` setting. The default index name prefix is `logstash-`.
|
151
151
|
|
@@ -332,7 +332,7 @@ One of [template_file](#template_file) or [templates](#templates) must also be s
|
|
332
332
|
|
333
333
|
You can specify HTTP request timeout.
|
334
334
|
|
335
|
-
This is useful when
|
335
|
+
This is useful when Elasticsearch cannot return response for bulk request within the default of 5 seconds.
|
336
336
|
|
337
337
|
```
|
338
338
|
request_timeout 15s # defaults to 5s
|
@@ -340,7 +340,7 @@ request_timeout 15s # defaults to 5s
|
|
340
340
|
|
341
341
|
### reload_connections
|
342
342
|
|
343
|
-
You can tune how the elasticsearch-transport host reloading feature works. By default it will reload the host list from the server every 10,000th request to spread the load. This can be an issue if your
|
343
|
+
You can tune how the elasticsearch-transport host reloading feature works. By default it will reload the host list from the server every 10,000th request to spread the load. This can be an issue if your Elasticsearch cluster is behind a Reverse Proxy, as Fluentd process may not have direct network access to the Elasticsearch nodes.
|
344
344
|
|
345
345
|
```
|
346
346
|
reload_connections false # defaults to true
|
@@ -380,7 +380,7 @@ This will add the Fluentd tag in the JSON record. For instance, if you have a co
|
|
380
380
|
</match>
|
381
381
|
```
|
382
382
|
|
383
|
-
The record inserted into
|
383
|
+
The record inserted into Elasticsearch would be
|
384
384
|
|
385
385
|
```
|
386
386
|
{"_key": "my.logs", "name": "Johnny Doeie"}
|
@@ -392,9 +392,9 @@ The record inserted into ElasticSearch would be
|
|
392
392
|
id_key request_id # use "request_id" field as a record id in ES
|
393
393
|
```
|
394
394
|
|
395
|
-
By default, all records inserted into
|
395
|
+
By default, all records inserted into Elasticsearch get a random _id. This option allows to use a field in the record as an identifier.
|
396
396
|
|
397
|
-
This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will trigger the following
|
397
|
+
This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will trigger the following Elasticsearch command
|
398
398
|
|
399
399
|
```
|
400
400
|
{ "index" : { "_index": "logstash-2013.01.01", "_type": "fluentd", "_id": "87d89af7daffad6" } }
|
@@ -422,7 +422,32 @@ Example configuration for [fluent-plugin-genhashvalue](https://github.com/mtakem
|
|
422
422
|
</filter>
|
423
423
|
```
|
424
424
|
|
425
|
-
:warning: In order to avoid hash-collisions and loosing data careful consideration is required when choosing the keys in the event record that should be used to calculate the hash
|
425
|
+
:warning: In order to avoid hash-collisions and loosing data careful consideration is required when choosing the keys in the event record that should be used to calculate the hash
|
426
|
+
|
427
|
+
#### Using nested key
|
428
|
+
|
429
|
+
Nested key specifying syntax is also supported.
|
430
|
+
|
431
|
+
With the following configuration
|
432
|
+
|
433
|
+
```aconf
|
434
|
+
id_key $.nested.request_id
|
435
|
+
```
|
436
|
+
|
437
|
+
and the following nested record
|
438
|
+
|
439
|
+
```json
|
440
|
+
{"nested":{"name": "Johnny", "request_id": "87d89af7daffad6"}}
|
441
|
+
```
|
442
|
+
|
443
|
+
will trigger the following Elasticsearch command
|
444
|
+
|
445
|
+
```
|
446
|
+
{"index":{"_index":"fluentd","_type":"fluentd","_id":"87d89af7daffad6"}}
|
447
|
+
{"nested":{"name":"Johnny","request_id":"87d89af7daffad6"}}
|
448
|
+
```
|
449
|
+
|
450
|
+
:warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
|
426
451
|
|
427
452
|
### parent_key
|
428
453
|
|
@@ -435,7 +460,7 @@ If your input is
|
|
435
460
|
{ "name": "Johnny", "a_parent": "my_parent" }
|
436
461
|
```
|
437
462
|
|
438
|
-
|
463
|
+
Elasticsearch command would be
|
439
464
|
|
440
465
|
```
|
441
466
|
{ "index" : { "_index": "****", "_type": "****", "_id": "****", "_parent": "my_parent" } }
|
@@ -444,6 +469,31 @@ ElasticSearch command would be
|
|
444
469
|
|
445
470
|
if `parent_key` is not configed or the `parent_key` is absent in input record, nothing will happen.
|
446
471
|
|
472
|
+
#### Using nested key
|
473
|
+
|
474
|
+
Nested key specifying syntax is also supported.
|
475
|
+
|
476
|
+
With the following configuration
|
477
|
+
|
478
|
+
```aconf
|
479
|
+
parent_key $.nested.a_parent
|
480
|
+
```
|
481
|
+
|
482
|
+
and the following nested record
|
483
|
+
|
484
|
+
```json
|
485
|
+
{"nested":{ "name": "Johnny", "a_parent": "my_parent" }}
|
486
|
+
```
|
487
|
+
|
488
|
+
will trigger the following Elasticsearch command
|
489
|
+
|
490
|
+
```
|
491
|
+
{"index":{"_index":"fluentd","_type":"fluentd","_parent":"my_parent"}}
|
492
|
+
{"nested":{"name":"Johnny","a_parent":"my_parent"}}
|
493
|
+
```
|
494
|
+
|
495
|
+
:warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
|
496
|
+
|
447
497
|
### routing_key
|
448
498
|
|
449
499
|
Similar to `parent_key` config, will add `_routing` into elasticsearch command if `routing_key` is set and the field does exist in input event.
|
@@ -520,12 +570,12 @@ with_transporter_log true
|
|
520
570
|
|
521
571
|
### Client/host certificate options
|
522
572
|
|
523
|
-
Need to verify
|
573
|
+
Need to verify Elasticsearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
|
524
574
|
```
|
525
575
|
ca_file /path/to/your/ca/cert
|
526
576
|
```
|
527
577
|
|
528
|
-
Does your
|
578
|
+
Does your Elasticsearch cluster want to verify client connections? You can specify the following parameters to use your client certificate, key, and key password for your connection.
|
529
579
|
```
|
530
580
|
client_cert /path/to/your/client/cert
|
531
581
|
client_key /path/to/your/private/key
|
@@ -600,7 +650,7 @@ Here is a sample config:
|
|
600
650
|
|
601
651
|
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.
|
602
652
|
|
603
|
-
Alternatively, consider using [fluent-plugin-forest](https://github.com/tagomoris/fluent-plugin-forest). For example, to configure multiple tags to be sent to different
|
653
|
+
Alternatively, consider using [fluent-plugin-forest](https://github.com/tagomoris/fluent-plugin-forest). For example, to configure multiple tags to be sent to different Elasticsearch indices:
|
604
654
|
|
605
655
|
```
|
606
656
|
<match my.logs.*>
|
@@ -620,7 +670,7 @@ And yet another option is described in Dynamic Configuration section.
|
|
620
670
|
|
621
671
|
### Dynamic configuration
|
622
672
|
|
623
|
-
If you want configurations to depend on information in messages, you can use `elasticsearch_dynamic`. This is an experimental variation of the
|
673
|
+
If you want configurations to depend on information in messages, you can use `elasticsearch_dynamic`. This is an experimental variation of the Elasticsearch plugin allows configuration values to be specified in ways such as the below:
|
624
674
|
|
625
675
|
```
|
626
676
|
<match my.logs.*>
|
@@ -3,10 +3,10 @@ $:.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.5.0'
|
7
7
|
s.authors = ['diogo', 'pitr']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
|
9
|
-
s.description = %q{
|
9
|
+
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
10
10
|
s.summary = s.description
|
11
11
|
s.homepage = 'https://github.com/uken/fluent-plugin-elasticsearch'
|
12
12
|
s.license = 'Apache-2.0'
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'fluentd', '>= 0.14.
|
21
|
+
s.add_runtime_dependency 'fluentd', '>= 0.14.20'
|
22
22
|
s.add_runtime_dependency 'excon', '>= 0'
|
23
23
|
s.add_runtime_dependency 'elasticsearch'
|
24
24
|
|
@@ -19,7 +19,7 @@ module Fluent::Plugin
|
|
19
19
|
class ElasticsearchOutput < Output
|
20
20
|
class ConnectionFailure < StandardError; end
|
21
21
|
|
22
|
-
helpers :event_emitter, :compat_parameters
|
22
|
+
helpers :event_emitter, :compat_parameters, :record_accessor
|
23
23
|
|
24
24
|
Fluent::Plugin.register_output('elasticsearch', self)
|
25
25
|
|
@@ -120,6 +120,11 @@ module Fluent::Plugin
|
|
120
120
|
templates_hash_install(@templates, @template_overwrite)
|
121
121
|
end
|
122
122
|
|
123
|
+
# Consider missing the prefix of "$." in nested key specifiers.
|
124
|
+
@id_key = convert_compat_id_key(@id_key) if @id_key
|
125
|
+
@parent_key = convert_compat_id_key(@parent_key) if @parent_key
|
126
|
+
@routing_key = convert_compat_id_key(@routing_key) if @routing_key
|
127
|
+
|
123
128
|
@meta_config_map = create_meta_config_map
|
124
129
|
|
125
130
|
begin
|
@@ -147,11 +152,18 @@ module Fluent::Plugin
|
|
147
152
|
end
|
148
153
|
end
|
149
154
|
|
155
|
+
def convert_compat_id_key(key)
|
156
|
+
if key.include?('.') && !key.start_with?('$[')
|
157
|
+
key = "$.#{key}" unless key.start_with?('$.')
|
158
|
+
end
|
159
|
+
key
|
160
|
+
end
|
161
|
+
|
150
162
|
def create_meta_config_map
|
151
163
|
result = []
|
152
|
-
result << [@id_key, '_id'] if @id_key
|
153
|
-
result << [@parent_key, '_parent'] if @parent_key
|
154
|
-
result << [@routing_key, '_routing'] if @routing_key
|
164
|
+
result << [record_accessor_create(@id_key), '_id'] if @id_key
|
165
|
+
result << [record_accessor_create(@parent_key), '_parent'] if @parent_key
|
166
|
+
result << [record_accessor_create(@routing_key), '_routing'] if @routing_key
|
155
167
|
result
|
156
168
|
end
|
157
169
|
|
@@ -403,8 +415,10 @@ module Fluent::Plugin
|
|
403
415
|
meta["pipeline".freeze] = @pipeline
|
404
416
|
end
|
405
417
|
|
406
|
-
@meta_config_map.each do |
|
407
|
-
|
418
|
+
@meta_config_map.each do |record_accessor, meta_key|
|
419
|
+
if raw_value = record_accessor.call(record)
|
420
|
+
meta[meta_key] = raw_value
|
421
|
+
end
|
408
422
|
end
|
409
423
|
|
410
424
|
if @remove_keys
|
@@ -187,8 +187,10 @@ module Fluent::Plugin
|
|
187
187
|
meta = {"_index" => target_index, "_type" => dynamic_conf['type_name']}
|
188
188
|
|
189
189
|
@meta_config_map.each_pair do |config_name, meta_key|
|
190
|
-
if dynamic_conf[config_name] &&
|
191
|
-
|
190
|
+
if dynamic_conf[config_name] && accessor = record_accessor_create(dynamic_conf[config_name])
|
191
|
+
if raw_value = accessor.call(record)
|
192
|
+
meta[meta_key] = raw_value
|
193
|
+
end
|
192
194
|
end
|
193
195
|
end
|
194
196
|
|
@@ -34,6 +34,12 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
34
34
|
{'age' => 26, 'request_id' => '42', 'parent_id' => 'parent', 'routing_id' => 'routing'}
|
35
35
|
end
|
36
36
|
|
37
|
+
def nested_sample_record
|
38
|
+
{'nested' =>
|
39
|
+
{'age' => 26, 'parent_id' => 'parent', 'routing_id' => 'routing', 'request_id' => '42'}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
37
43
|
def stub_elastic_ping(url="http://localhost:9200")
|
38
44
|
stub_request(:head, url).to_return(:status => 200, :body => "", :headers => {})
|
39
45
|
end
|
@@ -1429,6 +1435,38 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1429
1435
|
assert_equal(index_cmds[0]['index']['_id'], '42')
|
1430
1436
|
end
|
1431
1437
|
|
1438
|
+
class NestedIdKeyTest < self
|
1439
|
+
def test_adds_nested_id_key_with_dot
|
1440
|
+
driver.configure("id_key nested.request_id\n")
|
1441
|
+
stub_elastic_ping
|
1442
|
+
stub_elastic
|
1443
|
+
driver.run(default_tag: 'test') do
|
1444
|
+
driver.feed(nested_sample_record)
|
1445
|
+
end
|
1446
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
def test_adds_nested_id_key_with_dollar_dot
|
1450
|
+
driver.configure("id_key $.nested.request_id\n")
|
1451
|
+
stub_elastic_ping
|
1452
|
+
stub_elastic
|
1453
|
+
driver.run(default_tag: 'test') do
|
1454
|
+
driver.feed(nested_sample_record)
|
1455
|
+
end
|
1456
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
def test_adds_nested_id_key_with_bracket
|
1460
|
+
driver.configure("id_key $['nested']['request_id']\n")
|
1461
|
+
stub_elastic_ping
|
1462
|
+
stub_elastic
|
1463
|
+
driver.run(default_tag: 'test') do
|
1464
|
+
driver.feed(nested_sample_record)
|
1465
|
+
end
|
1466
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
1467
|
+
end
|
1468
|
+
end
|
1469
|
+
|
1432
1470
|
def test_doesnt_add_id_key_if_missing_when_configured
|
1433
1471
|
driver.configure("id_key another_request_id\n")
|
1434
1472
|
stub_elastic_ping
|
@@ -1458,6 +1496,38 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1458
1496
|
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
1459
1497
|
end
|
1460
1498
|
|
1499
|
+
class NestedParentKeyTest < self
|
1500
|
+
def test_adds_nested_parent_key_with_dot
|
1501
|
+
driver.configure("parent_key nested.parent_id\n")
|
1502
|
+
stub_elastic_ping
|
1503
|
+
stub_elastic
|
1504
|
+
driver.run(default_tag: 'test') do
|
1505
|
+
driver.feed(nested_sample_record)
|
1506
|
+
end
|
1507
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
def test_adds_nested_parent_key_with_dollar_dot
|
1511
|
+
driver.configure("parent_key $.nested.parent_id\n")
|
1512
|
+
stub_elastic_ping
|
1513
|
+
stub_elastic
|
1514
|
+
driver.run(default_tag: 'test') do
|
1515
|
+
driver.feed(nested_sample_record)
|
1516
|
+
end
|
1517
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
1518
|
+
end
|
1519
|
+
|
1520
|
+
def test_adds_nested_parent_key_with_bracket
|
1521
|
+
driver.configure("parent_key $['nested']['parent_id']\n")
|
1522
|
+
stub_elastic_ping
|
1523
|
+
stub_elastic
|
1524
|
+
driver.run(default_tag: 'test') do
|
1525
|
+
driver.feed(nested_sample_record)
|
1526
|
+
end
|
1527
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
1528
|
+
end
|
1529
|
+
end
|
1530
|
+
|
1461
1531
|
def test_doesnt_add_parent_key_if_missing_when_configured
|
1462
1532
|
driver.configure("parent_key another_parent_id\n")
|
1463
1533
|
stub_elastic_ping
|
@@ -1487,6 +1557,38 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1487
1557
|
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
1488
1558
|
end
|
1489
1559
|
|
1560
|
+
class NestedRoutingKeyTest < self
|
1561
|
+
def test_adds_nested_routing_key_with_dot
|
1562
|
+
driver.configure("routing_key nested.routing_id\n")
|
1563
|
+
stub_elastic_ping
|
1564
|
+
stub_elastic
|
1565
|
+
driver.run(default_tag: 'test') do
|
1566
|
+
driver.feed(nested_sample_record)
|
1567
|
+
end
|
1568
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
1569
|
+
end
|
1570
|
+
|
1571
|
+
def test_adds_nested_routing_key_with_dollar_dot
|
1572
|
+
driver.configure("routing_key $.nested.routing_id\n")
|
1573
|
+
stub_elastic_ping
|
1574
|
+
stub_elastic
|
1575
|
+
driver.run(default_tag: 'test') do
|
1576
|
+
driver.feed(nested_sample_record)
|
1577
|
+
end
|
1578
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
1579
|
+
end
|
1580
|
+
|
1581
|
+
def test_adds_nested_routing_key_with_bracket
|
1582
|
+
driver.configure("routing_key $['nested']['routing_id']\n")
|
1583
|
+
stub_elastic_ping
|
1584
|
+
stub_elastic
|
1585
|
+
driver.run(default_tag: 'test') do
|
1586
|
+
driver.feed(nested_sample_record)
|
1587
|
+
end
|
1588
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
1589
|
+
end
|
1590
|
+
end
|
1591
|
+
|
1490
1592
|
def test_doesnt_add_routing_key_if_missing_when_configured
|
1491
1593
|
driver.configure("routing_key another_routing_id\n")
|
1492
1594
|
stub_elastic_ping
|
@@ -31,6 +31,12 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
31
31
|
{'age' => 26, 'request_id' => '42', 'parent_id' => 'parent', 'routing_id' => 'routing'}
|
32
32
|
end
|
33
33
|
|
34
|
+
def nested_sample_record
|
35
|
+
{'nested' =>
|
36
|
+
{'age' => 26, 'parent_id' => 'parent', 'routing_id' => 'routing', 'request_id' => '42'}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
34
40
|
def stub_elastic_ping(url="http://localhost:9200")
|
35
41
|
stub_request(:head, url).to_return(:status => 200, :body => "", :headers => {})
|
36
42
|
end
|
@@ -582,6 +588,38 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
582
588
|
assert_equal(index_cmds[0]['index']['_id'], '42')
|
583
589
|
end
|
584
590
|
|
591
|
+
class NestedIdKeyTest < self
|
592
|
+
def test_adds_nested_id_key_with_dot
|
593
|
+
driver.configure("id_key nested.request_id\n")
|
594
|
+
stub_elastic_ping
|
595
|
+
stub_elastic
|
596
|
+
driver.run(default_tag: 'test') do
|
597
|
+
driver.feed(nested_sample_record)
|
598
|
+
end
|
599
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
600
|
+
end
|
601
|
+
|
602
|
+
def test_adds_nested_id_key_with_dollar_dot
|
603
|
+
driver.configure("id_key $.nested.request_id\n")
|
604
|
+
stub_elastic_ping
|
605
|
+
stub_elastic
|
606
|
+
driver.run(default_tag: 'test') do
|
607
|
+
driver.feed(nested_sample_record)
|
608
|
+
end
|
609
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
610
|
+
end
|
611
|
+
|
612
|
+
def test_adds_nested_id_key_with_bracket
|
613
|
+
driver.configure("id_key $['nested']['request_id']\n")
|
614
|
+
stub_elastic_ping
|
615
|
+
stub_elastic
|
616
|
+
driver.run(default_tag: 'test') do
|
617
|
+
driver.feed(nested_sample_record)
|
618
|
+
end
|
619
|
+
assert_equal(index_cmds[0]['index']['_id'], '42')
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
585
623
|
def test_doesnt_add_id_key_if_missing_when_configured
|
586
624
|
driver.configure("id_key another_request_id\n")
|
587
625
|
stub_elastic_ping
|
@@ -611,6 +649,38 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
611
649
|
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
612
650
|
end
|
613
651
|
|
652
|
+
class NestedParentKeyTest < self
|
653
|
+
def test_adds_nested_parent_key_with_dot
|
654
|
+
driver.configure("parent_key nested.parent_id\n")
|
655
|
+
stub_elastic_ping
|
656
|
+
stub_elastic
|
657
|
+
driver.run(default_tag: 'test') do
|
658
|
+
driver.feed(nested_sample_record)
|
659
|
+
end
|
660
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
661
|
+
end
|
662
|
+
|
663
|
+
def test_adds_nested_parent_key_with_dollar_dot
|
664
|
+
driver.configure("parent_key $.nested.parent_id\n")
|
665
|
+
stub_elastic_ping
|
666
|
+
stub_elastic
|
667
|
+
driver.run(default_tag: 'test') do
|
668
|
+
driver.feed(nested_sample_record)
|
669
|
+
end
|
670
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
671
|
+
end
|
672
|
+
|
673
|
+
def test_adds_nested_parent_key_with_bracket
|
674
|
+
driver.configure("parent_key $['nested']['parent_id']\n")
|
675
|
+
stub_elastic_ping
|
676
|
+
stub_elastic
|
677
|
+
driver.run(default_tag: 'test') do
|
678
|
+
driver.feed(nested_sample_record)
|
679
|
+
end
|
680
|
+
assert_equal(index_cmds[0]['index']['_parent'], 'parent')
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
614
684
|
def test_doesnt_add_parent_key_if_missing_when_configured
|
615
685
|
driver.configure("parent_key another_parent_id\n")
|
616
686
|
stub_elastic_ping
|
@@ -640,6 +710,38 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
|
|
640
710
|
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
641
711
|
end
|
642
712
|
|
713
|
+
class NestedRoutingKeyTest < self
|
714
|
+
def test_adds_nested_routing_key_with_dot
|
715
|
+
driver.configure("routing_key nested.routing_id\n")
|
716
|
+
stub_elastic_ping
|
717
|
+
stub_elastic
|
718
|
+
driver.run(default_tag: 'test') do
|
719
|
+
driver.feed(nested_sample_record)
|
720
|
+
end
|
721
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
722
|
+
end
|
723
|
+
|
724
|
+
def test_adds_nested_routing_key_with_dollar_dot
|
725
|
+
driver.configure("routing_key $.nested.routing_id\n")
|
726
|
+
stub_elastic_ping
|
727
|
+
stub_elastic
|
728
|
+
driver.run(default_tag: 'test') do
|
729
|
+
driver.feed(nested_sample_record)
|
730
|
+
end
|
731
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
732
|
+
end
|
733
|
+
|
734
|
+
def test_adds_nested_routing_key_with_bracket
|
735
|
+
driver.configure("routing_key $['nested']['routing_id']\n")
|
736
|
+
stub_elastic_ping
|
737
|
+
stub_elastic
|
738
|
+
driver.run(default_tag: 'test') do
|
739
|
+
driver.feed(nested_sample_record)
|
740
|
+
end
|
741
|
+
assert_equal(index_cmds[0]['index']['_routing'], 'routing')
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
643
745
|
def test_doesnt_add_routing_key_if_missing_when_configured
|
644
746
|
driver.configure("routing_key another_routing_id\n")
|
645
747
|
stub_elastic_ping
|
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.
|
4
|
+
version: 2.5.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:
|
12
|
+
date: 2018-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.14.
|
20
|
+
version: 0.14.20
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.14.
|
27
|
+
version: 0.14.20
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: excon
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '2.0'
|
126
|
-
description:
|
126
|
+
description: Elasticsearch output plugin for Fluent event collector
|
127
127
|
email:
|
128
128
|
- pitr.vern@gmail.com
|
129
129
|
- me@diogoterror.com
|
@@ -175,10 +175,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.7.3
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
|
-
summary:
|
181
|
+
summary: Elasticsearch output plugin for Fluent event collector
|
182
182
|
test_files:
|
183
183
|
- test/helper.rb
|
184
184
|
- test/plugin/test_filter_elasticsearch_genid.rb
|