fluent-plugin-elasticsearch 4.0.9 → 4.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/issue-auto-closer.yml +12 -0
- data/History.md +9 -0
- data/README.ElasticsearchGenID.md +116 -0
- data/README.md +24 -2
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/filter_elasticsearch_genid.rb +52 -0
- data/lib/fluent/plugin/out_elasticsearch.rb +18 -11
- data/test/plugin/test_filter_elasticsearch_genid.rb +171 -0
- data/test/plugin/test_out_elasticsearch.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a12dc6596a56b7486d45129b64187021215433d2e7aa5428e96712fb63a345b5
|
4
|
+
data.tar.gz: 6fe5296f4a0afa23e863399f6d1cc9eeaa8f70c55e5cb979ca8db1bbf7a8988f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5d200eb1dee56f9f4fc05efc46cdbf440e0e2df7152e527985b124ac91ff74b0d263bee36f69fddec9f5ccc3730032145d51a95cc22fc00817f909fd4c2a7a
|
7
|
+
data.tar.gz: 11b0453ea6cbcfaf46e71866a96daf4ceba8f3877dd23e7aa124ea214f056b1b7f56bd8082ae273883a7403a2f1752c64beb377a2a3564c1d30757a8a5f101fa
|
@@ -0,0 +1,12 @@
|
|
1
|
+
name: Autocloser
|
2
|
+
on: [issues]
|
3
|
+
jobs:
|
4
|
+
autoclose:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- name: Autoclose issues that did not follow issue template
|
8
|
+
uses: roots/issue-closer-action@v1.1
|
9
|
+
with:
|
10
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
11
|
+
issue-close-message: "@${issue.user.login} this issue was automatically closed because it did not follow the issue template."
|
12
|
+
issue-pattern: "(.*Problem.*)|(.*Expected Behavior or What you need to ask.*)|(.*Using Fluentd and ES plugin versions.*)"
|
data/History.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
4
|
|
5
|
+
### 4.0.10
|
6
|
+
- filter_elasticsearch_genid: Use entire record as hash seed (#777)
|
7
|
+
- Suppress type in meta with suppress_type_name parameter (#774)
|
8
|
+
- filter\_elasticsearch\_genid: Add hash generation mechanism from events (#773)
|
9
|
+
- Clean up error text (#772)
|
10
|
+
- Use GitHub Actions badges instead of Travis' (#760)
|
11
|
+
- Add issue auto closer workflow (#759)
|
12
|
+
- Document required permissions (#757)
|
13
|
+
|
5
14
|
### 4.0.9
|
6
15
|
- Add possibility to configure multiple ILM policies (#753)
|
7
16
|
- Document required permissions (#757)
|
@@ -0,0 +1,116 @@
|
|
1
|
+
## Index
|
2
|
+
|
3
|
+
* [Usage](#usage)
|
4
|
+
* [Configuration](#configuration)
|
5
|
+
+ [hash_id_key](#hash_id_key)
|
6
|
+
+ [include_tag_in_seed](#include_tag_in_seed)
|
7
|
+
+ [include_time_in_seed](#include_time_in_seed)
|
8
|
+
+ [use_record_as_seed](#use_record_as_seed)
|
9
|
+
+ [use_entire_record](#use_entire_record)
|
10
|
+
+ [record_keys](#record_keys)
|
11
|
+
+ [separator](#separator)
|
12
|
+
+ [hash_type](#hash_type)
|
13
|
+
* [Advanced Usage](#advanced-usage)
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
In your Fluentd configuration, use `@type elasticsearch_genid`. Additional configuration is optional, default values would look like this:
|
18
|
+
|
19
|
+
```
|
20
|
+
<source>
|
21
|
+
@type elasticsearch_genid
|
22
|
+
hash_id_key _hash
|
23
|
+
include_tag_in_seed false
|
24
|
+
include_time_in_seed false
|
25
|
+
use_record_as_seed false
|
26
|
+
use_entire_record false
|
27
|
+
record_keys []
|
28
|
+
separator _
|
29
|
+
hash_type md5
|
30
|
+
</match>
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
### hash_id_key
|
36
|
+
|
37
|
+
```
|
38
|
+
hash_id_key _id
|
39
|
+
```
|
40
|
+
|
41
|
+
You can specify generated hash storing key.
|
42
|
+
|
43
|
+
### include_tag_in_seed
|
44
|
+
|
45
|
+
```
|
46
|
+
include_tag_in_seed true
|
47
|
+
```
|
48
|
+
|
49
|
+
You can specify to use tag for hash generation seed.
|
50
|
+
|
51
|
+
### include_time_in_seed
|
52
|
+
|
53
|
+
```
|
54
|
+
include_time_in_seed true
|
55
|
+
```
|
56
|
+
|
57
|
+
You can specify to use time for hash generation seed.
|
58
|
+
|
59
|
+
### use_record_as_seed
|
60
|
+
|
61
|
+
```
|
62
|
+
use_record_as_seed true
|
63
|
+
```
|
64
|
+
|
65
|
+
You can specify to use record in events for hash generation seed. This parameter should be used with [record_keys](#record_keys) parameter in practice.
|
66
|
+
|
67
|
+
### record_keys
|
68
|
+
|
69
|
+
```
|
70
|
+
record_keys request_id,pipeline_id
|
71
|
+
```
|
72
|
+
|
73
|
+
You can specify keys which are record in events for hash generation seed. This parameter should be used with [use_record_as_seed](#use_record_as_seed) parameter in practice.
|
74
|
+
|
75
|
+
### use_entire_record
|
76
|
+
|
77
|
+
```
|
78
|
+
use_entire_record true
|
79
|
+
```
|
80
|
+
|
81
|
+
You can specify to use entire record in events for hash generation seed.
|
82
|
+
|
83
|
+
|
84
|
+
### separator
|
85
|
+
|
86
|
+
```
|
87
|
+
separator |
|
88
|
+
```
|
89
|
+
|
90
|
+
You can specify separator charactor to creating seed for hash generation.
|
91
|
+
|
92
|
+
### hash_type
|
93
|
+
|
94
|
+
```
|
95
|
+
hash_type sha1
|
96
|
+
```
|
97
|
+
|
98
|
+
You can specify hash algorithm.
|
99
|
+
|
100
|
+
## Advanced Usage
|
101
|
+
|
102
|
+
Elasticsearch GenID plugin can handle record contents differing with the following parameters:
|
103
|
+
|
104
|
+
```aconf
|
105
|
+
<filter the.awesome.your.routing.tag>
|
106
|
+
@type elasticsearch_genid
|
107
|
+
use_entire_record true
|
108
|
+
hash_type sha1
|
109
|
+
hash_id_key _hash
|
110
|
+
separator _
|
111
|
+
inc_time_as_key true
|
112
|
+
inc_tag_as_key true
|
113
|
+
</filter>
|
114
|
+
```
|
115
|
+
|
116
|
+
The above configuration can handle tag, time, and record differing and generate different base64 encoded hash per record.
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Fluent::Plugin::Elasticsearch, a plugin for [Fluentd](http://fluentd.org)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-elasticsearch.png)](http://badge.fury.io/rb/fluent-plugin-elasticsearch)
|
4
|
-
|
4
|
+
![Testing on Windows](https://github.com/uken/fluent-plugin-elasticsearch/workflows/Testing%20on%20Windows/badge.svg?branch=master)
|
5
|
+
![Testing on macOS](https://github.com/uken/fluent-plugin-elasticsearch/workflows/Testing%20on%20macOS/badge.svg?branch=master)
|
6
|
+
![Testing on Ubuntu](https://github.com/uken/fluent-plugin-elasticsearch/workflows/Testing%20on%20Ubuntu/badge.svg?branch=master)
|
5
7
|
[![Coverage Status](https://coveralls.io/repos/uken/fluent-plugin-elasticsearch/badge.png)](https://coveralls.io/r/uken/fluent-plugin-elasticsearch)
|
6
8
|
[![Code Climate](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch.png)](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch)
|
7
9
|
|
@@ -31,6 +33,7 @@ Current maintainers: @cosmo0920
|
|
31
33
|
+ [time_key_exclude_timestamp](#time_key_exclude_timestamp)
|
32
34
|
+ [include_timestamp](#include_timestamp)
|
33
35
|
+ [utc_index](#utc_index)
|
36
|
+
+ [suppress_type_name](#suppress_type_name)
|
34
37
|
+ [target_index_key](#target_index_key)
|
35
38
|
+ [target_type_key](#target_type_key)
|
36
39
|
+ [template_name](#template_name)
|
@@ -97,6 +100,7 @@ Current maintainers: @cosmo0920
|
|
97
100
|
+ [ilm_policy_overwrite](#ilm_policy_overwrite)
|
98
101
|
+ [truncate_caches_interval](#truncate_caches_interval)
|
99
102
|
* [Configuration - Elasticsearch Input](#configuration---elasticsearch-input)
|
103
|
+
* [Configuration - Elasticsearch Filter GenID](#configuration---elasticsearch-filter-genid)
|
100
104
|
* [Elasticsearch permissions](#elasticsearch-permissions)
|
101
105
|
* [Troubleshooting](#troubleshooting)
|
102
106
|
+ [Cannot send events to elasticsearch](#cannot-send-events-to-elasticsearch)
|
@@ -351,6 +355,20 @@ utc_index true
|
|
351
355
|
|
352
356
|
By default, the records inserted into index `logstash-YYMMDD` with UTC (Coordinated Universal Time). This option allows to use local time if you describe utc_index to false.
|
353
357
|
|
358
|
+
### suppress_type_name
|
359
|
+
|
360
|
+
In Elasticsearch 7.x, Elasticsearch cluster complains the following types removal warnings:
|
361
|
+
|
362
|
+
```json
|
363
|
+
{"type": "deprecation", "timestamp": "2020-07-03T08:02:20,830Z", "level": "WARN", "component": "o.e.d.a.b.BulkRequestParser", "cluster.name": "docker-cluster", "node.name": "70dd5c6b94c3", "message": "[types removal] Specifying types in bulk requests is deprecated.", "cluster.uuid": "NoJJmtzfTtSzSMv0peG8Wg", "node.id": "VQ-PteHmTVam2Pnbg7xWHw" }
|
364
|
+
```
|
365
|
+
|
366
|
+
This can be suppressed with:
|
367
|
+
|
368
|
+
```
|
369
|
+
suppress_type_name true
|
370
|
+
```
|
371
|
+
|
354
372
|
### target_index_key
|
355
373
|
|
356
374
|
Tell this plugin to find the index name to write to in the record under this key in preference to other mechanisms. Key can be specified as path to nested record using dot ('.') as a separator.
|
@@ -985,7 +1003,7 @@ If you use Fluentd directly, you must pass the following lines as Fluentd comman
|
|
985
1003
|
|
986
1004
|
```
|
987
1005
|
sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
|
988
|
-
$ fluentd -r $sniffer
|
1006
|
+
$ fluentd -r $sniffer [AND YOUR OTHER OPTIONS]
|
989
1007
|
```
|
990
1008
|
|
991
1009
|
### Reload After
|
@@ -1243,6 +1261,10 @@ Default value is `nil`.
|
|
1243
1261
|
|
1244
1262
|
See [Elasticsearch Input plugin document](README.ElasticsearchInput.md)
|
1245
1263
|
|
1264
|
+
## Configuration - Elasticsearch Filter GenID
|
1265
|
+
|
1266
|
+
See [Elasticsearch Filter GenID document](README.ElasticsearchGenID.md)
|
1267
|
+
|
1246
1268
|
## Elasticsearch permissions
|
1247
1269
|
|
1248
1270
|
If the target Elasticsearch requires authentication, a user holding the necessary permissions needs to be provided.
|
@@ -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 = '4.0.
|
6
|
+
s.version = '4.0.10'
|
7
7
|
s.authors = ['diogo', 'pitr', 'Hiroshi Hatake']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com', 'cosmo0920.wp@gmail.com']
|
9
9
|
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
@@ -7,6 +7,13 @@ module Fluent::Plugin
|
|
7
7
|
Fluent::Plugin.register_filter('elasticsearch_genid', self)
|
8
8
|
|
9
9
|
config_param :hash_id_key, :string, :default => '_hash'
|
10
|
+
config_param :include_tag_in_seed, :bool, :default => false
|
11
|
+
config_param :include_time_in_seed, :bool, :default => false
|
12
|
+
config_param :use_record_as_seed, :bool, :default => false
|
13
|
+
config_param :use_entire_record, :bool, :default => false
|
14
|
+
config_param :record_keys, :array, :default => []
|
15
|
+
config_param :separator, :string, :default => '_'
|
16
|
+
config_param :hash_type, :enum, list: [:md5, :sha1, :sha256, :sha512], :default => :sha1
|
10
17
|
|
11
18
|
def initialize
|
12
19
|
super
|
@@ -14,12 +21,57 @@ module Fluent::Plugin
|
|
14
21
|
|
15
22
|
def configure(conf)
|
16
23
|
super
|
24
|
+
|
25
|
+
if !@use_entire_record
|
26
|
+
if @record_keys.empty? && @use_record_as_seed
|
27
|
+
raise Fluent::ConfigError, "When using record as hash seed, users must specify `record_keys`."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if @use_record_as_seed
|
32
|
+
class << self
|
33
|
+
alias_method :filter, :filter_seed_as_record
|
34
|
+
end
|
35
|
+
else
|
36
|
+
class << self
|
37
|
+
alias_method :filter, :filter_simple
|
38
|
+
end
|
39
|
+
end
|
17
40
|
end
|
18
41
|
|
19
42
|
def filter(tag, time, record)
|
43
|
+
# for safety.
|
44
|
+
end
|
45
|
+
|
46
|
+
def filter_simple(tag, time, record)
|
20
47
|
record[@hash_id_key] = Base64.strict_encode64(SecureRandom.uuid)
|
21
48
|
record
|
22
49
|
end
|
23
50
|
|
51
|
+
def filter_seed_as_record(tag, time, record)
|
52
|
+
seed = ""
|
53
|
+
seed += tag + separator if @include_tag_in_seed
|
54
|
+
seed += time.to_s + separator if @include_time_in_seed
|
55
|
+
if @use_entire_record
|
56
|
+
record.each {|k,v| seed += "|#{k}|#{v}"}
|
57
|
+
else
|
58
|
+
seed += record_keys.map {|k| record[k]}.join(separator)
|
59
|
+
end
|
60
|
+
record[@hash_id_key] = Base64.strict_encode64(encode_hash(@hash_type, seed))
|
61
|
+
record
|
62
|
+
end
|
63
|
+
|
64
|
+
def encode_hash(type, seed)
|
65
|
+
case type
|
66
|
+
when :md5
|
67
|
+
Digest::MD5.digest(seed)
|
68
|
+
when :sha1
|
69
|
+
Digest::SHA1.digest(seed)
|
70
|
+
when :sha256
|
71
|
+
Digest::SHA256.digest(seed)
|
72
|
+
when :sha512
|
73
|
+
Digest::SHA512.digest(seed)
|
74
|
+
end
|
75
|
+
end
|
24
76
|
end
|
25
77
|
end
|
@@ -90,6 +90,7 @@ EOC
|
|
90
90
|
config_param :logstash_dateformat, :string, :default => "%Y.%m.%d"
|
91
91
|
config_param :utc_index, :bool, :default => true
|
92
92
|
config_param :type_name, :string, :default => DEFAULT_TYPE_NAME
|
93
|
+
config_param :suppress_type_name, :bool, :default => false
|
93
94
|
config_param :index_name, :string, :default => "fluentd"
|
94
95
|
config_param :id_key, :string, :default => nil
|
95
96
|
config_param :write_operation, :string, :default => "index"
|
@@ -234,7 +235,7 @@ EOC
|
|
234
235
|
raise Fluent::ConfigError, "deflector_alias is prohibited to use with 'logstash_format at same time." if @logstash_format and @deflector_alias
|
235
236
|
end
|
236
237
|
if @ilm_policy.empty? && @ilm_policy_overwrite
|
237
|
-
raise Fluent::ConfigError, "ilm_policy_overwrite
|
238
|
+
raise Fluent::ConfigError, "ilm_policy_overwrite requires a non empty ilm_policy."
|
238
239
|
end
|
239
240
|
if @logstash_format || placeholder_substitution_needed_for_template?
|
240
241
|
class << self
|
@@ -304,16 +305,20 @@ EOC
|
|
304
305
|
else
|
305
306
|
@default_elasticsearch_version
|
306
307
|
end
|
307
|
-
if @
|
308
|
-
log.info "Detected ES 6.x: ES 7.x will only accept `_doc` in type_name."
|
309
|
-
end
|
310
|
-
if @last_seen_major_version == 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
311
|
-
log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
|
312
|
-
@type_name = '_doc'.freeze
|
313
|
-
end
|
314
|
-
if @last_seen_major_version >= 8 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
315
|
-
log.info "Detected ES 8.x or above: This parameter has no effect."
|
308
|
+
if @suppress_type_name && @last_seen_major_version >= 7
|
316
309
|
@type_name = nil
|
310
|
+
else
|
311
|
+
if @last_seen_major_version == 6 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
312
|
+
log.info "Detected ES 6.x: ES 7.x will only accept `_doc` in type_name."
|
313
|
+
end
|
314
|
+
if @last_seen_major_version == 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
315
|
+
log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
|
316
|
+
@type_name = '_doc'.freeze
|
317
|
+
end
|
318
|
+
if @last_seen_major_version >= 8 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
319
|
+
log.info "Detected ES 8.x or above: This parameter has no effect."
|
320
|
+
@type_name = nil
|
321
|
+
end
|
317
322
|
end
|
318
323
|
|
319
324
|
if @validate_client_version && !dry_run?
|
@@ -856,7 +861,9 @@ EOC
|
|
856
861
|
target_type = nil
|
857
862
|
end
|
858
863
|
else
|
859
|
-
if @
|
864
|
+
if @suppress_type_name && @last_seen_major_version >= 7
|
865
|
+
target_type = nil
|
866
|
+
elsif @last_seen_major_version == 7 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
860
867
|
log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
|
861
868
|
target_type = '_doc'.freeze
|
862
869
|
elsif @last_seen_major_version >= 8
|
@@ -18,6 +18,12 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
18
18
|
Fluent::Test::Driver::Filter.new(Fluent::Plugin::ElasticsearchGenidFilter).configure(conf)
|
19
19
|
end
|
20
20
|
|
21
|
+
test "invalid configuration" do
|
22
|
+
assert_raise(Fluent::ConfigError) do
|
23
|
+
create_driver("use_record_as_seed true")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
21
27
|
def sample_record
|
22
28
|
{'age' => 26, 'request_id' => '42', 'parent_id' => 'parent', 'routing_id' => 'routing'}
|
23
29
|
end
|
@@ -41,4 +47,169 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
41
47
|
assert_equal(Base64.strict_encode64(SecureRandom.uuid),
|
42
48
|
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
43
49
|
end
|
50
|
+
|
51
|
+
class UseRecordAsSeedTest < self
|
52
|
+
data("md5" => ["md5", "PPg+zmH1ASUCpNzMUcTzqw=="],
|
53
|
+
"sha1" => ["sha1", "JKfCrEAxeAyRSdcKqkw4unC9xZ8="],
|
54
|
+
"sha256" => ["sha256", "9Z9i+897bGivSItD/6i0vye9uRwq/sLwWkxOwydtTJY="],
|
55
|
+
"sha512" => ["sha512", "KWI5OdZPaCFW9/CEY3NoGrvueMtjZJdmGdqIVGJP8vgI4uW+0gHExZVaHerw+RhbtIdLCtVZ43xBgMKH+KliQg=="],
|
56
|
+
)
|
57
|
+
def test_simple(data)
|
58
|
+
hash_type, expected = data
|
59
|
+
d = create_driver(%[
|
60
|
+
use_record_as_seed true
|
61
|
+
record_keys age,parent_id,routing_id,custom_key
|
62
|
+
hash_type #{hash_type}
|
63
|
+
])
|
64
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
65
|
+
d.run(default_tag: 'test') do
|
66
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
67
|
+
end
|
68
|
+
assert_equal(expected,
|
69
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
70
|
+
end
|
71
|
+
|
72
|
+
data("md5" => ["md5", "qUO/xqWiOJq4D0ApdoHVEQ=="],
|
73
|
+
"sha1" => ["sha1", "v3UWYr90zIH2veGQBVwUH586TuI="],
|
74
|
+
"sha256" => ["sha256", "4hwh10qfw9B24NtNFoEFF8wCiImvgIy1Vk4gzcKt5Pw="],
|
75
|
+
"sha512" => ["sha512", "TY3arcmC8mhYClDIjQxH8ePRLnHK01Cj5QQL8FxbwNtPQBY3IZ4qJY9CpOusmdWBYwm1golRVQCmURiAhlnWIQ=="],)
|
76
|
+
def test_record_with_tag(data)
|
77
|
+
hash_type, expected = data
|
78
|
+
d = create_driver(%[
|
79
|
+
use_record_as_seed true
|
80
|
+
record_keys age,parent_id,routing_id,custom_key
|
81
|
+
hash_type #{hash_type}
|
82
|
+
include_tag_in_seed true
|
83
|
+
])
|
84
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
85
|
+
d.run(default_tag: 'test.fluentd') do
|
86
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
87
|
+
end
|
88
|
+
assert_equal(expected,
|
89
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
90
|
+
end
|
91
|
+
|
92
|
+
data("md5" => ["md5", "oHo+PoC5I4KC+XCfXvyf9w=="],
|
93
|
+
"sha1" => ["sha1", "50Nwarm2225gLy1ka8d9i+W6cKA="],
|
94
|
+
"sha256" => ["sha256", "ReX1XgizcrHjBc0sQwx9Sjuf2QBFll2njYf4ee+XSIc="],
|
95
|
+
"sha512" => ["sha512", "8bcpZrqNUQIz6opdoVZz0MwxP8r9SCqOEPkWF6xGLlFwPCJVqk2SQp99m8rPufr0xPIgvZyOMejA5slBV9xrdg=="],)
|
96
|
+
def test_record_with_time(data)
|
97
|
+
hash_type, expected = data
|
98
|
+
d = create_driver(%[
|
99
|
+
use_record_as_seed true
|
100
|
+
record_keys age,parent_id,routing_id,custom_key
|
101
|
+
hash_type #{hash_type}
|
102
|
+
include_time_in_seed true
|
103
|
+
])
|
104
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
105
|
+
d.run(default_tag: 'test.fluentd') do
|
106
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
107
|
+
end
|
108
|
+
assert_equal(expected,
|
109
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
110
|
+
end
|
111
|
+
|
112
|
+
data("md5" => ["md5", "u7/hr09gDC9CM5DI7tLc2Q=="],
|
113
|
+
"sha1" => ["sha1", "1WgptcTnVSHtTAlNUwNcoiaY3oM="],
|
114
|
+
"sha256" => ["sha256", "1iWZHI19m/A1VH8iFK7H2KFoyLdszpJRiVeKBv1Ndis="],
|
115
|
+
"sha512" => ["sha512", "NM+ui0lUmeDaEJsT7c9EyTc+lQBbRf1x6MQXXYdxp21CX3jZvHy3IT8Xp9ZdIKevZwhoo3Suo/tIBlfyLFXJXw=="],)
|
116
|
+
def test_record_with_tag_and_time
|
117
|
+
hash_type, expected = data
|
118
|
+
d = create_driver(%[
|
119
|
+
use_record_as_seed true
|
120
|
+
record_keys age,parent_id,routing_id,custom_key
|
121
|
+
hash_type #{hash_type}
|
122
|
+
include_tag_in_seed true
|
123
|
+
include_time_in_seed true
|
124
|
+
])
|
125
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
126
|
+
d.run(default_tag: 'test.fluentd') do
|
127
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
128
|
+
end
|
129
|
+
assert_equal(expected,
|
130
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class UseEntireRecordAsSeedTest < self
|
135
|
+
data("md5" => ["md5", "MuMU0gHOP1cWvvg/J4aEFg=="],
|
136
|
+
"sha1" => ["sha1", "GZ6Iup9Ywyk5spCWtPQbtZnfK0U="],
|
137
|
+
"sha256" => ["sha256", "O4YN0RiXCUAYeaR97UUULRLxgra/R2dvTV47viir5l4="],
|
138
|
+
"sha512" => ["sha512", "FtbwO1xsLUq0KcO0mj0l80rbwFH5rGE3vL+Vgh90+4R/9j+/Ni/ipwhiOoUcetDxj1r5Vf/92B54La+QTu3eMA=="],)
|
139
|
+
def test_record
|
140
|
+
hash_type, expected = data
|
141
|
+
d = create_driver(%[
|
142
|
+
use_record_as_seed true
|
143
|
+
use_entire_record true
|
144
|
+
hash_type #{hash_type}
|
145
|
+
])
|
146
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
147
|
+
d.run(default_tag: 'test.fluentd') do
|
148
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
149
|
+
end
|
150
|
+
assert_equal(expected,
|
151
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
152
|
+
end
|
153
|
+
|
154
|
+
data("md5" => ["md5", "GJfpWe8ofiGzn97bc9Gh0Q=="],
|
155
|
+
"sha1" => ["sha1", "AVaK67Tz0bEJ8xNEzjOQ6r9fAu4="],
|
156
|
+
"sha256" => ["sha256", "WIXWAuf/Z94Uw95mudloo2bgjhSsSduQIwkKTQsNFgU="],
|
157
|
+
"sha512" => ["sha512", "yjMGGxy8uc7gCrPgm8W6MzJGLFk0GtUwJ6w/91laf6WNywuvG/7T6kNHLagAV8rSW8xzxmtEfyValBO5scuoKw=="],)
|
158
|
+
def test_record_with_tag
|
159
|
+
hash_type, expected = data
|
160
|
+
d = create_driver(%[
|
161
|
+
use_record_as_seed true
|
162
|
+
use_entire_record true
|
163
|
+
hash_type #{hash_type}
|
164
|
+
include_tag_in_seed true
|
165
|
+
])
|
166
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
167
|
+
d.run(default_tag: 'test.fluentd') do
|
168
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
169
|
+
end
|
170
|
+
assert_equal(expected,
|
171
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
172
|
+
end
|
173
|
+
|
174
|
+
data("md5" => ["md5", "5nQSaJ4F1p9rDFign13Lfg=="],
|
175
|
+
"sha1" => ["sha1", "hyo9+0ZFBpizKl2NShs3C8yQcGw="],
|
176
|
+
"sha256" => ["sha256", "romVsZSIksbqYsOSnUzolZQw76ankcy0DgvDZ3CayTo="],
|
177
|
+
"sha512" => ["sha512", "RPU7K2Pt0iVyvV7p5usqcUIIOmfTajD1aa7pkR9qZ89UARH/lpm6ESY9iwuYJj92lxOUuF5OxlEwvV7uXJ07iA=="],)
|
178
|
+
def test_record_with_time
|
179
|
+
hash_type, expected = data
|
180
|
+
d = create_driver(%[
|
181
|
+
use_record_as_seed true
|
182
|
+
use_entire_record true
|
183
|
+
hash_type #{hash_type}
|
184
|
+
include_time_in_seed true
|
185
|
+
])
|
186
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
187
|
+
d.run(default_tag: 'test.fluentd') do
|
188
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
189
|
+
end
|
190
|
+
assert_equal(expected,
|
191
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
192
|
+
end
|
193
|
+
|
194
|
+
data("md5" => ["md5", "zGQF35KlMUibJAcgkgQDtw=="],
|
195
|
+
"sha1" => ["sha1", "1x9RZO1xEuWps090qq4DUIsU9x8="],
|
196
|
+
"sha256" => ["sha256", "eulMz0eF56lBEf31aIs0OG2TGCH/aoPfZbRqfEOkAwk="],
|
197
|
+
"sha512" => ["sha512", "mIiYATtpdUFEFCIZg1FdKssIs7oWY0gJjhSSbet0ddUmqB+CiQAcAMTmrXO6AVSH0vsMvao/8vtC8AsIPfF1fA=="],)
|
198
|
+
def test_record_with_tag_and_time
|
199
|
+
hash_type, expected = data
|
200
|
+
d = create_driver(%[
|
201
|
+
use_record_as_seed true
|
202
|
+
use_entire_record true
|
203
|
+
hash_type #{hash_type}
|
204
|
+
include_tag_in_seed true
|
205
|
+
include_time_in_seed true
|
206
|
+
])
|
207
|
+
time = event_time("2017-10-15 15:00:23.34567890 UTC")
|
208
|
+
d.run(default_tag: 'test.fluentd') do
|
209
|
+
d.feed(time, sample_record.merge("custom_key" => "This is also encoded value."))
|
210
|
+
end
|
211
|
+
assert_equal(expected,
|
212
|
+
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
213
|
+
end
|
214
|
+
end
|
44
215
|
end
|
@@ -3147,6 +3147,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3147
3147
|
|
3148
3148
|
data("border" => {"es_version" => 6, "_type" => "mytype"},
|
3149
3149
|
"fixed_behavior"=> {"es_version" => 7, "_type" => "_doc"},
|
3150
|
+
"to be nil" => {"es_version" => 8, "_type" => nil},
|
3150
3151
|
)
|
3151
3152
|
def test_writes_to_speficied_type(data)
|
3152
3153
|
driver('', data["es_version"]).configure("type_name mytype\n")
|
@@ -3159,6 +3160,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3159
3160
|
|
3160
3161
|
data("border" => {"es_version" => 6, "_type" => "mytype.test"},
|
3161
3162
|
"fixed_behavior"=> {"es_version" => 7, "_type" => "_doc"},
|
3163
|
+
"to be nil" => {"es_version" => 8, "_type" => nil},
|
3162
3164
|
)
|
3163
3165
|
def test_writes_to_speficied_type_with_placeholders(data)
|
3164
3166
|
driver('', data["es_version"]).configure("type_name mytype.${tag}\n")
|
@@ -3169,6 +3171,20 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3169
3171
|
assert_equal(data['_type'], index_cmds.first['index']['_type'])
|
3170
3172
|
end
|
3171
3173
|
|
3174
|
+
data("border" => {"es_version" => 6, "_type" => "mytype.test"},
|
3175
|
+
"fixed_behavior"=> {"es_version" => 7, "_type" => nil},
|
3176
|
+
"to be nil" => {"es_version" => 8, "_type" => nil},
|
3177
|
+
)
|
3178
|
+
def test_writes_to_speficied_type_with_suppress_type_name(data)
|
3179
|
+
driver('', data["es_version"])
|
3180
|
+
.configure("type_name mytype.${tag}\nsuppress_type_name true")
|
3181
|
+
stub_elastic
|
3182
|
+
driver.run(default_tag: 'test') do
|
3183
|
+
driver.feed(sample_record)
|
3184
|
+
end
|
3185
|
+
assert_equal(data['_type'], index_cmds.first['index']['_type'])
|
3186
|
+
end
|
3187
|
+
|
3172
3188
|
data("old" => {"es_version" => 2, "_type" => "local-override"},
|
3173
3189
|
"old_behavior" => {"es_version" => 5, "_type" => "local-override"},
|
3174
3190
|
"border" => {"es_version" => 6, "_type" => "fluentd"},
|
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: 4.0.
|
4
|
+
version: 4.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- diogo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|
@@ -135,6 +135,7 @@ extra_rdoc_files: []
|
|
135
135
|
files:
|
136
136
|
- ".coveralls.yml"
|
137
137
|
- ".editorconfig"
|
138
|
+
- ".github/workflows/issue-auto-closer.yml"
|
138
139
|
- ".github/workflows/linux.yml"
|
139
140
|
- ".github/workflows/macos.yml"
|
140
141
|
- ".github/workflows/windows.yml"
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- ISSUE_TEMPLATE.md
|
147
148
|
- LICENSE.txt
|
148
149
|
- PULL_REQUEST_TEMPLATE.md
|
150
|
+
- README.ElasticsearchGenID.md
|
149
151
|
- README.ElasticsearchInput.md
|
150
152
|
- README.md
|
151
153
|
- Rakefile
|