fluent-plugin-elasticsearch 4.2.0 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- data/.github/workflows/issue-auto-closer.yml +1 -1
- data/History.md +24 -0
- data/README.ElasticsearchGenID.md +2 -2
- data/README.md +88 -3
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_index_template.rb +15 -11
- data/lib/fluent/plugin/out_elasticsearch.rb +60 -14
- data/test/plugin/test_elasticsearch_fallback_selector.rb +1 -0
- data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +3 -0
- data/test/plugin/test_elasticsearch_tls.rb +8 -2
- data/test/plugin/test_out_elasticsearch.rb +427 -31
- data/test/plugin/test_out_elasticsearch_dynamic.rb +7 -2
- 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: 69be22981ce5e59de9e573f933c29b51cbf8204ba849fb6ad3729482f94361c0
|
4
|
+
data.tar.gz: f20f079c0dfce9a2c763f89572f4b64e22b790e7b90a5eb542b5c129f6160bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 966e0aee9947dcfebe785713118dc014df4216ed34565e5a1672547a47eabef2cb93f15442165ca2249d633b272d41602a52d172675a1d8df50c83516c602ff8
|
7
|
+
data.tar.gz: 714f4b5048b78fad7d30fea2a5a0bce2d824fa2c6585ec480c3dd8bece71c9378a0faa0514906094a3a217662e12bc3d4e86ce9853b6e6977b077954b76fa489
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
name: Bug Report
|
3
|
+
about: Create a report to help us improve. If you have questions about ES plugin on kubernetes, please direct these to https://discuss.kubernetes.io/ before sumbit kubernetes related issue.
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
(check apply)
|
8
|
+
- [ ] read [the contribution guideline](https://github.com/uken/fluent-plugin-elasticsearch/blob/master/CONTRIBUTING.md)
|
9
|
+
- [ ] (optional) already reported 3rd party upstream repository or mailing list if you use k8s addon or helm charts.
|
10
|
+
|
11
|
+
#### Problem
|
12
|
+
|
13
|
+
...
|
14
|
+
|
15
|
+
#### Steps to replicate
|
16
|
+
|
17
|
+
Either clone and modify https://gist.github.com/pitr/9a518e840db58f435911
|
18
|
+
|
19
|
+
**OR**
|
20
|
+
|
21
|
+
Provide example config and message
|
22
|
+
|
23
|
+
#### Expected Behavior or What you need to ask
|
24
|
+
|
25
|
+
...
|
26
|
+
|
27
|
+
#### Using Fluentd and ES plugin versions
|
28
|
+
|
29
|
+
* OS version
|
30
|
+
* Bare Metal or within Docker or Kubernetes or others?
|
31
|
+
* Fluentd v0.12 or v0.14/v1.0
|
32
|
+
* paste result of ``fluentd --version`` or ``td-agent --version``
|
33
|
+
* ES plugin 3.x.y/2.x.y or 1.x.y
|
34
|
+
* paste boot log of fluentd or td-agent
|
35
|
+
* paste result of ``fluent-gem list``, ``td-agent-gem list`` or your Gemfile.lock
|
36
|
+
* ES version (optional)
|
37
|
+
* ES template(s) (optional)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
(check apply)
|
8
|
+
- [ ] read [the contribution guideline](https://github.com/uken/fluent-plugin-elasticsearch/blob/master/CONTRIBUTING.md)
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
|
12
|
+
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
13
|
+
|
14
|
+
**Describe the solution you'd like**
|
15
|
+
|
16
|
+
<!-- A clear and concise description of what you want to happen. -->
|
17
|
+
|
18
|
+
**Describe alternatives you've considered**
|
19
|
+
|
20
|
+
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
21
|
+
|
22
|
+
**Additional context**
|
23
|
+
|
24
|
+
<!-- Add any other context or screenshots about the feature request here. -->
|
@@ -9,4 +9,4 @@ jobs:
|
|
9
9
|
with:
|
10
10
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
11
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.*)"
|
12
|
+
issue-pattern: "(.*Problem.*)|(.*Expected Behavior or What you need to ask.*)|(.*Using Fluentd and ES plugin versions.*)|(.*Is your feature request related to a problem? Please describe.*)|(.*Describe the solution you'd like.*)|(.*Describe alternatives you've considered.*)"
|
data/History.md
CHANGED
@@ -2,6 +2,30 @@
|
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
4
|
|
5
|
+
### 4.3.2
|
6
|
+
- Use log.debug to dump ES 8.x _type information (#852)
|
7
|
+
|
8
|
+
### 4.3.1
|
9
|
+
- Unsplit huge records by default (#851)
|
10
|
+
|
11
|
+
### 4.3.0
|
12
|
+
- Add cloud_id & cloud_auth settings (#850)
|
13
|
+
- Fix failing tests on es6 client (#848)
|
14
|
+
- feat: retry on transport errors (#846)
|
15
|
+
- fix typo (#838)
|
16
|
+
- Remove unnecessary nil check (#826)
|
17
|
+
|
18
|
+
### 4.2.2
|
19
|
+
- Remove unnecessary nil check (#826)
|
20
|
+
- Fix ILM rollover index template pattern to apply index_separator (#825)
|
21
|
+
- Fix ILM rollover alias creation when a placeholder is used in index_name (#823)
|
22
|
+
- Add a note about the pitfalls of per-date indexes used with ILM (#822)
|
23
|
+
|
24
|
+
### 4.2.1
|
25
|
+
- Update a broken link (#821)
|
26
|
+
- Include chunk_id in records (#820)
|
27
|
+
- Fix a failing testcase (#818)
|
28
|
+
|
5
29
|
### 4.2.0
|
6
30
|
- ci: Add Ruby 2.7 jobs (#812)
|
7
31
|
- Support Elasticsearch new style template (#810)
|
@@ -17,7 +17,7 @@
|
|
17
17
|
In your Fluentd configuration, use `@type elasticsearch_genid`. Additional configuration is optional, default values would look like this:
|
18
18
|
|
19
19
|
```
|
20
|
-
<
|
20
|
+
<filter>
|
21
21
|
@type elasticsearch_genid
|
22
22
|
hash_id_key _hash
|
23
23
|
include_tag_in_seed false
|
@@ -27,7 +27,7 @@ In your Fluentd configuration, use `@type elasticsearch_genid`. Additional confi
|
|
27
27
|
record_keys []
|
28
28
|
separator _
|
29
29
|
hash_type sha1
|
30
|
-
</
|
30
|
+
</filter>
|
31
31
|
```
|
32
32
|
|
33
33
|
## Configuration
|
data/README.md
CHANGED
@@ -19,6 +19,8 @@ Current maintainers: @cosmo0920
|
|
19
19
|
* [Configuration](#configuration)
|
20
20
|
+ [host](#host)
|
21
21
|
+ [port](#port)
|
22
|
+
+ [cloud_id](#cloud_id)
|
23
|
+
+ [cloud_auth](#cloud_auth)
|
22
24
|
+ [emit_error_for_missing_id](#emit_error_for_missing_id)
|
23
25
|
+ [hosts](#hosts)
|
24
26
|
+ [user, password, path, scheme, ssl_verify](#user-password-path-scheme-ssl_verify)
|
@@ -102,6 +104,9 @@ Current maintainers: @cosmo0920
|
|
102
104
|
+ [ilm_policy_overwrite](#ilm_policy_overwrite)
|
103
105
|
+ [truncate_caches_interval](#truncate_caches_interval)
|
104
106
|
+ [use_legacy_template](#use_legacy_template)
|
107
|
+
+ [metadata section](#metadata-section)
|
108
|
+
+ [include_chunk_id](#include_chunk_id)
|
109
|
+
+ [chunk_id_key](#chunk_id_key)
|
105
110
|
* [Configuration - Elasticsearch Input](#configuration---elasticsearch-input)
|
106
111
|
* [Configuration - Elasticsearch Filter GenID](#configuration---elasticsearch-filter-genid)
|
107
112
|
* [Elasticsearch permissions](#elasticsearch-permissions)
|
@@ -184,6 +189,26 @@ port 9201 # defaults to 9200
|
|
184
189
|
|
185
190
|
You can specify Elasticsearch port by this parameter.
|
186
191
|
|
192
|
+
### cloud_id
|
193
|
+
|
194
|
+
```
|
195
|
+
cloud_id test-dep:ZXVyb3BlLXdlc3QxLmdjcC5jbG91ZC5lcy5pbyRiYZTA1Ng==
|
196
|
+
```
|
197
|
+
|
198
|
+
You can specify Elasticsearch cloud_id by this parameter.
|
199
|
+
|
200
|
+
If you specify `cloud_id` option then `cloud_auth` option is required.
|
201
|
+
If you specify `cloud_id` option, `host`, `port`, `user` and `password` options are ignored.
|
202
|
+
|
203
|
+
### cloud_auth
|
204
|
+
|
205
|
+
```
|
206
|
+
cloud_auth 'elastic:slkjdaooewkd87iqQ2O8EQYV'
|
207
|
+
```
|
208
|
+
|
209
|
+
You can specify Elasticsearch cloud_auth by this parameter.
|
210
|
+
|
211
|
+
|
187
212
|
### emit_error_for_missing_id
|
188
213
|
|
189
214
|
```
|
@@ -498,7 +523,7 @@ Specify the application name for the rollover index to be created.
|
|
498
523
|
application_name default # defaults to "default"
|
499
524
|
```
|
500
525
|
|
501
|
-
If [enable_ilm](#enable_ilm is set, then this parameter will be in effect otherwise ignored.
|
526
|
+
If [enable_ilm](#enable_ilm) is set, then this parameter will be in effect otherwise ignored.
|
502
527
|
|
503
528
|
### template_overwrite
|
504
529
|
|
@@ -921,7 +946,7 @@ Starting with version 0.8.0, this gem uses excon, which supports proxy with envi
|
|
921
946
|
|
922
947
|
### Buffer options
|
923
948
|
|
924
|
-
`fluentd-plugin-elasticsearch` extends [Fluentd's builtin Output plugin](https://docs.fluentd.org/
|
949
|
+
`fluentd-plugin-elasticsearch` extends [Fluentd's builtin Output plugin](https://docs.fluentd.org/output#overview) and use `compat_parameters` plugin helper. It adds the following options:
|
925
950
|
|
926
951
|
```
|
927
952
|
buffer_type memory
|
@@ -1140,6 +1165,8 @@ And yet another option is described in Dynamic Configuration section.
|
|
1140
1165
|
|
1141
1166
|
### Dynamic configuration
|
1142
1167
|
|
1168
|
+
**NOTE**: *`out_elasticsearch_dynamic` will be planned to be marked as deprecated.* Please don't use the new Fluentd configuration. This plugin is maintained for backward compatibility.
|
1169
|
+
|
1143
1170
|
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:
|
1144
1171
|
|
1145
1172
|
```
|
@@ -1252,7 +1279,7 @@ Default value is `true`.
|
|
1252
1279
|
|
1253
1280
|
Configure `bulk_message` request splitting threshold size.
|
1254
1281
|
|
1255
|
-
Default value is `
|
1282
|
+
Default value is `-1`(unlimited).
|
1256
1283
|
|
1257
1284
|
If you specify this size as negative number, `bulk_message` request splitting feature will be disabled.
|
1258
1285
|
|
@@ -1316,6 +1343,51 @@ Composable template documentation is [Put Index Template API | Elasticsearch Ref
|
|
1316
1343
|
|
1317
1344
|
Please confirm that whether the using Elasticsearch cluster(s) support the composable template feature or not when turn on the brand new feature with this parameter.
|
1318
1345
|
|
1346
|
+
## <metadata\> section
|
1347
|
+
|
1348
|
+
Users can specify whether including `chunk_id` information into records or not:
|
1349
|
+
|
1350
|
+
```aconf
|
1351
|
+
<match your.awesome.routing.tag>
|
1352
|
+
@type elasticsearch
|
1353
|
+
# Other configurations.
|
1354
|
+
<metadata>
|
1355
|
+
include_chunk_id true
|
1356
|
+
# chunk_id_key chunk_id # Default value is "chunk_id".
|
1357
|
+
</metadata>
|
1358
|
+
</match>
|
1359
|
+
```
|
1360
|
+
|
1361
|
+
### include_chunk_id
|
1362
|
+
|
1363
|
+
Whether including `chunk_id` for not. Default value is `false`.
|
1364
|
+
|
1365
|
+
```aconf
|
1366
|
+
<match your.awesome.routing.tag>
|
1367
|
+
@type elasticsearch
|
1368
|
+
# Other configurations.
|
1369
|
+
<metadata>
|
1370
|
+
include_chunk_id true
|
1371
|
+
</metadata>
|
1372
|
+
</match>
|
1373
|
+
```
|
1374
|
+
|
1375
|
+
|
1376
|
+
### chunk_id_key
|
1377
|
+
|
1378
|
+
Specify `chunk_id_key` to store `chunk_id` information into records. Default value is `chunk_id`.
|
1379
|
+
|
1380
|
+
```aconf
|
1381
|
+
<match your.awesome.routing.tag>
|
1382
|
+
@type elasticsearch
|
1383
|
+
# Other configurations.
|
1384
|
+
<metadata>
|
1385
|
+
include_chunk_id
|
1386
|
+
chunk_id_key chunk_hex
|
1387
|
+
</metadata>
|
1388
|
+
</match>
|
1389
|
+
```
|
1390
|
+
|
1319
1391
|
## Configuration - Elasticsearch Input
|
1320
1392
|
|
1321
1393
|
See [Elasticsearch Input plugin document](README.ElasticsearchInput.md)
|
@@ -1833,6 +1905,16 @@ template_name your-fluentd-template
|
|
1833
1905
|
template_file /path/to/fluentd-template.json
|
1834
1906
|
```
|
1835
1907
|
|
1908
|
+
Note that if you create a new set of indexes every day, the elasticsearch ILM policy system will treat each day separately and will always
|
1909
|
+
maintain a separate active write index for each day.
|
1910
|
+
|
1911
|
+
If you have a rollover based on max_age, it will continue to roll the indexes for prior dates even if no new documents are indexed. If you want
|
1912
|
+
to delete indexes after a period of time, the ILM policy will never delete the current write index regardless of its age, so you would need a separate
|
1913
|
+
system, such as curator, to actually delete the old indexes.
|
1914
|
+
|
1915
|
+
For this reason, if you put the date into the index names with ILM you should only rollover based on size or number of documents and may need to use
|
1916
|
+
curator to actually delete old indexes.
|
1917
|
+
|
1836
1918
|
#### Fixed ILM indices
|
1837
1919
|
|
1838
1920
|
Also, users can use fixed ILM indices configuration.
|
@@ -1948,4 +2030,7 @@ Install dev dependencies:
|
|
1948
2030
|
$ gem install bundler
|
1949
2031
|
$ bundle install
|
1950
2032
|
$ bundle exec rake test
|
2033
|
+
# To just run the test you are working on:
|
2034
|
+
$ bundle exec rake test TEST=test/plugin/test_out_elasticsearch.rb TESTOPTS='--verbose --name=test_custom_template_with_rollover_index_create_and_custom_ilm'
|
2035
|
+
|
1951
2036
|
```
|
@@ -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.2
|
6
|
+
s.version = '4.3.2'
|
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}
|
@@ -32,12 +32,13 @@ module Fluent::ElasticsearchIndexTemplate
|
|
32
32
|
return false
|
33
33
|
end
|
34
34
|
|
35
|
-
def retry_operate(max_retries, fail_on_retry_exceed = true)
|
35
|
+
def retry_operate(max_retries, fail_on_retry_exceed = true, catch_trasport_exceptions = true)
|
36
36
|
return unless block_given?
|
37
37
|
retries = 0
|
38
|
+
transport_errors = Elasticsearch::Transport::Transport::Errors.constants.map{ |c| Elasticsearch::Transport::Transport::Errors.const_get c } if catch_trasport_exceptions
|
38
39
|
begin
|
39
40
|
yield
|
40
|
-
rescue *client.transport.host_unreachable_exceptions, Timeout::Error => e
|
41
|
+
rescue *client.transport.host_unreachable_exceptions, *transport_errors, Timeout::Error => e
|
41
42
|
@_es = nil
|
42
43
|
@_es_info = nil
|
43
44
|
if retries < max_retries
|
@@ -73,14 +74,15 @@ module Fluent::ElasticsearchIndexTemplate
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil, target_index = nil)
|
77
|
+
def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil, target_index = nil, index_separator = '-')
|
77
78
|
inject_template_name = get_template_name(enable_ilm, name, deflector_alias_name)
|
78
79
|
if overwrite
|
79
80
|
template_put(inject_template_name,
|
80
81
|
enable_ilm ? inject_ilm_settings_to_template(deflector_alias_name,
|
81
82
|
target_index,
|
82
83
|
ilm_policy_id,
|
83
|
-
get_template(template_file)
|
84
|
+
get_template(template_file),
|
85
|
+
index_separator) :
|
84
86
|
get_template(template_file), host)
|
85
87
|
|
86
88
|
log.debug("Template '#{inject_template_name}' overwritten with #{template_file}.")
|
@@ -91,7 +93,8 @@ module Fluent::ElasticsearchIndexTemplate
|
|
91
93
|
enable_ilm ? inject_ilm_settings_to_template(deflector_alias_name,
|
92
94
|
target_index,
|
93
95
|
ilm_policy_id,
|
94
|
-
get_template(template_file)
|
96
|
+
get_template(template_file),
|
97
|
+
index_separator) :
|
95
98
|
get_template(template_file), host)
|
96
99
|
log.info("Template configured, but no template installed. Installed '#{inject_template_name}' from #{template_file}.")
|
97
100
|
else
|
@@ -99,14 +102,15 @@ module Fluent::ElasticsearchIndexTemplate
|
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
102
|
-
def template_custom_install(template_name, template_file, overwrite, customize_template, enable_ilm, deflector_alias_name, ilm_policy_id, host, target_index)
|
105
|
+
def template_custom_install(template_name, template_file, overwrite, customize_template, enable_ilm, deflector_alias_name, ilm_policy_id, host, target_index, index_separator)
|
103
106
|
template_custom_name = get_template_name(enable_ilm, template_name, deflector_alias_name)
|
104
107
|
custom_template = if enable_ilm
|
105
108
|
inject_ilm_settings_to_template(deflector_alias_name,
|
106
109
|
target_index,
|
107
110
|
ilm_policy_id,
|
108
111
|
get_custom_template(template_file,
|
109
|
-
customize_template)
|
112
|
+
customize_template),
|
113
|
+
index_separator)
|
110
114
|
else
|
111
115
|
get_custom_template(template_file, customize_template)
|
112
116
|
end
|
@@ -127,9 +131,9 @@ module Fluent::ElasticsearchIndexTemplate
|
|
127
131
|
enable_ilm ? deflector_alias_name : template_name
|
128
132
|
end
|
129
133
|
|
130
|
-
def inject_ilm_settings_to_template(deflector_alias, target_index, ilm_policy_id, template)
|
134
|
+
def inject_ilm_settings_to_template(deflector_alias, target_index, ilm_policy_id, template, index_separator)
|
131
135
|
log.debug("Overwriting index patterns when Index Lifecycle Management is enabled.")
|
132
|
-
template['index_patterns'] = "#{target_index}
|
136
|
+
template['index_patterns'] = "#{target_index}#{index_separator}*"
|
133
137
|
if @use_legacy_template
|
134
138
|
template.delete('template') if template.include?('template')
|
135
139
|
# Prepare settings Hash
|
@@ -140,7 +144,7 @@ module Fluent::ElasticsearchIndexTemplate
|
|
140
144
|
log.debug("Overwriting index lifecycle name and rollover alias when Index Lifecycle Management is enabled.")
|
141
145
|
end
|
142
146
|
template['settings'].update({ 'index.lifecycle.name' => ilm_policy_id, 'index.lifecycle.rollover_alias' => deflector_alias})
|
143
|
-
template['order'] = template['order'] ? template['order'] + target_index.
|
147
|
+
template['order'] = template['order'] ? template['order'] + target_index.count(index_separator) + 1 : 51 + target_index.count(index_separator)
|
144
148
|
else
|
145
149
|
# Prepare template.settings Hash
|
146
150
|
if !template['template'].key?('settings')
|
@@ -150,7 +154,7 @@ module Fluent::ElasticsearchIndexTemplate
|
|
150
154
|
log.debug("Overwriting index lifecycle name and rollover alias when Index Lifecycle Management is enabled.")
|
151
155
|
end
|
152
156
|
template['template']['settings'].update({ 'index.lifecycle.name' => ilm_policy_id, 'index.lifecycle.rollover_alias' => deflector_alias})
|
153
|
-
template['priority'] = template['priority'] ? template['priority'] + target_index.
|
157
|
+
template['priority'] = template['priority'] ? template['priority'] + target_index.count(index_separator) + 1 : 101 + target_index.count(index_separator)
|
154
158
|
end
|
155
159
|
template
|
156
160
|
end
|
@@ -18,6 +18,7 @@ require 'fluent/plugin/output'
|
|
18
18
|
require 'fluent/event'
|
19
19
|
require 'fluent/error'
|
20
20
|
require 'fluent/time'
|
21
|
+
require 'fluent/unique_id'
|
21
22
|
require 'fluent/log-ext'
|
22
23
|
require 'zlib'
|
23
24
|
require_relative 'elasticsearch_constants'
|
@@ -76,6 +77,8 @@ module Fluent::Plugin
|
|
76
77
|
config_param :port, :integer, :default => 9200
|
77
78
|
config_param :user, :string, :default => nil
|
78
79
|
config_param :password, :string, :default => nil, :secret => true
|
80
|
+
config_param :cloud_id, :string, :default => nil
|
81
|
+
config_param :cloud_auth, :string, :default => nil
|
79
82
|
config_param :path, :string, :default => nil
|
80
83
|
config_param :scheme, :enum, :list => [:https, :http], :default => :http
|
81
84
|
config_param :hosts, :string, :default => nil
|
@@ -170,6 +173,12 @@ EOC
|
|
170
173
|
config_param :ilm_policy_overwrite, :bool, :default => false
|
171
174
|
config_param :truncate_caches_interval, :time, :default => nil
|
172
175
|
config_param :use_legacy_template, :bool, :default => true
|
176
|
+
config_param :catch_transport_exception_on_retry, :bool, :default => true
|
177
|
+
|
178
|
+
config_section :metadata, param_name: :metainfo, multi: false do
|
179
|
+
config_param :include_chunk_id, :bool, :default => false
|
180
|
+
config_param :chunk_id_key, :string, :default => "chunk_id".freeze
|
181
|
+
end
|
173
182
|
|
174
183
|
config_section :buffer do
|
175
184
|
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
@@ -253,9 +262,11 @@ EOC
|
|
253
262
|
template_installation_actual(@deflector_alias ? @deflector_alias : @index_name, @template_name, @customize_template, @application_name, @index_name, @ilm_policy_id)
|
254
263
|
end
|
255
264
|
verify_ilm_working if @enable_ilm
|
256
|
-
end
|
265
|
+
end
|
257
266
|
if @templates
|
258
|
-
retry_operate(@max_retry_putting_template,
|
267
|
+
retry_operate(@max_retry_putting_template,
|
268
|
+
@fail_on_putting_template_retry_exceed,
|
269
|
+
@catch_transport_exception_on_retry) do
|
259
270
|
templates_hash_install(@templates, @template_overwrite)
|
260
271
|
end
|
261
272
|
end
|
@@ -285,8 +296,14 @@ EOC
|
|
285
296
|
@dump_proc = Yajl.method(:dump)
|
286
297
|
end
|
287
298
|
|
299
|
+
raise Fluent::ConfigError, "`cloud_auth` must be present if `cloud_id` is present" if @cloud_id && @cloud_auth.nil?
|
288
300
|
raise Fluent::ConfigError, "`password` must be present if `user` is present" if @user && @password.nil?
|
289
301
|
|
302
|
+
if @cloud_auth
|
303
|
+
@user = @cloud_auth.split(':', -1)[0]
|
304
|
+
@password = @cloud_auth.split(':', -1)[1]
|
305
|
+
end
|
306
|
+
|
290
307
|
if @user && m = @user.match(/%{(?<user>.*)}/)
|
291
308
|
@user = URI.encode_www_form_component(m["user"])
|
292
309
|
end
|
@@ -332,7 +349,7 @@ EOC
|
|
332
349
|
@type_name = '_doc'.freeze
|
333
350
|
end
|
334
351
|
if @last_seen_major_version >= 8 && @type_name != DEFAULT_TYPE_NAME_ES_7x
|
335
|
-
log.
|
352
|
+
log.debug "Detected ES 8.x or above: This parameter has no effect."
|
336
353
|
@type_name = nil
|
337
354
|
end
|
338
355
|
end
|
@@ -464,7 +481,9 @@ EOC
|
|
464
481
|
|
465
482
|
def handle_last_seen_es_major_version
|
466
483
|
if @verify_es_version_at_startup && !dry_run?
|
467
|
-
retry_operate(@max_retry_get_es_version,
|
484
|
+
retry_operate(@max_retry_get_es_version,
|
485
|
+
@fail_on_detecting_es_version_retry_exceed,
|
486
|
+
@catch_transport_exception_on_retry) do
|
468
487
|
detect_es_major_version
|
469
488
|
end
|
470
489
|
else
|
@@ -549,7 +568,17 @@ EOC
|
|
549
568
|
return Time.at(event_time).to_datetime
|
550
569
|
end
|
551
570
|
|
571
|
+
def cloud_client
|
572
|
+
Elasticsearch::Client.new(
|
573
|
+
cloud_id: @cloud_id,
|
574
|
+
user: @user,
|
575
|
+
password: @password
|
576
|
+
)
|
577
|
+
end
|
578
|
+
|
552
579
|
def client(host = nil, compress_connection = false)
|
580
|
+
return cloud_client if @cloud_id
|
581
|
+
|
553
582
|
# check here to see if we already have a client connection for the given host
|
554
583
|
connection_options = get_connection_options(host)
|
555
584
|
|
@@ -771,6 +800,15 @@ EOC
|
|
771
800
|
true
|
772
801
|
end
|
773
802
|
|
803
|
+
def inject_chunk_id_to_record_if_needed(record, chunk_id)
|
804
|
+
if @metainfo&.include_chunk_id
|
805
|
+
record[@metainfo.chunk_id_key] = chunk_id
|
806
|
+
record
|
807
|
+
else
|
808
|
+
record
|
809
|
+
end
|
810
|
+
end
|
811
|
+
|
774
812
|
def write(chunk)
|
775
813
|
bulk_message_count = Hash.new { |h,k| h[k] = 0 }
|
776
814
|
bulk_message = Hash.new { |h,k| h[k] = '' }
|
@@ -778,6 +816,7 @@ EOC
|
|
778
816
|
meta = {}
|
779
817
|
|
780
818
|
tag = chunk.metadata.tag
|
819
|
+
chunk_id = dump_unique_id_hex(chunk.unique_id)
|
781
820
|
extracted_values = expand_placeholders(chunk)
|
782
821
|
host = if @hosts
|
783
822
|
extract_placeholders(@hosts, chunk)
|
@@ -787,6 +826,9 @@ EOC
|
|
787
826
|
|
788
827
|
chunk.msgpack_each do |time, record|
|
789
828
|
next unless record.is_a? Hash
|
829
|
+
|
830
|
+
record = inject_chunk_id_to_record_if_needed(record, chunk_id)
|
831
|
+
|
790
832
|
begin
|
791
833
|
meta, header, record = process_message(tag, meta, header, time, record, extracted_values)
|
792
834
|
info = if @include_index_in_url
|
@@ -888,7 +930,7 @@ EOC
|
|
888
930
|
log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
|
889
931
|
target_type = '_doc'.freeze
|
890
932
|
elsif @last_seen_major_version >=8
|
891
|
-
log.
|
933
|
+
log.debug "Detected ES 8.x or above: document type will not be used."
|
892
934
|
target_type = nil
|
893
935
|
end
|
894
936
|
else
|
@@ -898,7 +940,7 @@ EOC
|
|
898
940
|
log.warn "Detected ES 7.x: `_doc` will be used as the document `_type`."
|
899
941
|
target_type = '_doc'.freeze
|
900
942
|
elsif @last_seen_major_version >= 8
|
901
|
-
log.
|
943
|
+
log.debug "Detected ES 8.x or above: document type will not be used."
|
902
944
|
target_type = nil
|
903
945
|
else
|
904
946
|
target_type = type_name
|
@@ -963,22 +1005,26 @@ EOC
|
|
963
1005
|
|
964
1006
|
def template_installation_actual(deflector_alias, template_name, customize_template, application_name, target_index, ilm_policy_id, host=nil)
|
965
1007
|
if template_name && @template_file
|
966
|
-
if !@logstash_format && @alias_indexes.include?
|
967
|
-
|
968
|
-
|
969
|
-
|
1008
|
+
if !@logstash_format && (deflector_alias.nil? || (@alias_indexes.include? deflector_alias)) && (@template_names.include? template_name)
|
1009
|
+
if deflector_alias
|
1010
|
+
log.debug("Index alias #{deflector_alias} and template #{template_name} already exist (cached)")
|
1011
|
+
else
|
1012
|
+
log.debug("Template #{template_name} already exists (cached)")
|
1013
|
+
end
|
970
1014
|
else
|
971
|
-
retry_operate(@max_retry_putting_template,
|
1015
|
+
retry_operate(@max_retry_putting_template,
|
1016
|
+
@fail_on_putting_template_retry_exceed,
|
1017
|
+
@catch_transport_exception_on_retry) do
|
972
1018
|
if customize_template
|
973
|
-
template_custom_install(template_name, @template_file, @template_overwrite, customize_template, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index)
|
1019
|
+
template_custom_install(template_name, @template_file, @template_overwrite, customize_template, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index, @index_separator)
|
974
1020
|
else
|
975
|
-
template_install(template_name, @template_file, @template_overwrite, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index)
|
1021
|
+
template_install(template_name, @template_file, @template_overwrite, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index, @index_separator)
|
976
1022
|
end
|
977
1023
|
ilm_policy = @ilm_policies[ilm_policy_id] || {}
|
978
1024
|
create_rollover_alias(target_index, @rollover_index, deflector_alias, application_name, @index_date_pattern, @index_separator, @enable_ilm, ilm_policy_id, ilm_policy, @ilm_policy_overwrite, host)
|
979
1025
|
end
|
980
1026
|
@alias_indexes << deflector_alias unless deflector_alias.nil?
|
981
|
-
@template_names << template_name
|
1027
|
+
@template_names << template_name
|
982
1028
|
end
|
983
1029
|
end
|
984
1030
|
end
|