fluent-plugin-elasticsearch 1.9.4 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  4. data/.github/workflows/issue-auto-closer.yml +12 -0
  5. data/.github/workflows/linux.yml +26 -0
  6. data/.github/workflows/macos.yml +26 -0
  7. data/.github/workflows/windows.yml +26 -0
  8. data/.travis.yml +33 -6
  9. data/CONTRIBUTING.md +24 -0
  10. data/Gemfile +4 -1
  11. data/History.md +445 -1
  12. data/ISSUE_TEMPLATE.md +19 -0
  13. data/README.ElasticsearchGenID.md +116 -0
  14. data/README.ElasticsearchInput.md +293 -0
  15. data/README.Troubleshooting.md +692 -0
  16. data/README.md +1013 -38
  17. data/appveyor.yml +20 -0
  18. data/fluent-plugin-elasticsearch.gemspec +15 -9
  19. data/{Gemfile.v0.12 → gemfiles/Gemfile.elasticsearch.v6} +6 -5
  20. data/lib/fluent/log-ext.rb +38 -0
  21. data/lib/fluent/plugin/default-ilm-policy.json +14 -0
  22. data/lib/fluent/plugin/elasticsearch_constants.rb +13 -0
  23. data/lib/fluent/plugin/elasticsearch_error.rb +5 -0
  24. data/lib/fluent/plugin/elasticsearch_error_handler.rb +129 -0
  25. data/lib/fluent/plugin/elasticsearch_fallback_selector.rb +9 -0
  26. data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +67 -0
  27. data/lib/fluent/plugin/elasticsearch_index_template.rb +186 -12
  28. data/lib/fluent/plugin/elasticsearch_simple_sniffer.rb +10 -0
  29. data/lib/fluent/plugin/elasticsearch_tls.rb +70 -0
  30. data/lib/fluent/plugin/filter_elasticsearch_genid.rb +77 -0
  31. data/lib/fluent/plugin/in_elasticsearch.rb +325 -0
  32. data/lib/fluent/plugin/oj_serializer.rb +22 -0
  33. data/lib/fluent/plugin/out_elasticsearch.rb +1008 -267
  34. data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +218 -0
  35. data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +232 -214
  36. data/test/plugin/test_alias_template.json +9 -0
  37. data/test/plugin/test_elasticsearch_error_handler.rb +646 -0
  38. data/test/plugin/test_elasticsearch_fallback_selector.rb +74 -0
  39. data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +66 -0
  40. data/test/plugin/test_elasticsearch_tls.rb +145 -0
  41. data/test/plugin/test_filter_elasticsearch_genid.rb +215 -0
  42. data/test/plugin/test_in_elasticsearch.rb +459 -0
  43. data/test/plugin/test_index_alias_template.json +11 -0
  44. data/test/plugin/test_index_template.json +25 -0
  45. data/test/plugin/test_oj_serializer.rb +19 -0
  46. data/test/plugin/test_out_elasticsearch.rb +5029 -387
  47. data/test/plugin/test_out_elasticsearch_data_stream.rb +337 -0
  48. data/test/plugin/test_out_elasticsearch_dynamic.rb +681 -208
  49. data/test/test_log-ext.rb +35 -0
  50. metadata +97 -19
data/README.md CHANGED
@@ -1,34 +1,57 @@
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
- [![Build Status](https://travis-ci.org/uken/fluent-plugin-elasticsearch.png?branch=master)](https://travis-ci.org/uken/fluent-plugin-elasticsearch)
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
- [![Issue Stats](http://issuestats.com/github/uken/fluent-plugin-elasticsearch/badge/pr)](http://issuestats.com/github/uken/fluent-plugin-elasticsearch)
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 ElasticSearch (and search them with Kibana maybe?)
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
 
14
+ Current maintainers: @cosmo0920
15
+
14
16
  * [Installation](#installation)
15
17
  * [Usage](#usage)
16
18
  + [Index templates](#index-templates)
17
19
  * [Configuration](#configuration)
20
+ + [host](#host)
21
+ + [port](#port)
22
+ + [cloud_id](#cloud_id)
23
+ + [cloud_auth](#cloud_auth)
24
+ + [emit_error_for_missing_id](#emit_error_for_missing_id)
18
25
  + [hosts](#hosts)
19
26
  + [user, password, path, scheme, ssl_verify](#user-password-path-scheme-ssl_verify)
20
27
  + [logstash_format](#logstash_format)
21
28
  + [logstash_prefix](#logstash_prefix)
29
+ + [logstash_prefix_separator](#logstash_prefix_separator)
22
30
  + [logstash_dateformat](#logstash_dateformat)
31
+ + [pipeline](#pipeline)
23
32
  + [time_key_format](#time_key_format)
33
+ + [time_precision](#time_precision)
24
34
  + [time_key](#time_key)
25
35
  + [time_key_exclude_timestamp](#time_key_exclude_timestamp)
36
+ + [include_timestamp](#include_timestamp)
26
37
  + [utc_index](#utc_index)
38
+ + [suppress_type_name](#suppress_type_name)
27
39
  + [target_index_key](#target_index_key)
28
40
  + [target_type_key](#target_type_key)
29
41
  + [template_name](#template_name)
30
42
  + [template_file](#template_file)
43
+ + [template_overwrite](#template_overwrite)
44
+ + [customize_template](#customize_template)
45
+ + [rollover_index](#rollover_index)
46
+ + [index_date_pattern](#index_date_pattern)
47
+ + [deflector_alias](#deflector_alias)
48
+ + [application_name](#application_name)
49
+ + [index_prefix](#index_prefix)
31
50
  + [templates](#templates)
51
+ + [max_retry_putting_template](#max_retry_putting_template)
52
+ + [fail_on_putting_template_retry_exceed](#fail_on_putting_template_retry_exceed)
53
+ + [fail_on_detecting_es_version_retry_exceed](#fail_on_detecting_es_version_retry_exceed)
54
+ + [max_retry_get_es_version](#max_retry_get_es_version)
32
55
  + [request_timeout](#request_timeout)
33
56
  + [reload_connections](#reload_connections)
34
57
  + [reload_on_failure](#reload_on_failure)
@@ -40,19 +63,74 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
40
63
  + [remove_keys](#remove_keys)
41
64
  + [remove_keys_on_update](#remove_keys_on_update)
42
65
  + [remove_keys_on_update_key](#remove_keys_on_update_key)
66
+ + [retry_tag](#retry_tag)
43
67
  + [write_operation](#write_operation)
44
68
  + [time_parse_error_tag](#time_parse_error_tag)
45
69
  + [reconnect_on_error](#reconnect_on_error)
70
+ + [with_transporter_log](#with_transporter_log)
71
+ + [content_type](#content_type)
72
+ + [include_index_in_url](#include_index_in_url)
73
+ + [http_backend](#http_backend)
74
+ + [http_backend_excon_nonblock](#http_backend_excon_nonblock)
75
+ + [prefer_oj_serializer](#prefer_oj_serializer)
76
+ + [compression_level](#compression_level)
46
77
  + [Client/host certificate options](#clienthost-certificate-options)
47
78
  + [Proxy Support](#proxy-support)
48
- + [Buffered output options](#buffered-output-options)
79
+ + [Buffer options](#buffer-options)
49
80
  + [Hash flattening](#hash-flattening)
81
+ + [Generate Hash ID](#generate-hash-id)
82
+ + [sniffer_class_name](#sniffer-class-name)
83
+ + [selector_class_name](#selector-class-name)
84
+ + [reload_after](#reload-after)
85
+ + [validate_client_version](#validate-client-version)
86
+ + [unrecoverable_error_types](#unrecoverable-error-types)
87
+ + [verify_es version at startup](#verify_es_version_at_startup)
88
+ + [default_elasticsearch_version](#default_elasticsearch_version)
89
+ + [custom_headers](#custom_headers)
90
+ + [api_key](#api_key)
50
91
  + [Not seeing a config you need?](#not-seeing-a-config-you-need)
51
92
  + [Dynamic configuration](#dynamic-configuration)
93
+ + [Placeholders](#placeholders)
94
+ + [Multi workers](#multi-workers)
95
+ + [log_es_400_reason](#log_es_400_reason)
96
+ + [suppress_doc_wrap](#suppress_doc_wrap)
97
+ + [ignore_exceptions](#ignore_exceptions)
98
+ + [exception_backup](#exception_backup)
99
+ + [bulk_message_request_threshold](#bulk_message_request_threshold)
100
+ + [enable_ilm](#enable_ilm)
101
+ + [ilm_policy_id](#ilm_policy_id)
102
+ + [ilm_policy](#ilm_policy)
103
+ + [ilm_policies](#ilm_policies)
104
+ + [ilm_policy_overwrite](#ilm_policy_overwrite)
105
+ + [truncate_caches_interval](#truncate_caches_interval)
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)
110
+ * [Configuration - Elasticsearch Input](#configuration---elasticsearch-input)
111
+ * [Configuration - Elasticsearch Filter GenID](#configuration---elasticsearch-filter-genid)
112
+ * [Configuration - Elasticsearch Output Data Stream](#configuration---elasticsearch-output-data-stream)
113
+ * [Elasticsearch permissions](#elasticsearch-permissions)
114
+ * [Troubleshooting](#troubleshooting)
52
115
  * [Contact](#contact)
53
116
  * [Contributing](#contributing)
54
117
  * [Running tests](#running-tests)
55
118
 
119
+ ## Requirements
120
+
121
+ | fluent-plugin-elasticsearch | fluentd | ruby |
122
+ |:----------------------------:|:-----------:|:------:|
123
+ | >= 4.0.1 | >= v0.14.22 | >= 2.3 |
124
+ | >= 3.2.4 && < 4.0.1 | >= v0.14.22 | >= 2.1 |
125
+ | >= 2.0.0 && < 3.2.3 | >= v0.14.20 | >= 2.1 |
126
+ | < 2.0.0 | >= v0.12.0 | >= 1.9 |
127
+
128
+ 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.
129
+
130
+ NOTE: This documentation is for fluent-plugin-elasticsearch 2.x or later. For 1.x documentation, please see [v0.12 branch](https://github.com/uken/fluent-plugin-elasticsearch/tree/v0.12).
131
+
132
+ NOTE: Using Index Lifecycle management(ILM) feature needs to install elasticsearch-xpack gem v7.4.0 or later.
133
+
56
134
  ## Installation
57
135
 
58
136
  ```sh
@@ -73,27 +151,121 @@ In your Fluentd configuration, use `@type elasticsearch`. Additional configurati
73
151
  </match>
74
152
  ```
75
153
 
154
+ NOTE: `type_name` parameter will be used fixed `_doc` value for Elasticsearch 7.
155
+
156
+ NOTE: `type_name` parameter will make no effect for Elasticsearch 8.
157
+
76
158
  ### Index templates
77
159
 
78
- 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.
160
+ 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.
79
161
 
80
162
  ## Configuration
81
163
 
164
+ ### host
165
+
166
+ ```
167
+ host user-custom-host.domain # default localhost
168
+ ```
169
+
170
+ You can specify Elasticsearch host by this parameter.
171
+
172
+ **Note:** Since v3.3.2, `host` parameter supports builtin placeholders. If you want to send events dynamically into different hosts at runtime with `elasticsearch_dynamic` output plugin, please consider to switch to use plain `elasticsearch` output plugin. In more detail for builtin placeholders, please refer to [Placeholders](#placeholders) section.
173
+
174
+ To use IPv6 address on `host` parameter, you can use the following styles:
175
+
176
+ #### string style
177
+
178
+ To use string style, you must quote IPv6 address due to prevent to be interpreted as JSON:
179
+
180
+ ```
181
+ host "[2404:7a80:d440:3000:192a:a292:bd7f:ca10]"
182
+ ```
183
+
184
+ #### raw style
185
+
186
+ You can also specify raw IPv6 address. This will be handled as `[specified IPv6 address]`:
187
+
188
+ ```
189
+ host 2404:7a80:d440:3000:192a:a292:bd7f:ca10
190
+ ```
191
+
192
+ ### port
193
+
194
+ ```
195
+ port 9201 # defaults to 9200
196
+ ```
197
+
198
+ You can specify Elasticsearch port by this parameter.
199
+
200
+ ### cloud_id
201
+
202
+ ```
203
+ cloud_id test-dep:ZXVyb3BlLXdlc3QxLmdjcC5jbG91ZC5lcy5pbyRiYZTA1Ng==
204
+ ```
205
+
206
+ You can specify Elasticsearch cloud_id by this parameter.
207
+
208
+ If you specify `cloud_id` option then `cloud_auth` option is required.
209
+ If you specify `cloud_id` option, `host`, `port`, `user` and `password` options are ignored.
210
+
211
+ ### cloud_auth
212
+
213
+ ```
214
+ cloud_auth 'elastic:slkjdaooewkd87iqQ2O8EQYV'
215
+ ```
216
+
217
+ You can specify Elasticsearch cloud_auth by this parameter.
218
+
219
+
220
+ ### emit_error_for_missing_id
221
+
222
+ ```
223
+ emit_error_for_missing_id true
224
+ ```
225
+ When `write_operation` is configured to anything other then `index`, setting this value to `true` will
226
+ cause the plugin to `emit_error_event` of any records which do not include an `_id` field. The default (`false`)
227
+ behavior is to silently drop the records.
228
+
82
229
  ### hosts
83
230
 
84
231
  ```
85
232
  hosts host1:port1,host2:port2,host3:port3
86
- # or
87
- hosts https://customhost.com:443/path,https://username:password@host-failover.com:443
88
233
  ```
89
234
 
90
- You can specify multiple ElasticSearch hosts with separator ",".
235
+ You can specify multiple Elasticsearch hosts with separator ",".
91
236
 
92
- 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.
237
+ 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.
93
238
 
94
- ### user, password, path, scheme, ssl_verify
239
+ If you specify `hosts` option, `host` and `port` options are ignored.
240
+
241
+ ```
242
+ host user-custom-host.domain # ignored
243
+ port 9200 # ignored
244
+ hosts host1:port1,host2:port2,host3:port3
245
+ ```
246
+
247
+ If you specify `hosts` option without port, `port` option is used.
248
+
249
+ ```
250
+ port 9200
251
+ hosts host1:port1,host2:port2,host3 # port3 is 9200
252
+ ```
253
+
254
+ **Note:** If you will use scheme https, do not include "https://" in your hosts ie. host "https://domain", this will cause ES cluster to be unreachable and you will receive an error "Can not reach Elasticsearch cluster"
255
+
256
+ **Note:** Up until v2.8.5, it was allowed to embed the username/password in the URL. However, this syntax is deprecated as of v2.8.6 because it was found to cause serious connection problems (See #394). Please migrate your settings to use the `user` and `password` field (described below) instead.
95
257
 
96
- If you specify this option, host and port options are ignored.
258
+ #### IPv6 addresses
259
+
260
+ When you want to specify IPv6 addresses, you must specify schema together:
261
+
262
+ ```
263
+ hosts http://[2404:7a80:d440:3000:de:7311:6329:2e6c]:port1,http://[2404:7a80:d440:3000:de:7311:6329:1e6c]:port2,http://[2404:7a80:d440:3000:de:6311:6329:2e6c]:port3
264
+ ```
265
+
266
+ If you don't specify hosts with schema together, Elasticsearch plugin complains Invalid URI for them.
267
+
268
+ ### user, password, path, scheme, ssl_verify
97
269
 
98
270
  ```
99
271
  user demo
@@ -102,7 +274,14 @@ path /elastic_search/
102
274
  scheme https
103
275
  ```
104
276
 
105
- You can specify user and password for HTTP basic auth. If used in conjunction with a hosts list, then these options will be used by default i.e. if you do not provide any of these options within the hosts listed.
277
+ You can specify user and password for HTTP Basic authentication.
278
+
279
+ And this plugin will escape required URL encoded characters within `%{}` placeholders.
280
+
281
+ ```
282
+ user %{demo+}
283
+ password %{@secret}
284
+ ```
106
285
 
107
286
  Specify `ssl_verify false` to skip ssl verification (defaults to true)
108
287
 
@@ -112,7 +291,17 @@ Specify `ssl_verify false` to skip ssl verification (defaults to true)
112
291
  logstash_format true # defaults to false
113
292
  ```
114
293
 
115
- 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}`
294
+ 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}-#{formatted_date}`
295
+
296
+ :warning: Setting this option to `true` will ignore the `index_name` setting. The default index name prefix is `logstash-`.
297
+
298
+ ### include_timestamp
299
+
300
+ ```
301
+ include_timestamp true # defaults to false
302
+ ```
303
+
304
+ Adds a `@timestamp` field to the log, following all settings `logstash_format` does, except without the restrictions on `index_name`. This allows one to log to an alias in Elasticsearch and utilize the rollover API.
116
305
 
117
306
  ### logstash_prefix
118
307
 
@@ -120,6 +309,12 @@ This is meant to make writing data into ElasticSearch indices compatible to what
120
309
  logstash_prefix mylogs # defaults to "logstash"
121
310
  ```
122
311
 
312
+ ### logstash_prefix_separator
313
+
314
+ ```
315
+ logstash_prefix_separator _ # defaults to "-"
316
+ ```
317
+
123
318
  ### logstash_dateformat
124
319
 
125
320
  The strftime format to generate index target index name when `logstash_format` is set to true. By default, the records are inserted into index `logstash-YYYY.MM.DD`. This option, alongwith `logstash_prefix` lets us insert into specified index like `mylogs-YYYYMM` for a monthly index.
@@ -128,11 +323,21 @@ The strftime format to generate index target index name when `logstash_format` i
128
323
  logstash_dateformat %Y.%m. # defaults to "%Y.%m.%d"
129
324
  ```
130
325
 
326
+ ### pipeline
327
+
328
+ Only in ES >= 5.x is available to use this parameter.
329
+ This param is to set a pipeline id of your elasticsearch to be added into the request, you can configure ingest node.
330
+ For more information: [![Ingest node](https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest.html)]
331
+
332
+ ```
333
+ pipeline pipeline_id
334
+ ```
335
+
131
336
  ### time_key_format
132
337
 
133
338
  The format of the time stamp field (`@timestamp` or what you specify with [time_key](#time_key)). This parameter only has an effect when [logstash_format](#logstash_format) is true as it only affects the name of the index we write to. Please see [Time#strftime](http://ruby-doc.org/core-1.9.3/Time.html#method-i-strftime) for information about the value of this format.
134
339
 
135
- Setting this to a known format can vastly improve your log ingestion speed if all most of your logs are in the same format. If there is an error parsing this format the timestamp will default to the ingestion time. If you are on Ruby 2.0 or later you can get a further performance improvment by installing the "strptime" gem: `fluent-gem install strptime`.
340
+ Setting this to a known format can vastly improve your log ingestion speed if all most of your logs are in the same format. If there is an error parsing this format the timestamp will default to the ingestion time. If you are on Ruby 2.0 or later you can get a further performance improvement by installing the "strptime" gem: `fluent-gem install strptime`.
136
341
 
137
342
  For example to parse ISO8601 times with sub-second precision:
138
343
 
@@ -140,12 +345,18 @@ For example to parse ISO8601 times with sub-second precision:
140
345
  time_key_format %Y-%m-%dT%H:%M:%S.%N%z
141
346
  ```
142
347
 
348
+ ### time_precision
349
+
350
+ Should the record not include a `time_key`, define the degree of sub-second time precision to preserve from the `time` portion of the routed event.
351
+
352
+ For example, should your input plugin not include a `time_key` in the record but it able to pass a `time` to the router when emitting the event (AWS CloudWatch events are an example of this), then this setting will allow you to preserve the sub-second time resolution of those events. This is the case for: [fluent-plugin-cloudwatch-ingest](https://github.com/sampointer/fluent-plugin-cloudwatch-ingest).
353
+
143
354
  ### time_key
144
355
 
145
356
  By default, when inserting records in [Logstash](https://www.elastic.co/products/logstash) format, `@timestamp` is dynamically created with the time at log ingestion. If you'd like to use a custom time, include an `@timestamp` with your record.
146
357
 
147
358
  ```
148
- {"@timestamp":"2014-04-07T000:00:00-00:00"}
359
+ {"@timestamp": "2014-04-07T000:00:00-00:00"}
149
360
  ```
150
361
 
151
362
  You can specify an option `time_key` (like the option described in [tail Input Plugin](http://docs.fluentd.org/articles/in_tail)) to replace `@timestamp` key.
@@ -192,11 +403,25 @@ utc_index true
192
403
 
193
404
  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.
194
405
 
406
+ ### suppress_type_name
407
+
408
+ In Elasticsearch 7.x, Elasticsearch cluster complains the following types removal warnings:
409
+
410
+ ```json
411
+ {"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" }
412
+ ```
413
+
414
+ This can be suppressed with:
415
+
416
+ ```
417
+ suppress_type_name true
418
+ ```
419
+
195
420
  ### target_index_key
196
421
 
197
422
  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.
198
423
 
199
- If it is present in the record (and the value is non falsey) the value will be used as the index name to write to and then removed from the record before output; if it is not found then it will use logstash_format or index_name settings as configured.
424
+ If it is present in the record (and the value is non falsy) the value will be used as the index name to write to and then removed from the record before output; if it is not found then it will use logstash_format or index_name settings as configured.
200
425
 
201
426
  Suppose you have the following settings
202
427
 
@@ -231,7 +456,7 @@ Similar to `target_index_key` config, find the type name to write to in the reco
231
456
 
232
457
  ### template_name
233
458
 
234
- The name of the template to define. If a template by the name given is already present, it will be left unchanged.
459
+ 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.
235
460
 
236
461
  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).
237
462
 
@@ -248,16 +473,139 @@ The path to the file containing the template to install.
248
473
  Specify index templates in form of hash. Can contain multiple templates.
249
474
 
250
475
  ```
251
- templates { "templane_name_1": "path_to_template_1_file", "templane_name_2": "path_to_template_2_file"}
476
+ templates { "template_name_1": "path_to_template_1_file", "template_name_2": "path_to_template_2_file"}
477
+ ```
478
+
479
+ **Note:** Before ES plugin v4.1.2, if `template_file` and `template_name` are set, then this parameter will be ignored. In 4.1.3 or later, `template_file` and `template_name` can work with `templates`.
480
+
481
+ ### customize_template
482
+
483
+ Specify the string and its value to be replaced in form of hash. Can contain multiple key value pair that would be replaced in the specified template_file.
484
+ This setting only creates template and to add rollover index please check the [rollover_index](#rollover_index) configuration.
485
+
486
+ ```
487
+ customize_template {"string_1": "subs_value_1", "string_2": "subs_value_2"}
488
+ ```
489
+
490
+ If [template_file](#template_file) and [template_name](#template_name) are set, then this parameter will be in effect otherwise ignored.
491
+
492
+ ### rollover_index
493
+
494
+ Specify this as true when an index with rollover capability needs to be created. It creates an index with the format <logstash-default-{now/d}-000001> where logstash denotes the index_prefix and default denotes the application_name which can be set.
495
+ 'deflector_alias' is a required field for rollover_index set to true.
496
+ 'index_prefix' and 'application_name' are optional and defaults to logstash and default respectively.
497
+ ```
498
+ rollover_index true # defaults to false
499
+ ```
500
+
501
+ If [customize_template](#customize_template) is set, then this parameter will be in effect otherwise ignored.
502
+
503
+ ### index_date_pattern
504
+
505
+ Specify this to override the index date pattern for creating a rollover index. The default is to use "now/d",
506
+ for example: <logstash-default-{now/d}-000001>. Overriding this changes the rollover time period. Setting
507
+ "now/w{xxxx.ww}" would create weekly rollover indexes instead of daily.
508
+
509
+ This setting only takes effect when combined with the [enable_ilm](#enable_ilm) setting.
510
+
511
+ ```
512
+ index_date_pattern "now/w{xxxx.ww}" # defaults to "now/d"
513
+ ```
514
+
515
+ If empty string(`""`) is specified in `index_date_pattern`, index date pattern is not used.
516
+ Elasticsearch plugin just creates <`target_index`-`application_name`-000001> rollover index instead of <`target_index`-`application_name`-`{index_date_pattern}`-000001>.
517
+
518
+ If [customize_template](#customize_template) is set, then this parameter will be in effect otherwise ignored.
519
+
520
+ ### deflector_alias
521
+
522
+ Specify the deflector alias which would be assigned to the rollover index created. This is useful in case of using the Elasticsearch rollover API
523
+ ```
524
+ deflector_alias test-current
252
525
  ```
253
526
 
254
- If `template_file` and `template_name` are set, then this parameter will be ignored.
527
+ If [rollover_index](#rollover_index) is set, then this parameter will be in effect otherwise ignored.
528
+
529
+ **NOTE:** Since 4.1.1, `deflector_alias` is prohibited to use with `enable_ilm`.
530
+
531
+ ### index_prefix
532
+
533
+ This parameter is marked as obsoleted.
534
+ Consider to use [index_name](#index_name) for specify ILM target index when not using with logstash_format.
535
+ When specifying `logstash_format` as true, consider to use [logstash_prefix](#logstash_prefix) to specify ILM target index prefix.
536
+
537
+ ### application_name
538
+
539
+ Specify the application name for the rollover index to be created.
540
+ ```
541
+ application_name default # defaults to "default"
542
+ ```
543
+
544
+ If [enable_ilm](#enable_ilm) is set, then this parameter will be in effect otherwise ignored.
545
+
546
+ ### template_overwrite
547
+
548
+ Always update the template, even if it already exists.
549
+
550
+ ```
551
+ template_overwrite true # defaults to false
552
+ ```
553
+
554
+ One of [template_file](#template_file) or [templates](#templates) must also be specified if this is set.
555
+
556
+ ### max_retry_putting_template
557
+
558
+ You can specify times of retry putting template.
559
+
560
+ This is useful when Elasticsearch plugin cannot connect Elasticsearch to put template.
561
+ Usually, booting up clustered Elasticsearch containers are much slower than launching Fluentd container.
562
+
563
+ ```
564
+ max_retry_putting_template 15 # defaults to 10
565
+ ```
566
+
567
+ ### fail_on_putting_template_retry_exceed
568
+
569
+ Indicates whether to fail when `max_retry_putting_template` is exceeded.
570
+ If you have multiple output plugin, you could use this property to do not fail on fluentd statup.
571
+
572
+ ```
573
+ fail_on_putting_template_retry_exceed false # defaults to true
574
+ ```
575
+
576
+ ### fail_on_detecting_es_version_retry_exceed
577
+
578
+ Indicates whether to fail when `max_retry_get_es_version` is exceeded.
579
+ If you want to use fallback mechanism for obtaining ELasticsearch version, you could use this property to do not fail on fluentd statup.
580
+
581
+ ```
582
+ fail_on_detecting_es_version_retry_exceed false
583
+ ```
584
+
585
+ And the following parameters should be working with:
586
+
587
+ ```
588
+ verify_es_version_at_startup true
589
+ max_retry_get_es_version 2 # greater than 0.
590
+ default_elasticsearch_version 7 # This version is used when occurring fallback.
591
+ ```
592
+
593
+ ### max_retry_get_es_version
594
+
595
+ You can specify times of retry obtaining Elasticsearch version.
596
+
597
+ This is useful when Elasticsearch plugin cannot connect Elasticsearch to obtain Elasticsearch version.
598
+ Usually, booting up clustered Elasticsearch containers are much slower than launching Fluentd container.
599
+
600
+ ```
601
+ max_retry_get_es_version 17 # defaults to 15
602
+ ```
255
603
 
256
604
  ### request_timeout
257
605
 
258
606
  You can specify HTTP request timeout.
259
607
 
260
- This is useful when ElasticSearch cannot return response for bulk request within the default of 5 seconds.
608
+ This is useful when Elasticsearch cannot return response for bulk request within the default of 5 seconds.
261
609
 
262
610
  ```
263
611
  request_timeout 15s # defaults to 5s
@@ -265,7 +613,7 @@ request_timeout 15s # defaults to 5s
265
613
 
266
614
  ### reload_connections
267
615
 
268
- 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.
616
+ 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.
269
617
 
270
618
  ```
271
619
  reload_connections false # defaults to true
@@ -285,7 +633,7 @@ reload_on_failure true # defaults to false
285
633
  You can set in the elasticsearch-transport how often dead connections from the elasticsearch-transport's pool will be resurrected.
286
634
 
287
635
  ```
288
- resurrect_after 5 # defaults to 60s
636
+ resurrect_after 5s # defaults to 60s
289
637
  ```
290
638
 
291
639
  ### include_tag_key, tag_key
@@ -305,10 +653,10 @@ This will add the Fluentd tag in the JSON record. For instance, if you have a co
305
653
  </match>
306
654
  ```
307
655
 
308
- The record inserted into ElasticSearch would be
656
+ The record inserted into Elasticsearch would be
309
657
 
310
658
  ```
311
- {"_key":"my.logs", "name":"Johnny Doeie"}
659
+ {"_key": "my.logs", "name": "Johnny Doeie"}
312
660
  ```
313
661
 
314
662
  ### id_key
@@ -317,15 +665,63 @@ The record inserted into ElasticSearch would be
317
665
  id_key request_id # use "request_id" field as a record id in ES
318
666
  ```
319
667
 
320
- By default, all records inserted into ElasticSearch get a random _id. This option allows to use a field in the record as an identifier.
668
+ By default, all records inserted into Elasticsearch get a random _id. This option allows to use a field in the record as an identifier.
321
669
 
322
- This following record `{"name":"Johnny","request_id":"87d89af7daffad6"}` will trigger the following ElasticSearch command
670
+ This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will trigger the following Elasticsearch command
323
671
 
324
672
  ```
325
- { "index" : { "_index" : "logstash-2013.01.01, "_type" : "fluentd", "_id" : "87d89af7daffad6" } }
673
+ { "index" : { "_index": "logstash-2013.01.01", "_type": "fluentd", "_id": "87d89af7daffad6" } }
326
674
  { "name": "Johnny", "request_id": "87d89af7daffad6" }
327
675
  ```
328
676
 
677
+ Fluentd re-emits events that failed to be indexed/ingested in Elasticsearch with a new and unique `_id` value, this means that congested Elasticsearch clusters that reject events (due to command queue overflow, for example) will cause Fluentd to re-emit the event with a new `_id`, however Elasticsearch may actually process both (or more) attempts (with some delay) and create duplicate events in the index (since each have a unique `_id` value), one possible workaround is to use the [fluent-plugin-genhashvalue](https://github.com/mtakemi/fluent-plugin-genhashvalue) plugin to generate a unique `_hash` key in the record of each event, this `_hash` record can be used as the `id_key` to prevent Elasticsearch from creating duplicate events.
678
+
679
+ ```
680
+ id_key _hash
681
+ ```
682
+
683
+ Example configuration for [fluent-plugin-genhashvalue](https://github.com/mtakemi/fluent-plugin-genhashvalue) (review the documentation of the plugin for more details)
684
+ ```
685
+ <filter logs.**>
686
+ @type genhashvalue
687
+ keys session_id,request_id
688
+ hash_type md5 # md5/sha1/sha256/sha512
689
+ base64_enc true
690
+ base91_enc false
691
+ set_key _hash
692
+ separator _
693
+ inc_time_as_key true
694
+ inc_tag_as_key true
695
+ </filter>
696
+ ```
697
+
698
+ :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
699
+
700
+ #### Using nested key
701
+
702
+ Nested key specifying syntax is also supported.
703
+
704
+ With the following configuration
705
+
706
+ ```aconf
707
+ id_key $.nested.request_id
708
+ ```
709
+
710
+ and the following nested record
711
+
712
+ ```json
713
+ {"nested":{"name": "Johnny", "request_id": "87d89af7daffad6"}}
714
+ ```
715
+
716
+ will trigger the following Elasticsearch command
717
+
718
+ ```
719
+ {"index":{"_index":"fluentd","_type":"fluentd","_id":"87d89af7daffad6"}}
720
+ {"nested":{"name":"Johnny","request_id":"87d89af7daffad6"}}
721
+ ```
722
+
723
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
724
+
329
725
  ### parent_key
330
726
 
331
727
  ```
@@ -337,15 +733,40 @@ If your input is
337
733
  { "name": "Johnny", "a_parent": "my_parent" }
338
734
  ```
339
735
 
340
- ElasticSearch command would be
736
+ Elasticsearch command would be
341
737
 
342
738
  ```
343
- { "index" : { "_index" : "****", "_type" : "****", "_id" : "****", "_parent" : "my_parent" } }
739
+ { "index" : { "_index": "****", "_type": "****", "_id": "****", "_parent": "my_parent" } }
344
740
  { "name": "Johnny", "a_parent": "my_parent" }
345
741
  ```
346
742
 
347
743
  if `parent_key` is not configed or the `parent_key` is absent in input record, nothing will happen.
348
744
 
745
+ #### Using nested key
746
+
747
+ Nested key specifying syntax is also supported.
748
+
749
+ With the following configuration
750
+
751
+ ```aconf
752
+ parent_key $.nested.a_parent
753
+ ```
754
+
755
+ and the following nested record
756
+
757
+ ```json
758
+ {"nested":{ "name": "Johnny", "a_parent": "my_parent" }}
759
+ ```
760
+
761
+ will trigger the following Elasticsearch command
762
+
763
+ ```
764
+ {"index":{"_index":"fluentd","_type":"fluentd","_parent":"my_parent"}}
765
+ {"nested":{"name":"Johnny","a_parent":"my_parent"}}
766
+ ```
767
+
768
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
769
+
349
770
  ### routing_key
350
771
 
351
772
  Similar to `parent_key` config, will add `_routing` into elasticsearch command if `routing_key` is set and the field does exist in input event.
@@ -360,7 +781,7 @@ remove_keys a_parent, a_routing # a_parent and a_routing fields won't be sent to
360
781
 
361
782
  ### remove_keys_on_update
362
783
 
363
- Remove keys on update will not update the configured keys in elasticsearch when a record is being updated.
784
+ Remove keys on update will not update the configured keys in elasticsearch when a record is being updated.
364
785
  This setting only has any effect if the write operation is update or upsert.
365
786
 
366
787
  If the write setting is upsert then these keys are only removed if the record is being
@@ -381,6 +802,21 @@ present in the record then the keys in record are used, if the `remove_keys_on_u
381
802
  remove_keys_on_update_key keys_to_skip
382
803
  ```
383
804
 
805
+ ### retry_tag
806
+
807
+ This setting allows custom routing of messages in response to bulk request failures. The default behavior is to emit
808
+ failed records using the same tag that was provided. When set to a value other then `nil`, failed messages are emitted
809
+ with the specified tag:
810
+
811
+ ```
812
+ retry_tag 'retry_es'
813
+ ```
814
+ **NOTE:** `retry_tag` is optional. If you would rather use labels to reroute retries, add a label (e.g '@label @SOMELABEL') to your fluent
815
+ elasticsearch plugin configuration. Retry records are, by default, submitted for retry to the ROOT label, which means
816
+ records will flow through your fluentd pipeline from the beginning. This may nor may not be a problem if the pipeline
817
+ is idempotent - that is - you can process a record again with no changes. Use tagging or labeling to ensure your retry
818
+ records are not processed again by your fluentd processing pipeline.
819
+
384
820
  ### write_operation
385
821
 
386
822
  The write_operation can be any of:
@@ -409,31 +845,130 @@ We recommended to set this true in the presence of elasticsearch shield.
409
845
  reconnect_on_error true # defaults to false
410
846
  ```
411
847
 
848
+ ### with_transporter_log
849
+
850
+ This is debugging purpose option to enable to obtain transporter layer log.
851
+ Default value is `false` for backward compatibility.
852
+
853
+ We recommend to set this true if you start to debug this plugin.
854
+
855
+ ```
856
+ with_transporter_log true
857
+ ```
858
+
859
+ ### content_type
860
+
861
+ With `content_type application/x-ndjson`, elasticsearch plugin adds `application/x-ndjson` as `Content-Type` in payload.
862
+
863
+ Default value is `application/json` which is default Content-Type of Elasticsearch requests.
864
+ If you will not use template, it recommends to set `content_type application/x-ndjson`.
865
+
866
+ ```
867
+ content_type application/x-ndjson
868
+ ```
869
+
870
+ ### include_index_in_url
871
+
872
+ With this option set to true, Fluentd manifests the index name in the request URL (rather than in the request body).
873
+ You can use this option to enforce an URL-based access control.
874
+
875
+ ```
876
+ include_index_in_url true
877
+ ```
878
+
879
+ ### http_backend
880
+
881
+ With `http_backend typhoeus`, elasticsearch plugin uses typhoeus faraday http backend.
882
+ Typhoeus can handle HTTP keepalive.
883
+
884
+ Default value is `excon` which is default http_backend of elasticsearch plugin.
885
+
886
+ ```
887
+ http_backend typhoeus
888
+ ```
889
+
890
+ ### http_backend_excon_nonblock
891
+
892
+ With `http_backend_excon_nonblock false`, elasticsearch plugin use excon with nonblock=false.
893
+ If you use elasticsearch plugin with jRuby for https, you may need to consider to set `false` to avoid follwoing problems.
894
+ - https://github.com/geemus/excon/issues/106
895
+ - https://github.com/jruby/jruby-ossl/issues/19
896
+
897
+ But for all other case, it strongly reccomend to set `true` to avoid process hangin problem reported in https://github.com/uken/fluent-plugin-elasticsearch/issues/732
898
+
899
+ Default value is `true`.
900
+
901
+ ```
902
+ http_backend_excon_nonblock false
903
+ ```
904
+
905
+ ### compression_level
906
+ You can add gzip compression of output data. In this case `default_compression`, `best_compression` or `best speed` option should be chosen.
907
+ By default there is no compression, default value for this option is `no_compression`
908
+ ```
909
+ compression_level best_compression
910
+ ```
911
+
912
+ ### prefer_oj_serializer
913
+
914
+ With default behavior, Elasticsearch client uses `Yajl` as JSON encoder/decoder.
915
+ `Oj` is the alternative high performance JSON encoder/decoder.
916
+ When this parameter sets as `true`, Elasticsearch client uses `Oj` as JSON encoder/decoder.
917
+
918
+ Default value is `false`.
919
+
920
+ ```
921
+ prefer_oj_serializer true
922
+ ```
923
+
412
924
  ### Client/host certificate options
413
925
 
414
- Need to verify ElasticSearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
926
+ Need to verify Elasticsearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
415
927
  ```
416
928
  ca_file /path/to/your/ca/cert
417
929
  ```
418
930
 
419
- 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.
931
+ 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.
420
932
  ```
421
933
  client_cert /path/to/your/client/cert
422
934
  client_key /path/to/your/private/key
423
935
  client_key_pass password
424
936
  ```
425
937
 
938
+ If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
939
+ ```
940
+ ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
941
+ ```
942
+
943
+ :warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
944
+
945
+ In Elasticsearch plugin v4.0.2 with Ruby 2.5 or later combination, Elasticsearch plugin also support `ssl_max_version` and `ssl_min_version`.
946
+
947
+ ```
948
+ ssl_max_version TLSv1_3
949
+ ssl_min_version TLSv1_2
950
+ ```
951
+
952
+ Elasticsearch plugin will use TLSv1.2 as minimum ssl version and TLSv1.3 as maximum ssl version on transportation with TLS. Note that when they are used in Elastissearch plugin configuration, *`ssl_version` is not used* to set up TLS version.
953
+
954
+ If they are *not* specified in the Elasticsearch plugin configuration, `ssl_max_version` and `ssl_min_version` is set up with:
955
+
956
+ In Elasticsearch plugin v4.0.8 or later with Ruby 2.5 or later environment, `ssl_max_version` should be `TLSv1_3` and `ssl_min_version` should be `TLSv1_2`.
957
+
958
+ From Elasticsearch plugin v4.0.4 to v4.0.7 with Ruby 2.5 or later environment, the value of `ssl_version` will be *used in `ssl_max_version` and `ssl_min_version`*.
959
+
960
+
426
961
  ### Proxy Support
427
962
 
428
963
  Starting with version 0.8.0, this gem uses excon, which supports proxy with environment variables - https://github.com/excon/excon#proxy-support
429
964
 
430
- ### Buffered output options
965
+ ### Buffer options
431
966
 
432
- `fluentd-plugin-elasticsearch` extends [Fluentd's builtin Buffered Output plugin](http://docs.fluentd.org/articles/buffer-plugin-overview). It adds the following options:
967
+ `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:
433
968
 
434
969
  ```
435
970
  buffer_type memory
436
- flush_interval 60
971
+ flush_interval 60s
437
972
  retry_limit 17
438
973
  retry_wait 1.0
439
974
  num_threads 1
@@ -441,6 +976,10 @@ num_threads 1
441
976
 
442
977
  The value for option `buffer_chunk_limit` should not exceed value `http.max_content_length` in your Elasticsearch setup (by default it is 100mb).
443
978
 
979
+ **Note**: If you use or evaluate Fluentd v0.14, you can use `<buffer>` directive to specify buffer configuration, too. In more detail, please refer to the [buffer configuration options for v0.14](https://docs.fluentd.org/v0.14/articles/buffer-plugin-overview#configuration-parameters)
980
+
981
+ **Note**: If you use `disable_retry_limit` in v0.12 or `retry_forever` in v0.14 or later, please be careful to consume memory inexhaustibly.
982
+
444
983
  ### Hash flattening
445
984
 
446
985
  Elasticsearch will complain if you send object and concrete values to the same field. For example, you might have logs that look this, from different places:
@@ -460,11 +999,171 @@ This will produce elasticsearch output that looks like this:
460
999
 
461
1000
  Note that the flattener does not deal with arrays at this time.
462
1001
 
1002
+ ### Generate Hash ID
1003
+
1004
+ By default, the fluentd elasticsearch plugin does not emit records with a _id field, leaving it to Elasticsearch to generate a unique _id as the record is indexed. When an Elasticsearch cluster is congested and begins to take longer to respond than the configured request_timeout, the fluentd elasticsearch plugin will re-send the same bulk request. Since Elasticsearch can't tell its actually the same request, all documents in the request are indexed again resulting in duplicate data. In certain scenarios, this can result in essentially and infinite loop generating multiple copies of the same data.
1005
+
1006
+ The bundled elasticsearch_genid filter can generate a unique _hash key for each record, this key may be passed to the id_key parameter in the elasticsearch plugin to communicate to Elasticsearch the uniqueness of the requests so that duplicates will be rejected or simply replace the existing records.
1007
+ Here is a sample config:
1008
+
1009
+ ```
1010
+ <filter **>
1011
+ @type elasticsearch_genid
1012
+ hash_id_key _hash # storing generated hash id key (default is _hash)
1013
+ </filter>
1014
+ <match **>
1015
+ @type elasticsearch
1016
+ id_key _hash # specify same key name which is specified in hash_id_key
1017
+ remove_keys _hash # Elasticsearch doesn't like keys that start with _
1018
+ # other settings are omitted.
1019
+ </match>
1020
+ ```
1021
+
1022
+ ### Sniffer Class Name
1023
+
1024
+ The default Sniffer used by the `Elasticsearch::Transport` class works well when Fluentd has a direct connection
1025
+ to all of the Elasticsearch servers and can make effective use of the `_nodes` API. This doesn't work well
1026
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
1027
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
1028
+ there is a new `Fluent::Plugin::ElasticsearchSimpleSniffer` class which reuses the hosts given in the configuration, which
1029
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
1030
+ connections to `logging-es` to reload every 100 operations:
1031
+
1032
+ ```
1033
+ host logging-es
1034
+ port 9200
1035
+ reload_connections true
1036
+ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
1037
+ reload_after 100
1038
+ ```
1039
+
1040
+ #### Tips
1041
+
1042
+ The included sniffer class is not required `out_elasticsearch`.
1043
+ You should tell Fluentd where the sniffer class exists.
1044
+
1045
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1046
+
1047
+ ```
1048
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
1049
+ TD_AGENT_OPTIONS="--use-v1-config -r $sniffer"
1050
+ ```
1051
+
1052
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1053
+
1054
+ ```
1055
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
1056
+ $ fluentd -r $sniffer [AND YOUR OTHER OPTIONS]
1057
+ ```
1058
+
1059
+ ### Selector Class Name
1060
+
1061
+ The default selector used by the `Elasticsearch::Transport` class works well when Fluentd should behave round robin and random selector cases. This doesn't work well when Fluentd should behave fallbacking from exhausted ES cluster to normal ES cluster.
1062
+ The parameter `selector_class_name` gives you the ability to provide your own Selector class to implement whatever selection nodes logic you require.
1063
+
1064
+ The below configuration is using plugin built-in `ElasticseatchFallbackSelector`:
1065
+
1066
+ ```
1067
+ hosts exhausted-host:9201,normal-host:9200
1068
+ selector_class_name "Fluent::Plugin::ElasticseatchFallbackSelector"
1069
+ ```
1070
+
1071
+ #### Tips
1072
+
1073
+ The included selector class is required in `out_elasticsearch` by default.
1074
+ But, your custom selector class is not required in `out_elasticsearch`.
1075
+ You should tell Fluentd where the selector class exists.
1076
+
1077
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1078
+
1079
+ ```
1080
+ selector=/path/to/your_awesome_selector.rb
1081
+ TD_AGENT_OPTIONS="--use-v1-config -r $selector"
1082
+ ```
1083
+
1084
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1085
+
1086
+ ```
1087
+ selector=/path/to/your_awesome_selector.rb
1088
+ $ fluentd -r $selector [AND YOUR OTHER OPTIONS]
1089
+ ```
1090
+
1091
+ ### Reload After
1092
+
1093
+ When `reload_connections true`, this is the integer number of operations after which the plugin will
1094
+ reload the connections. The default value is 10000.
1095
+
1096
+ ### Validate Client Version
1097
+
1098
+ When you use mismatched Elasticsearch server and client libraries, fluent-plugin-elasticsearch cannot send data into Elasticsearch. The default value is `false`.
1099
+
1100
+ ```
1101
+ validate_client_version true
1102
+ ```
1103
+
1104
+ ### Unrecoverable Error Types
1105
+
1106
+ Default `unrecoverable_error_types` parameter is set up strictly.
1107
+ Because `es_rejected_execution_exception` is caused by exceeding Elasticsearch's thread pool capacity.
1108
+ Advanced users can increase its capacity, but normal users should follow default behavior.
1109
+
1110
+ If you want to increase it and forcibly retrying bulk request, please consider to change `unrecoverable_error_types` parameter from default value.
1111
+
1112
+ Change default value of `thread_pool.bulk.queue_size` in elasticsearch.yml:
1113
+ e.g.)
1114
+
1115
+ ```yaml
1116
+ thread_pool.bulk.queue_size: 1000
1117
+ ```
1118
+
1119
+ Then, remove `es_rejected_execution_exception` from `unrecoverable_error_types` parameter:
1120
+
1121
+ ```
1122
+ unrecoverable_error_types ["out_of_memory_error"]
1123
+ ```
1124
+
1125
+ ### verify_es_version_at_startup
1126
+
1127
+ Because Elasticsearch plugin should change behavior each of Elasticsearch major versions.
1128
+
1129
+ For example, Elasticsearch 6 starts to prohibit multiple type_names in one index, and Elasticsearch 7 will handle only `_doc` type_name in index.
1130
+
1131
+ If you want to disable to verify Elasticsearch version at start up, set it as `false`.
1132
+
1133
+ When using the following configuration, ES plugin intends to communicate into Elasticsearch 6.
1134
+
1135
+ ```
1136
+ verify_es_version_at_startup false
1137
+ default_elasticsearch_version 6
1138
+ ```
1139
+
1140
+ The default value is `true`.
1141
+
1142
+ ### default_elasticsearch_version
1143
+
1144
+ This parameter changes that ES plugin assumes default Elasticsearch version. The default value is `5`.
1145
+
1146
+ ### custom_headers
1147
+
1148
+ This parameter adds additional headers to request. The default value is `{}`.
1149
+
1150
+ ```
1151
+ custom_headers {"token":"secret"}
1152
+ ```
1153
+
1154
+ ### api_key
1155
+
1156
+ This parameter adds authentication header. The default value is `nil`.
1157
+
1158
+ ```
1159
+ api_key "ElasticsearchAPIKEY"
1160
+ ```
1161
+
463
1162
  ### Not seeing a config you need?
464
1163
 
465
1164
  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.
466
1165
 
467
- 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:
1166
+ 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:
468
1167
 
469
1168
  ```
470
1169
  <match my.logs.*>
@@ -480,9 +1179,13 @@ Alternatively, consider using [fluent-plugin-forest](https://github.com/tagomori
480
1179
 
481
1180
  And yet another option is described in Dynamic Configuration section.
482
1181
 
1182
+ **Note**: If you use or evaluate Fluentd v0.14, you can use builtin placeholders. In more detail, please refer to [Placeholders](#placeholders) section.
1183
+
483
1184
  ### Dynamic configuration
484
1185
 
485
- 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:
1186
+ **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.
1187
+
1188
+ 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:
486
1189
 
487
1190
  ```
488
1191
  <match my.logs.*>
@@ -497,6 +1200,273 @@ If you want configurations to depend on information in messages, you can use `el
497
1200
 
498
1201
  **Please note, this uses Ruby's `eval` for every message, so there are performance and security implications.**
499
1202
 
1203
+ ### Placeholders
1204
+
1205
+ v0.14 placeholders can handle `${tag}` for tag, `%Y%m%d` like strftime format, and custom record keys like as `record["mykey"]`.
1206
+
1207
+ Note that custom chunk key is different notations for `record_reformer` and `record_modifier`.
1208
+ They uses `record["some_key"]` to specify placeholders, but this feature uses `${key1}`, `${key2}` notation. And tag, time, and some arbitrary keys must be included in buffer directive attributes.
1209
+
1210
+ They are used as below:
1211
+
1212
+ #### tag
1213
+
1214
+ ```aconf
1215
+ <match my.logs>
1216
+ @type elasticsearch
1217
+ index_name elastic.${tag} #=> replaced with each event's tag. e.g.) elastic.test.tag
1218
+ <buffer tag>
1219
+ @type memory
1220
+ </buffer>
1221
+ # <snip>
1222
+ </match>
1223
+ ```
1224
+
1225
+ #### time
1226
+
1227
+ ```aconf
1228
+ <match my.logs>
1229
+ @type elasticsearch
1230
+ index_name elastic.%Y%m%d #=> e.g.) elastic.20170811
1231
+ <buffer tag, time>
1232
+ @type memory
1233
+ timekey 3600
1234
+ </buffer>
1235
+ # <snip>
1236
+ </match>
1237
+ ```
1238
+
1239
+ #### custom key
1240
+
1241
+ ```log
1242
+ records = {key1: "value1", key2: "value2"}
1243
+ ```
1244
+
1245
+ ```aconf
1246
+ <match my.logs>
1247
+ @type elasticsearch
1248
+ index_name elastic.${key1}.${key2} # => e.g.) elastic.value1.value2
1249
+ <buffer tag, key1, key2>
1250
+ @type memory
1251
+ </buffer>
1252
+ # <snip>
1253
+ </match>
1254
+ ```
1255
+
1256
+ ## Multi workers
1257
+
1258
+ Since Fluentd v0.14, multi workers feature had been implemented to increase throughput with multiple processes. This feature allows Fluentd processes to use one or more CPUs. This feature will be enabled by the following system configuration:
1259
+
1260
+ ```
1261
+ <system>
1262
+ workers N # where N is a natural number (N >= 1).
1263
+ </system>
1264
+ ```
1265
+
1266
+ ## log_es_400_reason
1267
+
1268
+ By default, the error logger won't record the reason for a 400 error from the Elasticsearch API unless you set log_level to debug. However, this results in a lot of log spam, which isn't desirable if all you want is the 400 error reasons. You can set this `true` to capture the 400 error reasons without all the other debug logs.
1269
+
1270
+ Default value is `false`.
1271
+
1272
+ ## suppress_doc_wrap
1273
+
1274
+ By default, record body is wrapped by 'doc'. This behavior can not handle update script requests. You can set this to suppress doc wrapping and allow record body to be untouched.
1275
+
1276
+ Default value is `false`.
1277
+
1278
+ ## ignore_exceptions
1279
+
1280
+ A list of exception that will be ignored - when the exception occurs the chunk will be discarded and the buffer retry mechanism won't be called. It is possible also to specify classes at higher level in the hierarchy. For example
1281
+
1282
+ ```
1283
+ ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]
1284
+ ```
1285
+
1286
+ will match all subclasses of `ServerError` - `Elasticsearch::Transport::Transport::Errors::BadRequest`, `Elasticsearch::Transport::Transport::Errors::ServiceUnavailable`, etc.
1287
+
1288
+ Default value is empty list (no exception is ignored).
1289
+
1290
+ ## exception_backup
1291
+
1292
+ Indicates whether to backup chunk when ignore exception occurs.
1293
+
1294
+ Default value is `true`.
1295
+
1296
+ ## bulk_message_request_threshold
1297
+
1298
+ Configure `bulk_message` request splitting threshold size.
1299
+
1300
+ Default value is `-1`(unlimited).
1301
+
1302
+ If you specify this size as negative number, `bulk_message` request splitting feature will be disabled.
1303
+
1304
+ ## enable_ilm
1305
+
1306
+ Enable Index Lifecycle Management (ILM).
1307
+
1308
+ Default value is `false`.
1309
+
1310
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1311
+
1312
+ ## ilm_policy_id
1313
+
1314
+ Specify ILM policy id.
1315
+
1316
+ Default value is `logstash-policy`.
1317
+
1318
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1319
+
1320
+ ## ilm_policy
1321
+
1322
+ Specify ILM policy contents as Hash.
1323
+
1324
+ Default value is `{}`.
1325
+
1326
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1327
+
1328
+ ## ilm_policies
1329
+
1330
+ A hash in the format `{"ilm_policy_id1":{ <ILM policy 1 hash> }, "ilm_policy_id2": { <ILM policy 2 hash> }}`.
1331
+
1332
+ Default value is `{}`.
1333
+
1334
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1335
+
1336
+ ## ilm_policy_overwrite
1337
+
1338
+ Specify whether overwriting ilm policy or not.
1339
+
1340
+ Default value is `false`.
1341
+
1342
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1343
+
1344
+ ## truncate_caches_interval
1345
+
1346
+ Specify truncating caches interval.
1347
+
1348
+ If it is set, timer for clearing `alias_indexes` and `template_names` caches will be launched and executed.
1349
+
1350
+ Default value is `nil`.
1351
+
1352
+ ## use_legacy_template
1353
+
1354
+ Use legacy template or not.
1355
+
1356
+ For Elasticsearch 7.8 or later, users can specify this parameter as `false` if their [template_file](#template_file) contains a composable index template.
1357
+
1358
+ For Elasticsearch 7.7 or older, users should specify this parameter as `true`.
1359
+
1360
+ Composable template documentation is [Put Index Template API | Elasticsearch Reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html) and legacy template documentation is [Index Templates | Elasticsearch Reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).
1361
+
1362
+ 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.
1363
+
1364
+ ## <metadata\> section
1365
+
1366
+ Users can specify whether including `chunk_id` information into records or not:
1367
+
1368
+ ```aconf
1369
+ <match your.awesome.routing.tag>
1370
+ @type elasticsearch
1371
+ # Other configurations.
1372
+ <metadata>
1373
+ include_chunk_id true
1374
+ # chunk_id_key chunk_id # Default value is "chunk_id".
1375
+ </metadata>
1376
+ </match>
1377
+ ```
1378
+
1379
+ ### include_chunk_id
1380
+
1381
+ Whether including `chunk_id` for not. Default value is `false`.
1382
+
1383
+ ```aconf
1384
+ <match your.awesome.routing.tag>
1385
+ @type elasticsearch
1386
+ # Other configurations.
1387
+ <metadata>
1388
+ include_chunk_id true
1389
+ </metadata>
1390
+ </match>
1391
+ ```
1392
+
1393
+
1394
+ ### chunk_id_key
1395
+
1396
+ Specify `chunk_id_key` to store `chunk_id` information into records. Default value is `chunk_id`.
1397
+
1398
+ ```aconf
1399
+ <match your.awesome.routing.tag>
1400
+ @type elasticsearch
1401
+ # Other configurations.
1402
+ <metadata>
1403
+ include_chunk_id
1404
+ chunk_id_key chunk_hex
1405
+ </metadata>
1406
+ </match>
1407
+ ```
1408
+
1409
+ ## Configuration - Elasticsearch Input
1410
+
1411
+ See [Elasticsearch Input plugin document](README.ElasticsearchInput.md)
1412
+
1413
+ ## Configuration - Elasticsearch Filter GenID
1414
+
1415
+ See [Elasticsearch Filter GenID document](README.ElasticsearchGenID.md)
1416
+
1417
+ ## Elasticsearch permissions
1418
+
1419
+ If the target Elasticsearch requires authentication, a user holding the necessary permissions needs to be provided.
1420
+
1421
+ The set of required permissions are the following:
1422
+
1423
+ ```json
1424
+ "cluster": ["manage_index_templates", "monitor", "manage_ilm"],
1425
+ "indices": [
1426
+ {
1427
+ "names": [ "*" ],
1428
+ "privileges": ["write","create","delete","create_index","manage","manage_ilm"]
1429
+ }
1430
+ ]
1431
+ ```
1432
+
1433
+ These permissions can be narrowed down by:
1434
+
1435
+ - Setting a more specific pattern for indices under the `names` field
1436
+ - Removing the `manage_index_templates` cluster permission when not using the feature within your plugin configuration
1437
+ - Removing the `manage_ilm` cluster permission and the `manage` and `manage_ilm` indices privileges when not using ilm
1438
+ features in the plugin configuration
1439
+
1440
+ The list of privileges along with their description can be found in
1441
+ [security privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html).
1442
+
1443
+ ## Configuration - Elasticsearch Output Data Stream
1444
+
1445
+ Since Elasticsearch 7.9, Data Streams was introduced.
1446
+
1447
+ You can enable this feature by specifying `@type elasticsearch_data_stream`.
1448
+
1449
+ ```
1450
+ @type elasticsearch_data_stream
1451
+ data_stream_name test
1452
+ ```
1453
+
1454
+ When `@type elasticsearch_data_stream` is used, ILM default policy is set to the specified data stream.
1455
+ Then, the matching index template is also created automatically.
1456
+
1457
+ ### data_stream_name
1458
+
1459
+ You can specify Elasticsearch data stream name by this parameter.
1460
+ This parameter is mandatory for `elasticsearch_data_stream`.
1461
+
1462
+ There are some limitations about naming rule.
1463
+
1464
+ In more detail, please refer to the [Path parameters](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-data-stream.html#indices-create-data-stream-api-path-params).
1465
+
1466
+ ## Troubleshooting
1467
+
1468
+ See [Troubleshooting document](README.Troubleshooting.md)
1469
+
500
1470
  ## Contact
501
1471
 
502
1472
  If you have a question, [open an Issue](https://github.com/uken/fluent-plugin-elasticsearch/issues).
@@ -507,6 +1477,8 @@ There are usually a few feature requests, tagged [Easy](https://github.com/uken/
507
1477
 
508
1478
  Pull Requests are welcomed.
509
1479
 
1480
+ Becore send a pull request or report an issue, please read [the contribution guideline](CONTRIBUTING.md).
1481
+
510
1482
  [![Pull Request Graph](https://graphs.waffle.io/uken/fluent-plugin-elasticsearch/throughput.svg)](https://waffle.io/uken/fluent-plugin-elasticsearch/metrics)
511
1483
 
512
1484
  ## Running tests
@@ -517,4 +1489,7 @@ Install dev dependencies:
517
1489
  $ gem install bundler
518
1490
  $ bundle install
519
1491
  $ bundle exec rake test
1492
+ # To just run the test you are working on:
1493
+ $ bundle exec rake test TEST=test/plugin/test_out_elasticsearch.rb TESTOPTS='--verbose --name=test_custom_template_with_rollover_index_create_and_custom_ilm'
1494
+
520
1495
  ```