fluent-plugin-elasticsearch-dext 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.editorconfig +9 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  6. data/.github/workflows/issue-auto-closer.yml +12 -0
  7. data/.github/workflows/linux.yml +26 -0
  8. data/.github/workflows/macos.yml +26 -0
  9. data/.github/workflows/windows.yml +26 -0
  10. data/.gitignore +18 -0
  11. data/.travis.yml +40 -0
  12. data/CONTRIBUTING.md +24 -0
  13. data/Gemfile +11 -0
  14. data/History.md +553 -0
  15. data/ISSUE_TEMPLATE.md +30 -0
  16. data/LICENSE.txt +201 -0
  17. data/PULL_REQUEST_TEMPLATE.md +10 -0
  18. data/README.ElasticsearchGenID.md +116 -0
  19. data/README.ElasticsearchInput.md +293 -0
  20. data/README.Troubleshooting.md +601 -0
  21. data/README.md +1467 -0
  22. data/Rakefile +11 -0
  23. data/appveyor.yml +20 -0
  24. data/fluent-plugin-elasticsearch.gemspec +35 -0
  25. data/gemfiles/Gemfile.elasticsearch.v6 +12 -0
  26. data/lib/fluent/log-ext.rb +38 -0
  27. data/lib/fluent/plugin/default-ilm-policy.json +14 -0
  28. data/lib/fluent/plugin/elasticsearch_constants.rb +13 -0
  29. data/lib/fluent/plugin/elasticsearch_error.rb +5 -0
  30. data/lib/fluent/plugin/elasticsearch_error_handler.rb +129 -0
  31. data/lib/fluent/plugin/elasticsearch_fallback_selector.rb +9 -0
  32. data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +67 -0
  33. data/lib/fluent/plugin/elasticsearch_index_template.rb +211 -0
  34. data/lib/fluent/plugin/elasticsearch_simple_sniffer.rb +10 -0
  35. data/lib/fluent/plugin/elasticsearch_tls.rb +70 -0
  36. data/lib/fluent/plugin/filter_elasticsearch_genid.rb +77 -0
  37. data/lib/fluent/plugin/in_elasticsearch.rb +325 -0
  38. data/lib/fluent/plugin/oj_serializer.rb +22 -0
  39. data/lib/fluent/plugin/out_elasticsearch.rb +1108 -0
  40. data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +218 -0
  41. data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +282 -0
  42. data/test/helper.rb +24 -0
  43. data/test/plugin/test_alias_template.json +9 -0
  44. data/test/plugin/test_elasticsearch_error_handler.rb +646 -0
  45. data/test/plugin/test_elasticsearch_fallback_selector.rb +74 -0
  46. data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +66 -0
  47. data/test/plugin/test_elasticsearch_tls.rb +145 -0
  48. data/test/plugin/test_filter_elasticsearch_genid.rb +215 -0
  49. data/test/plugin/test_in_elasticsearch.rb +459 -0
  50. data/test/plugin/test_index_alias_template.json +11 -0
  51. data/test/plugin/test_index_template.json +25 -0
  52. data/test/plugin/test_oj_serializer.rb +19 -0
  53. data/test/plugin/test_out_elasticsearch.rb +5688 -0
  54. data/test/plugin/test_out_elasticsearch_data_stream.rb +337 -0
  55. data/test/plugin/test_out_elasticsearch_dynamic.rb +1134 -0
  56. data/test/plugin/test_template.json +23 -0
  57. data/test/test_log-ext.rb +35 -0
  58. metadata +236 -0
data/README.md ADDED
@@ -0,0 +1,1467 @@
1
+ # Fluent::Plugin::Elasticsearch, a plugin for [Fluentd](http://fluentd.org)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-elasticsearch.png)](http://badge.fury.io/rb/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)
7
+ [![Coverage Status](https://coveralls.io/repos/uken/fluent-plugin-elasticsearch/badge.png)](https://coveralls.io/r/uken/fluent-plugin-elasticsearch)
8
+ [![Code Climate](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch.png)](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch)
9
+
10
+ Send your logs to Elasticsearch (and search them with Kibana maybe?)
11
+
12
+ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-elasticsearch-service](https://github.com/atomita/fluent-plugin-aws-elasticsearch-service)
13
+
14
+ Current maintainers: @cosmo0920
15
+
16
+ * [Installation](#installation)
17
+ * [Usage](#usage)
18
+ + [Index templates](#index-templates)
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)
25
+ + [hosts](#hosts)
26
+ + [user, password, path, scheme, ssl_verify](#user-password-path-scheme-ssl_verify)
27
+ + [logstash_format](#logstash_format)
28
+ + [logstash_prefix](#logstash_prefix)
29
+ + [logstash_prefix_separator](#logstash_prefix_separator)
30
+ + [logstash_dateformat](#logstash_dateformat)
31
+ + [pipeline](#pipeline)
32
+ + [time_key_format](#time_key_format)
33
+ + [time_precision](#time_precision)
34
+ + [time_key](#time_key)
35
+ + [time_key_exclude_timestamp](#time_key_exclude_timestamp)
36
+ + [include_timestamp](#include_timestamp)
37
+ + [utc_index](#utc_index)
38
+ + [suppress_type_name](#suppress_type_name)
39
+ + [target_index_key](#target_index_key)
40
+ + [target_type_key](#target_type_key)
41
+ + [template_name](#template_name)
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)
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)
55
+ + [request_timeout](#request_timeout)
56
+ + [reload_connections](#reload_connections)
57
+ + [reload_on_failure](#reload_on_failure)
58
+ + [resurrect_after](#resurrect_after)
59
+ + [include_tag_key, tag_key](#include_tag_key-tag_key)
60
+ + [id_key](#id_key)
61
+ + [parent_key](#parent_key)
62
+ + [routing_key](#routing_key)
63
+ + [remove_keys](#remove_keys)
64
+ + [remove_keys_on_update](#remove_keys_on_update)
65
+ + [remove_keys_on_update_key](#remove_keys_on_update_key)
66
+ + [retry_tag](#retry_tag)
67
+ + [write_operation](#write_operation)
68
+ + [time_parse_error_tag](#time_parse_error_tag)
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)
77
+ + [Client/host certificate options](#clienthost-certificate-options)
78
+ + [Proxy Support](#proxy-support)
79
+ + [Buffer options](#buffer-options)
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)
91
+ + [Not seeing a config you need?](#not-seeing-a-config-you-need)
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)
115
+ * [Contact](#contact)
116
+ * [Contributing](#contributing)
117
+ * [Running tests](#running-tests)
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
+
134
+ ## Installation
135
+
136
+ ```sh
137
+ $ gem install fluent-plugin-elasticsearch
138
+ ```
139
+
140
+ ## Usage
141
+
142
+ In your Fluentd configuration, use `@type elasticsearch`. Additional configuration is optional, default values would look like this:
143
+
144
+ ```
145
+ <match my.logs>
146
+ @type elasticsearch
147
+ host localhost
148
+ port 9200
149
+ index_name fluentd
150
+ type_name fluentd
151
+ </match>
152
+ ```
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
+
158
+ ### Index templates
159
+
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.
161
+
162
+ ## Configuration
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
+ ### port
175
+
176
+ ```
177
+ port 9201 # defaults to 9200
178
+ ```
179
+
180
+ You can specify Elasticsearch port by this parameter.
181
+
182
+ ### cloud_id
183
+
184
+ ```
185
+ cloud_id test-dep:ZXVyb3BlLXdlc3QxLmdjcC5jbG91ZC5lcy5pbyRiYZTA1Ng==
186
+ ```
187
+
188
+ You can specify Elasticsearch cloud_id by this parameter.
189
+
190
+ If you specify `cloud_id` option then `cloud_auth` option is required.
191
+ If you specify `cloud_id` option, `host`, `port`, `user` and `password` options are ignored.
192
+
193
+ ### cloud_auth
194
+
195
+ ```
196
+ cloud_auth 'elastic:slkjdaooewkd87iqQ2O8EQYV'
197
+ ```
198
+
199
+ You can specify Elasticsearch cloud_auth by this parameter.
200
+
201
+
202
+ ### emit_error_for_missing_id
203
+
204
+ ```
205
+ emit_error_for_missing_id true
206
+ ```
207
+ When `write_operation` is configured to anything other then `index`, setting this value to `true` will
208
+ cause the plugin to `emit_error_event` of any records which do not include an `_id` field. The default (`false`)
209
+ behavior is to silently drop the records.
210
+
211
+ ### hosts
212
+
213
+ ```
214
+ hosts host1:port1,host2:port2,host3:port3
215
+ ```
216
+
217
+ You can specify multiple Elasticsearch hosts with separator ",".
218
+
219
+ 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.
220
+
221
+ If you specify `hosts` option, `host` and `port` options are ignored.
222
+
223
+ ```
224
+ host user-custom-host.domain # ignored
225
+ port 9200 # ignored
226
+ hosts host1:port1,host2:port2,host3:port3
227
+ ```
228
+
229
+ If you specify `hosts` option without port, `port` option is used.
230
+
231
+ ```
232
+ port 9200
233
+ hosts host1:port1,host2:port2,host3 # port3 is 9200
234
+ ```
235
+
236
+ **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"
237
+
238
+ **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.
239
+
240
+ ### user, password, path, scheme, ssl_verify
241
+
242
+ ```
243
+ user demo
244
+ password secret
245
+ path /elastic_search/
246
+ scheme https
247
+ ```
248
+
249
+ You can specify user and password for HTTP Basic authentication.
250
+
251
+ And this plugin will escape required URL encoded characters within `%{}` placeholders.
252
+
253
+ ```
254
+ user %{demo+}
255
+ password %{@secret}
256
+ ```
257
+
258
+ Specify `ssl_verify false` to skip ssl verification (defaults to true)
259
+
260
+ ### logstash_format
261
+
262
+ ```
263
+ logstash_format true # defaults to false
264
+ ```
265
+
266
+ 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}`
267
+
268
+ :warning: Setting this option to `true` will ignore the `index_name` setting. The default index name prefix is `logstash-`.
269
+
270
+ ### include_timestamp
271
+
272
+ ```
273
+ include_timestamp true # defaults to false
274
+ ```
275
+
276
+ 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.
277
+
278
+ ### logstash_prefix
279
+
280
+ ```
281
+ logstash_prefix mylogs # defaults to "logstash"
282
+ ```
283
+
284
+ ### logstash_prefix_separator
285
+
286
+ ```
287
+ logstash_prefix_separator _ # defaults to "-"
288
+ ```
289
+
290
+ ### logstash_dateformat
291
+
292
+ 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.
293
+
294
+ ```
295
+ logstash_dateformat %Y.%m. # defaults to "%Y.%m.%d"
296
+ ```
297
+
298
+ ### pipeline
299
+
300
+ Only in ES >= 5.x is available to use this parameter.
301
+ This param is to set a pipeline id of your elasticsearch to be added into the request, you can configure ingest node.
302
+ For more information: [![Ingest node](https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest.html)]
303
+
304
+ ```
305
+ pipeline pipeline_id
306
+ ```
307
+
308
+ ### time_key_format
309
+
310
+ 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.
311
+
312
+ 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`.
313
+
314
+ For example to parse ISO8601 times with sub-second precision:
315
+
316
+ ```
317
+ time_key_format %Y-%m-%dT%H:%M:%S.%N%z
318
+ ```
319
+
320
+ ### time_precision
321
+
322
+ 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.
323
+
324
+ 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).
325
+
326
+ ### time_key
327
+
328
+ 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.
329
+
330
+ ```
331
+ {"@timestamp": "2014-04-07T000:00:00-00:00"}
332
+ ```
333
+
334
+ 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.
335
+
336
+ Suppose you have settings
337
+
338
+ ```
339
+ logstash_format true
340
+ time_key vtm
341
+ ```
342
+
343
+ Your input is:
344
+ ```
345
+ {
346
+ "title": "developer",
347
+ "vtm": "2014-12-19T08:01:03Z"
348
+ }
349
+ ```
350
+
351
+ The output will be
352
+ ```
353
+ {
354
+ "title": "developer",
355
+ "@timestamp": "2014-12-19T08:01:03Z",
356
+ "vtm": "2014-12-19T08:01:03Z"
357
+ }
358
+ ```
359
+
360
+ See `time_key_exclude_timestamp` to avoid adding `@timestamp`.
361
+
362
+ ### time_key_exclude_timestamp
363
+
364
+ ```
365
+ time_key_exclude_timestamp false
366
+ ```
367
+
368
+ By default, setting `time_key` will copy the value to an additional field `@timestamp`. When setting `time_key_exclude_timestamp true`, no additional field will be added.
369
+
370
+ ### utc_index
371
+
372
+ ```
373
+ utc_index true
374
+ ```
375
+
376
+ 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.
377
+
378
+ ### suppress_type_name
379
+
380
+ In Elasticsearch 7.x, Elasticsearch cluster complains the following types removal warnings:
381
+
382
+ ```json
383
+ {"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" }
384
+ ```
385
+
386
+ This can be suppressed with:
387
+
388
+ ```
389
+ suppress_type_name true
390
+ ```
391
+
392
+ ### target_index_key
393
+
394
+ 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.
395
+
396
+ 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.
397
+
398
+ Suppose you have the following settings
399
+
400
+ ```
401
+ target_index_key @target_index
402
+ index_name fallback
403
+ ```
404
+
405
+ If your input is:
406
+ ```
407
+ {
408
+ "title": "developer",
409
+ "@timestamp": "2014-12-19T08:01:03Z",
410
+ "@target_index": "logstash-2014.12.19"
411
+ }
412
+ ```
413
+
414
+ The output would be
415
+
416
+ ```
417
+ {
418
+ "title": "developer",
419
+ "@timestamp": "2014-12-19T08:01:03Z",
420
+ }
421
+ ```
422
+
423
+ and this record will be written to the specified index (`logstash-2014.12.19`) rather than `fallback`.
424
+
425
+ ### target_type_key
426
+
427
+ Similar to `target_index_key` config, find the type name to write to in the record under this key (or nested record). If key not found in record - fallback to `type_name` (default "fluentd").
428
+
429
+ ### template_name
430
+
431
+ 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.
432
+
433
+ 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).
434
+
435
+ [template_file](#template_file) must also be specified.
436
+
437
+ ### template_file
438
+
439
+ The path to the file containing the template to install.
440
+
441
+ [template_name](#template_name) must also be specified.
442
+
443
+ ### templates
444
+
445
+ Specify index templates in form of hash. Can contain multiple templates.
446
+
447
+ ```
448
+ templates { "template_name_1": "path_to_template_1_file", "template_name_2": "path_to_template_2_file"}
449
+ ```
450
+
451
+ **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`.
452
+
453
+ ### customize_template
454
+
455
+ 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.
456
+ This setting only creates template and to add rollover index please check the [rollover_index](#rollover_index) configuration.
457
+
458
+ ```
459
+ customize_template {"string_1": "subs_value_1", "string_2": "subs_value_2"}
460
+ ```
461
+
462
+ If [template_file](#template_file) and [template_name](#template_name) are set, then this parameter will be in effect otherwise ignored.
463
+
464
+ ### rollover_index
465
+
466
+ 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.
467
+ 'deflector_alias' is a required field for rollover_index set to true.
468
+ 'index_prefix' and 'application_name' are optional and defaults to logstash and default respectively.
469
+ ```
470
+ rollover_index true # defaults to false
471
+ ```
472
+
473
+ If [customize_template](#customize_template) is set, then this parameter will be in effect otherwise ignored.
474
+
475
+ ### index_date_pattern
476
+
477
+ Specify this to override the index date pattern for creating a rollover index. The default is to use "now/d",
478
+ for example: <logstash-default-{now/d}-000001>. Overriding this changes the rollover time period. Setting
479
+ "now/w{xxxx.ww}" would create weekly rollover indexes instead of daily.
480
+
481
+ This setting only takes effect when combined with the [enable_ilm](#enable_ilm) setting.
482
+
483
+ ```
484
+ index_date_pattern "now/w{xxxx.ww}" # defaults to "now/d"
485
+ ```
486
+
487
+ If empty string(`""`) is specified in `index_date_pattern`, index date pattern is not used.
488
+ Elasticsearch plugin just creates <`target_index`-`application_name`-000001> rollover index instead of <`target_index`-`application_name`-`{index_date_pattern}`-000001>.
489
+
490
+ If [customize_template](#customize_template) is set, then this parameter will be in effect otherwise ignored.
491
+
492
+ ### deflector_alias
493
+
494
+ Specify the deflector alias which would be assigned to the rollover index created. This is useful in case of using the Elasticsearch rollover API
495
+ ```
496
+ deflector_alias test-current
497
+ ```
498
+
499
+ If [rollover_index](#rollover_index) is set, then this parameter will be in effect otherwise ignored.
500
+
501
+ **NOTE:** Since 4.1.1, `deflector_alias` is prohibited to use with `enable_ilm`.
502
+
503
+ ### index_prefix
504
+
505
+ This parameter is marked as obsoleted.
506
+ Consider to use [index_name](#index_name) for specify ILM target index when not using with logstash_format.
507
+ When specifying `logstash_format` as true, consider to use [logstash_prefix](#logstash_prefix) to specify ILM target index prefix.
508
+
509
+ ### application_name
510
+
511
+ Specify the application name for the rollover index to be created.
512
+ ```
513
+ application_name default # defaults to "default"
514
+ ```
515
+
516
+ If [enable_ilm](#enable_ilm) is set, then this parameter will be in effect otherwise ignored.
517
+
518
+ ### template_overwrite
519
+
520
+ Always update the template, even if it already exists.
521
+
522
+ ```
523
+ template_overwrite true # defaults to false
524
+ ```
525
+
526
+ One of [template_file](#template_file) or [templates](#templates) must also be specified if this is set.
527
+
528
+ ### max_retry_putting_template
529
+
530
+ You can specify times of retry putting template.
531
+
532
+ This is useful when Elasticsearch plugin cannot connect Elasticsearch to put template.
533
+ Usually, booting up clustered Elasticsearch containers are much slower than launching Fluentd container.
534
+
535
+ ```
536
+ max_retry_putting_template 15 # defaults to 10
537
+ ```
538
+
539
+ ### fail_on_putting_template_retry_exceed
540
+
541
+ Indicates whether to fail when `max_retry_putting_template` is exceeded.
542
+ If you have multiple output plugin, you could use this property to do not fail on fluentd statup.
543
+
544
+ ```
545
+ fail_on_putting_template_retry_exceed false # defaults to true
546
+ ```
547
+
548
+ ### fail_on_detecting_es_version_retry_exceed
549
+
550
+ Indicates whether to fail when `max_retry_get_es_version` is exceeded.
551
+ If you want to use fallback mechanism for obtaining ELasticsearch version, you could use this property to do not fail on fluentd statup.
552
+
553
+ ```
554
+ fail_on_detecting_es_version_retry_exceed false
555
+ ```
556
+
557
+ And the following parameters should be working with:
558
+
559
+ ```
560
+ verify_es_version_at_startup true
561
+ max_retry_get_es_version 2 # greater than 0.
562
+ default_elasticsearch_version 7 # This version is used when occurring fallback.
563
+ ```
564
+
565
+ ### max_retry_get_es_version
566
+
567
+ You can specify times of retry obtaining Elasticsearch version.
568
+
569
+ This is useful when Elasticsearch plugin cannot connect Elasticsearch to obtain Elasticsearch version.
570
+ Usually, booting up clustered Elasticsearch containers are much slower than launching Fluentd container.
571
+
572
+ ```
573
+ max_retry_get_es_version 17 # defaults to 15
574
+ ```
575
+
576
+ ### request_timeout
577
+
578
+ You can specify HTTP request timeout.
579
+
580
+ This is useful when Elasticsearch cannot return response for bulk request within the default of 5 seconds.
581
+
582
+ ```
583
+ request_timeout 15s # defaults to 5s
584
+ ```
585
+
586
+ ### reload_connections
587
+
588
+ 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.
589
+
590
+ ```
591
+ reload_connections false # defaults to true
592
+ ```
593
+
594
+ ### reload_on_failure
595
+
596
+ Indicates that the elasticsearch-transport will try to reload the nodes addresses if there is a failure while making the
597
+ request, this can be useful to quickly remove a dead node from the list of addresses.
598
+
599
+ ```
600
+ reload_on_failure true # defaults to false
601
+ ```
602
+
603
+ ### resurrect_after
604
+
605
+ You can set in the elasticsearch-transport how often dead connections from the elasticsearch-transport's pool will be resurrected.
606
+
607
+ ```
608
+ resurrect_after 5s # defaults to 60s
609
+ ```
610
+
611
+ ### include_tag_key, tag_key
612
+
613
+ ```
614
+ include_tag_key true # defaults to false
615
+ tag_key tag # defaults to tag
616
+ ```
617
+
618
+ This will add the Fluentd tag in the JSON record. For instance, if you have a config like this:
619
+
620
+ ```
621
+ <match my.logs>
622
+ @type elasticsearch
623
+ include_tag_key true
624
+ tag_key _key
625
+ </match>
626
+ ```
627
+
628
+ The record inserted into Elasticsearch would be
629
+
630
+ ```
631
+ {"_key": "my.logs", "name": "Johnny Doeie"}
632
+ ```
633
+
634
+ ### id_key
635
+
636
+ ```
637
+ id_key request_id # use "request_id" field as a record id in ES
638
+ ```
639
+
640
+ By default, all records inserted into Elasticsearch get a random _id. This option allows to use a field in the record as an identifier.
641
+
642
+ This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will trigger the following Elasticsearch command
643
+
644
+ ```
645
+ { "index" : { "_index": "logstash-2013.01.01", "_type": "fluentd", "_id": "87d89af7daffad6" } }
646
+ { "name": "Johnny", "request_id": "87d89af7daffad6" }
647
+ ```
648
+
649
+ 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.
650
+
651
+ ```
652
+ id_key _hash
653
+ ```
654
+
655
+ Example configuration for [fluent-plugin-genhashvalue](https://github.com/mtakemi/fluent-plugin-genhashvalue) (review the documentation of the plugin for more details)
656
+ ```
657
+ <filter logs.**>
658
+ @type genhashvalue
659
+ keys session_id,request_id
660
+ hash_type md5 # md5/sha1/sha256/sha512
661
+ base64_enc true
662
+ base91_enc false
663
+ set_key _hash
664
+ separator _
665
+ inc_time_as_key true
666
+ inc_tag_as_key true
667
+ </filter>
668
+ ```
669
+
670
+ :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
671
+
672
+ #### Using nested key
673
+
674
+ Nested key specifying syntax is also supported.
675
+
676
+ With the following configuration
677
+
678
+ ```aconf
679
+ id_key $.nested.request_id
680
+ ```
681
+
682
+ and the following nested record
683
+
684
+ ```json
685
+ {"nested":{"name": "Johnny", "request_id": "87d89af7daffad6"}}
686
+ ```
687
+
688
+ will trigger the following Elasticsearch command
689
+
690
+ ```
691
+ {"index":{"_index":"fluentd","_type":"fluentd","_id":"87d89af7daffad6"}}
692
+ {"nested":{"name":"Johnny","request_id":"87d89af7daffad6"}}
693
+ ```
694
+
695
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
696
+
697
+ ### parent_key
698
+
699
+ ```
700
+ parent_key a_parent # use "a_parent" field value to set _parent in elasticsearch command
701
+ ```
702
+
703
+ If your input is
704
+ ```
705
+ { "name": "Johnny", "a_parent": "my_parent" }
706
+ ```
707
+
708
+ Elasticsearch command would be
709
+
710
+ ```
711
+ { "index" : { "_index": "****", "_type": "****", "_id": "****", "_parent": "my_parent" } }
712
+ { "name": "Johnny", "a_parent": "my_parent" }
713
+ ```
714
+
715
+ if `parent_key` is not configed or the `parent_key` is absent in input record, nothing will happen.
716
+
717
+ #### Using nested key
718
+
719
+ Nested key specifying syntax is also supported.
720
+
721
+ With the following configuration
722
+
723
+ ```aconf
724
+ parent_key $.nested.a_parent
725
+ ```
726
+
727
+ and the following nested record
728
+
729
+ ```json
730
+ {"nested":{ "name": "Johnny", "a_parent": "my_parent" }}
731
+ ```
732
+
733
+ will trigger the following Elasticsearch command
734
+
735
+ ```
736
+ {"index":{"_index":"fluentd","_type":"fluentd","_parent":"my_parent"}}
737
+ {"nested":{"name":"Johnny","a_parent":"my_parent"}}
738
+ ```
739
+
740
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
741
+
742
+ ### routing_key
743
+
744
+ Similar to `parent_key` config, will add `_routing` into elasticsearch command if `routing_key` is set and the field does exist in input event.
745
+
746
+ ### remove_keys
747
+
748
+ ```
749
+ parent_key a_parent
750
+ routing_key a_routing
751
+ remove_keys a_parent, a_routing # a_parent and a_routing fields won't be sent to elasticsearch
752
+ ```
753
+
754
+ ### remove_keys_on_update
755
+
756
+ Remove keys on update will not update the configured keys in elasticsearch when a record is being updated.
757
+ This setting only has any effect if the write operation is update or upsert.
758
+
759
+ If the write setting is upsert then these keys are only removed if the record is being
760
+ updated, if the record does not exist (by id) then all of the keys are indexed.
761
+
762
+ ```
763
+ remove_keys_on_update foo,bar
764
+ ```
765
+
766
+ ### remove_keys_on_update_key
767
+
768
+ This setting allows `remove_keys_on_update` to be configured with a key in each record, in much the same way as `target_index_key` works.
769
+ The configured key is removed before indexing in elasticsearch. If both `remove_keys_on_update` and `remove_keys_on_update_key` is
770
+ present in the record then the keys in record are used, if the `remove_keys_on_update_key` is not present then the value of
771
+ `remove_keys_on_update` is used as a fallback.
772
+
773
+ ```
774
+ remove_keys_on_update_key keys_to_skip
775
+ ```
776
+
777
+ ### retry_tag
778
+
779
+ This setting allows custom routing of messages in response to bulk request failures. The default behavior is to emit
780
+ failed records using the same tag that was provided. When set to a value other then `nil`, failed messages are emitted
781
+ with the specified tag:
782
+
783
+ ```
784
+ retry_tag 'retry_es'
785
+ ```
786
+ **NOTE:** `retry_tag` is optional. If you would rather use labels to reroute retries, add a label (e.g '@label @SOMELABEL') to your fluent
787
+ elasticsearch plugin configuration. Retry records are, by default, submitted for retry to the ROOT label, which means
788
+ records will flow through your fluentd pipeline from the beginning. This may nor may not be a problem if the pipeline
789
+ is idempotent - that is - you can process a record again with no changes. Use tagging or labeling to ensure your retry
790
+ records are not processed again by your fluentd processing pipeline.
791
+
792
+ ### write_operation
793
+
794
+ The write_operation can be any of:
795
+
796
+ | Operation | Description |
797
+ | ------------- | ----------- |
798
+ | index (default) | new data is added while existing data (based on its id) is replaced (reindexed).|
799
+ | create | adds new data - if the data already exists (based on its id), the op is skipped.|
800
+ | update | updates existing data (based on its id). If no data is found, the op is skipped.|
801
+ | upsert | known as merge or insert if the data does not exist, updates if the data exists (based on its id).|
802
+
803
+ **Please note, id is required in create, update, and upsert scenario. Without id, the message will be dropped.**
804
+
805
+ ### time_parse_error_tag
806
+
807
+ With `logstash_format true`, elasticsearch plugin parses timestamp field for generating index name. If the record has invalid timestamp value, this plugin emits an error event to `@ERROR` label with `time_parse_error_tag` configured tag.
808
+
809
+ Default value is `Fluent::ElasticsearchOutput::TimeParser.error` for backward compatibility. `::` separated tag is not good for tag routing because some plugins assume tag is separated by `.`. We recommend to set this parameter like `time_parse_error_tag es_plugin.output.time.error`.
810
+ We will change default value to `.` separated tag.
811
+
812
+ ### reconnect_on_error
813
+ Indicates that the plugin should reset connection on any error (reconnect on next send).
814
+ By default it will reconnect only on "host unreachable exceptions".
815
+ We recommended to set this true in the presence of elasticsearch shield.
816
+ ```
817
+ reconnect_on_error true # defaults to false
818
+ ```
819
+
820
+ ### with_transporter_log
821
+
822
+ This is debugging purpose option to enable to obtain transporter layer log.
823
+ Default value is `false` for backward compatibility.
824
+
825
+ We recommend to set this true if you start to debug this plugin.
826
+
827
+ ```
828
+ with_transporter_log true
829
+ ```
830
+
831
+ ### content_type
832
+
833
+ With `content_type application/x-ndjson`, elasticsearch plugin adds `application/x-ndjson` as `Content-Type` in payload.
834
+
835
+ Default value is `application/json` which is default Content-Type of Elasticsearch requests.
836
+ If you will not use template, it recommends to set `content_type application/x-ndjson`.
837
+
838
+ ```
839
+ content_type application/x-ndjson
840
+ ```
841
+
842
+ ### include_index_in_url
843
+
844
+ With this option set to true, Fluentd manifests the index name in the request URL (rather than in the request body).
845
+ You can use this option to enforce an URL-based access control.
846
+
847
+ ```
848
+ include_index_in_url true
849
+ ```
850
+
851
+ ### http_backend
852
+
853
+ With `http_backend typhoeus`, elasticsearch plugin uses typhoeus faraday http backend.
854
+ Typhoeus can handle HTTP keepalive.
855
+
856
+ Default value is `excon` which is default http_backend of elasticsearch plugin.
857
+
858
+ ```
859
+ http_backend typhoeus
860
+ ```
861
+
862
+ ### http_backend_excon_nonblock
863
+
864
+ With `http_backend_excon_nonblock false`, elasticsearch plugin use excon with nonblock=false.
865
+ If you use elasticsearch plugin with jRuby for https, you may need to consider to set `false` to avoid follwoing problems.
866
+ - https://github.com/geemus/excon/issues/106
867
+ - https://github.com/jruby/jruby-ossl/issues/19
868
+
869
+ 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
870
+
871
+ Default value is `true`.
872
+
873
+ ```
874
+ http_backend_excon_nonblock false
875
+ ```
876
+
877
+ ### compression_level
878
+ You can add gzip compression of output data. In this case `default_compression`, `best_compression` or `best speed` option should be chosen.
879
+ By default there is no compression, default value for this option is `no_compression`
880
+ ```
881
+ compression_level best_compression
882
+ ```
883
+
884
+ ### prefer_oj_serializer
885
+
886
+ With default behavior, Elasticsearch client uses `Yajl` as JSON encoder/decoder.
887
+ `Oj` is the alternative high performance JSON encoder/decoder.
888
+ When this parameter sets as `true`, Elasticsearch client uses `Oj` as JSON encoder/decoder.
889
+
890
+ Default value is `false`.
891
+
892
+ ```
893
+ prefer_oj_serializer true
894
+ ```
895
+
896
+ ### Client/host certificate options
897
+
898
+ Need to verify Elasticsearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
899
+ ```
900
+ ca_file /path/to/your/ca/cert
901
+ ```
902
+
903
+ 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.
904
+ ```
905
+ client_cert /path/to/your/client/cert
906
+ client_key /path/to/your/private/key
907
+ client_key_pass password
908
+ ```
909
+
910
+ If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
911
+ ```
912
+ ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
913
+ ```
914
+
915
+ :warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
916
+
917
+ In Elasticsearch plugin v4.0.2 with Ruby 2.5 or later combination, Elasticsearch plugin also support `ssl_max_version` and `ssl_min_version`.
918
+
919
+ ```
920
+ ssl_max_version TLSv1_3
921
+ ssl_min_version TLSv1_2
922
+ ```
923
+
924
+ 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.
925
+
926
+ If they are *not* specified in the Elasticsearch plugin configuration, `ssl_max_version` and `ssl_min_version` is set up with:
927
+
928
+ 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`.
929
+
930
+ 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`*.
931
+
932
+
933
+ ### Proxy Support
934
+
935
+ Starting with version 0.8.0, this gem uses excon, which supports proxy with environment variables - https://github.com/excon/excon#proxy-support
936
+
937
+ ### Buffer options
938
+
939
+ `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:
940
+
941
+ ```
942
+ buffer_type memory
943
+ flush_interval 60s
944
+ retry_limit 17
945
+ retry_wait 1.0
946
+ num_threads 1
947
+ ```
948
+
949
+ The value for option `buffer_chunk_limit` should not exceed value `http.max_content_length` in your Elasticsearch setup (by default it is 100mb).
950
+
951
+ **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)
952
+
953
+ **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.
954
+
955
+ ### Hash flattening
956
+
957
+ 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:
958
+
959
+ {"people" => 100}
960
+ {"people" => {"some" => "thing"}}
961
+
962
+ The second log line will be rejected by the Elasticsearch parser because objects and concrete values can't live in the same field. To combat this, you can enable hash flattening.
963
+
964
+ ```
965
+ flatten_hashes true
966
+ flatten_hashes_separator _
967
+ ```
968
+
969
+ This will produce elasticsearch output that looks like this:
970
+ {"people_some" => "thing"}
971
+
972
+ Note that the flattener does not deal with arrays at this time.
973
+
974
+ ### Generate Hash ID
975
+
976
+ 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.
977
+
978
+ 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.
979
+ Here is a sample config:
980
+
981
+ ```
982
+ <filter **>
983
+ @type elasticsearch_genid
984
+ hash_id_key _hash # storing generated hash id key (default is _hash)
985
+ </filter>
986
+ <match **>
987
+ @type elasticsearch
988
+ id_key _hash # specify same key name which is specified in hash_id_key
989
+ remove_keys _hash # Elasticsearch doesn't like keys that start with _
990
+ # other settings are omitted.
991
+ </match>
992
+ ```
993
+
994
+ ### Sniffer Class Name
995
+
996
+ The default Sniffer used by the `Elasticsearch::Transport` class works well when Fluentd has a direct connection
997
+ to all of the Elasticsearch servers and can make effective use of the `_nodes` API. This doesn't work well
998
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
999
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
1000
+ there is a new `Fluent::Plugin::ElasticsearchSimpleSniffer` class which reuses the hosts given in the configuration, which
1001
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
1002
+ connections to `logging-es` to reload every 100 operations:
1003
+
1004
+ ```
1005
+ host logging-es
1006
+ port 9200
1007
+ reload_connections true
1008
+ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
1009
+ reload_after 100
1010
+ ```
1011
+
1012
+ #### Tips
1013
+
1014
+ The included sniffer class is not required `out_elasticsearch`.
1015
+ You should tell Fluentd where the sniffer class exists.
1016
+
1017
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1018
+
1019
+ ```
1020
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
1021
+ TD_AGENT_OPTIONS="--use-v1-config -r $sniffer"
1022
+ ```
1023
+
1024
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1025
+
1026
+ ```
1027
+ sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
1028
+ $ fluentd -r $sniffer [AND YOUR OTHER OPTIONS]
1029
+ ```
1030
+
1031
+ ### Selector Class Name
1032
+
1033
+ 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.
1034
+ The parameter `selector_class_name` gives you the ability to provide your own Selector class to implement whatever selection nodes logic you require.
1035
+
1036
+ The below configuration is using plugin built-in `ElasticseatchFallbackSelector`:
1037
+
1038
+ ```
1039
+ hosts exhausted-host:9201,normal-host:9200
1040
+ selector_class_name "Fluent::Plugin::ElasticseatchFallbackSelector"
1041
+ ```
1042
+
1043
+ #### Tips
1044
+
1045
+ The included selector class is required in `out_elasticsearch` by default.
1046
+ But, your custom selector class is not required in `out_elasticsearch`.
1047
+ You should tell Fluentd where the selector class exists.
1048
+
1049
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1050
+
1051
+ ```
1052
+ selector=/path/to/your_awesome_selector.rb
1053
+ TD_AGENT_OPTIONS="--use-v1-config -r $selector"
1054
+ ```
1055
+
1056
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1057
+
1058
+ ```
1059
+ selector=/path/to/your_awesome_selector.rb
1060
+ $ fluentd -r $selector [AND YOUR OTHER OPTIONS]
1061
+ ```
1062
+
1063
+ ### Reload After
1064
+
1065
+ When `reload_connections true`, this is the integer number of operations after which the plugin will
1066
+ reload the connections. The default value is 10000.
1067
+
1068
+ ### Validate Client Version
1069
+
1070
+ When you use mismatched Elasticsearch server and client libraries, fluent-plugin-elasticsearch cannot send data into Elasticsearch. The default value is `false`.
1071
+
1072
+ ```
1073
+ validate_client_version true
1074
+ ```
1075
+
1076
+ ### Unrecoverable Error Types
1077
+
1078
+ Default `unrecoverable_error_types` parameter is set up strictly.
1079
+ Because `es_rejected_execution_exception` is caused by exceeding Elasticsearch's thread pool capacity.
1080
+ Advanced users can increase its capacity, but normal users should follow default behavior.
1081
+
1082
+ If you want to increase it and forcibly retrying bulk request, please consider to change `unrecoverable_error_types` parameter from default value.
1083
+
1084
+ Change default value of `thread_pool.bulk.queue_size` in elasticsearch.yml:
1085
+ e.g.)
1086
+
1087
+ ```yaml
1088
+ thread_pool.bulk.queue_size: 1000
1089
+ ```
1090
+
1091
+ Then, remove `es_rejected_execution_exception` from `unrecoverable_error_types` parameter:
1092
+
1093
+ ```
1094
+ unrecoverable_error_types ["out_of_memory_error"]
1095
+ ```
1096
+
1097
+ ### verify_es_version_at_startup
1098
+
1099
+ Because Elasticsearch plugin should change behavior each of Elasticsearch major versions.
1100
+
1101
+ For example, Elasticsearch 6 starts to prohibit multiple type_names in one index, and Elasticsearch 7 will handle only `_doc` type_name in index.
1102
+
1103
+ If you want to disable to verify Elasticsearch version at start up, set it as `false`.
1104
+
1105
+ When using the following configuration, ES plugin intends to communicate into Elasticsearch 6.
1106
+
1107
+ ```
1108
+ verify_es_version_at_startup false
1109
+ default_elasticsearch_version 6
1110
+ ```
1111
+
1112
+ The default value is `true`.
1113
+
1114
+ ### default_elasticsearch_version
1115
+
1116
+ This parameter changes that ES plugin assumes default Elasticsearch version. The default value is `5`.
1117
+
1118
+ ### custom_headers
1119
+
1120
+ This parameter adds additional headers to request. The default value is `{}`.
1121
+
1122
+ ```
1123
+ custom_headers {"token":"secret"}
1124
+ ```
1125
+
1126
+ ### api_key
1127
+
1128
+ This parameter adds authentication header. The default value is `nil`.
1129
+
1130
+ ```
1131
+ api_key "ElasticsearchAPIKEY"
1132
+ ```
1133
+
1134
+ ### Not seeing a config you need?
1135
+
1136
+ 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.
1137
+
1138
+ 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:
1139
+
1140
+ ```
1141
+ <match my.logs.*>
1142
+ @type forest
1143
+ subtype elasticsearch
1144
+ remove_prefix my.logs
1145
+ <template>
1146
+ logstash_prefix ${tag}
1147
+ # ...
1148
+ </template>
1149
+ </match>
1150
+ ```
1151
+
1152
+ And yet another option is described in Dynamic Configuration section.
1153
+
1154
+ **Note**: If you use or evaluate Fluentd v0.14, you can use builtin placeholders. In more detail, please refer to [Placeholders](#placeholders) section.
1155
+
1156
+ ### Dynamic configuration
1157
+
1158
+ **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.
1159
+
1160
+ 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:
1161
+
1162
+ ```
1163
+ <match my.logs.*>
1164
+ @type elasticsearch_dynamic
1165
+ hosts ${record['host1']}:9200,${record['host2']}:9200
1166
+ index_name my_index.${Time.at(time).getutc.strftime(@logstash_dateformat)}
1167
+ logstash_prefix ${tag_parts[3]}
1168
+ port ${9200+rand(4)}
1169
+ index_name ${tag_parts[2]}-${Time.at(time).getutc.strftime(@logstash_dateformat)}
1170
+ </match>
1171
+ ```
1172
+
1173
+ **Please note, this uses Ruby's `eval` for every message, so there are performance and security implications.**
1174
+
1175
+ ### Placeholders
1176
+
1177
+ v0.14 placeholders can handle `${tag}` for tag, `%Y%m%d` like strftime format, and custom record keys like as `record["mykey"]`.
1178
+
1179
+ Note that custom chunk key is different notations for `record_reformer` and `record_modifier`.
1180
+ 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.
1181
+
1182
+ They are used as below:
1183
+
1184
+ #### tag
1185
+
1186
+ ```aconf
1187
+ <match my.logs>
1188
+ @type elasticsearch
1189
+ index_name elastic.${tag} #=> replaced with each event's tag. e.g.) elastic.test.tag
1190
+ <buffer tag>
1191
+ @type memory
1192
+ </buffer>
1193
+ # <snip>
1194
+ </match>
1195
+ ```
1196
+
1197
+ #### time
1198
+
1199
+ ```aconf
1200
+ <match my.logs>
1201
+ @type elasticsearch
1202
+ index_name elastic.%Y%m%d #=> e.g.) elastic.20170811
1203
+ <buffer tag, time>
1204
+ @type memory
1205
+ timekey 3600
1206
+ </buffer>
1207
+ # <snip>
1208
+ </match>
1209
+ ```
1210
+
1211
+ #### custom key
1212
+
1213
+ ```log
1214
+ records = {key1: "value1", key2: "value2"}
1215
+ ```
1216
+
1217
+ ```aconf
1218
+ <match my.logs>
1219
+ @type elasticsearch
1220
+ index_name elastic.${key1}.${key2} # => e.g.) elastic.value1.value2
1221
+ <buffer tag, key1, key2>
1222
+ @type memory
1223
+ </buffer>
1224
+ # <snip>
1225
+ </match>
1226
+ ```
1227
+
1228
+ ## Multi workers
1229
+
1230
+ 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:
1231
+
1232
+ ```
1233
+ <system>
1234
+ workers N # where N is a natural number (N >= 1).
1235
+ </system>
1236
+ ```
1237
+
1238
+ ## log_es_400_reason
1239
+
1240
+ 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.
1241
+
1242
+ Default value is `false`.
1243
+
1244
+ ## suppress_doc_wrap
1245
+
1246
+ 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.
1247
+
1248
+ Default value is `false`.
1249
+
1250
+ ## ignore_exceptions
1251
+
1252
+ 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
1253
+
1254
+ ```
1255
+ ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]
1256
+ ```
1257
+
1258
+ will match all subclasses of `ServerError` - `Elasticsearch::Transport::Transport::Errors::BadRequest`, `Elasticsearch::Transport::Transport::Errors::ServiceUnavailable`, etc.
1259
+
1260
+ Default value is empty list (no exception is ignored).
1261
+
1262
+ ## exception_backup
1263
+
1264
+ Indicates whether to backup chunk when ignore exception occurs.
1265
+
1266
+ Default value is `true`.
1267
+
1268
+ ## bulk_message_request_threshold
1269
+
1270
+ Configure `bulk_message` request splitting threshold size.
1271
+
1272
+ Default value is `-1`(unlimited).
1273
+
1274
+ If you specify this size as negative number, `bulk_message` request splitting feature will be disabled.
1275
+
1276
+ ## enable_ilm
1277
+
1278
+ Enable Index Lifecycle Management (ILM).
1279
+
1280
+ Default value is `false`.
1281
+
1282
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1283
+
1284
+ ## ilm_policy_id
1285
+
1286
+ Specify ILM policy id.
1287
+
1288
+ Default value is `logstash-policy`.
1289
+
1290
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1291
+
1292
+ ## ilm_policy
1293
+
1294
+ Specify ILM policy contents as Hash.
1295
+
1296
+ Default value is `{}`.
1297
+
1298
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1299
+
1300
+ ## ilm_policies
1301
+
1302
+ A hash in the format `{"ilm_policy_id1":{ <ILM policy 1 hash> }, "ilm_policy_id2": { <ILM policy 2 hash> }}`.
1303
+
1304
+ Default value is `{}`.
1305
+
1306
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1307
+
1308
+ ## ilm_policy_overwrite
1309
+
1310
+ Specify whether overwriting ilm policy or not.
1311
+
1312
+ Default value is `false`.
1313
+
1314
+ **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1315
+
1316
+ ## truncate_caches_interval
1317
+
1318
+ Specify truncating caches interval.
1319
+
1320
+ If it is set, timer for clearing `alias_indexes` and `template_names` caches will be launched and executed.
1321
+
1322
+ Default value is `nil`.
1323
+
1324
+ ## use_legacy_template
1325
+
1326
+ Use legacy template or not.
1327
+
1328
+ Elasticsearch 7.8 or later supports the brand new composable templates.
1329
+
1330
+ For Elasticsearch 7.7 or older, users should specify this parameter as `false`.
1331
+
1332
+ 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).
1333
+
1334
+ 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.
1335
+
1336
+ ## <metadata\> section
1337
+
1338
+ Users can specify whether including `chunk_id` information into records or not:
1339
+
1340
+ ```aconf
1341
+ <match your.awesome.routing.tag>
1342
+ @type elasticsearch
1343
+ # Other configurations.
1344
+ <metadata>
1345
+ include_chunk_id true
1346
+ # chunk_id_key chunk_id # Default value is "chunk_id".
1347
+ </metadata>
1348
+ </match>
1349
+ ```
1350
+
1351
+ ### include_chunk_id
1352
+
1353
+ Whether including `chunk_id` for not. Default value is `false`.
1354
+
1355
+ ```aconf
1356
+ <match your.awesome.routing.tag>
1357
+ @type elasticsearch
1358
+ # Other configurations.
1359
+ <metadata>
1360
+ include_chunk_id true
1361
+ </metadata>
1362
+ </match>
1363
+ ```
1364
+
1365
+
1366
+ ### chunk_id_key
1367
+
1368
+ Specify `chunk_id_key` to store `chunk_id` information into records. Default value is `chunk_id`.
1369
+
1370
+ ```aconf
1371
+ <match your.awesome.routing.tag>
1372
+ @type elasticsearch
1373
+ # Other configurations.
1374
+ <metadata>
1375
+ include_chunk_id
1376
+ chunk_id_key chunk_hex
1377
+ </metadata>
1378
+ </match>
1379
+ ```
1380
+
1381
+ ## Configuration - Elasticsearch Input
1382
+
1383
+ See [Elasticsearch Input plugin document](README.ElasticsearchInput.md)
1384
+
1385
+ ## Configuration - Elasticsearch Filter GenID
1386
+
1387
+ See [Elasticsearch Filter GenID document](README.ElasticsearchGenID.md)
1388
+
1389
+ ## Elasticsearch permissions
1390
+
1391
+ If the target Elasticsearch requires authentication, a user holding the necessary permissions needs to be provided.
1392
+
1393
+ The set of required permissions are the following:
1394
+
1395
+ ```json
1396
+ "cluster": ["manage_index_templates", "monitor", "manage_ilm"],
1397
+ "indices": [
1398
+ {
1399
+ "names": [ "*" ],
1400
+ "privileges": ["write","create","delete","create_index","manage","manage_ilm"]
1401
+ }
1402
+ ]
1403
+ ```
1404
+
1405
+ These permissions can be narrowed down by:
1406
+
1407
+ - Setting a more specific pattern for indices under the `names` field
1408
+ - Removing the `manage_index_templates` cluster permission when not using the feature within your plugin configuration
1409
+ - Removing the `manage_ilm` cluster permission and the `manage` and `manage_ilm` indices privileges when not using ilm
1410
+ features in the plugin configuration
1411
+
1412
+ The list of privileges along with their description can be found in
1413
+ [security privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html).
1414
+
1415
+ ## Configuration - Elasticsearch Output Data Stream
1416
+
1417
+ Since Elasticsearch 7.9, Data Streams was introduced.
1418
+
1419
+ You can enable this feature by specifying `@type elasticsearch_data_stream`.
1420
+
1421
+ ```
1422
+ @type elasticsearch_data_stream
1423
+ data_stream_name test
1424
+ ```
1425
+
1426
+ When `@type elasticsearch_data_stream` is used, ILM default policy is set to the specified data stream.
1427
+ Then, the matching index template is also created automatically.
1428
+
1429
+ ### data_stream_name
1430
+
1431
+ You can specify Elasticsearch data stream name by this parameter.
1432
+ This parameter is mandatory for `elasticsearch_data_stream`.
1433
+
1434
+ There are some limitations about naming rule.
1435
+
1436
+ 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).
1437
+
1438
+ ## Troubleshooting
1439
+
1440
+ See [Troubleshooting document](README.Troubleshooting.md)
1441
+
1442
+ ## Contact
1443
+
1444
+ If you have a question, [open an Issue](https://github.com/uken/fluent-plugin-elasticsearch/issues).
1445
+
1446
+ ## Contributing
1447
+
1448
+ There are usually a few feature requests, tagged [Easy](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AEasy), [Normal](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3ANormal) and [Hard](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AHard). Feel free to work on any one of them.
1449
+
1450
+ Pull Requests are welcomed.
1451
+
1452
+ Becore send a pull request or report an issue, please read [the contribution guideline](CONTRIBUTING.md).
1453
+
1454
+ [![Pull Request Graph](https://graphs.waffle.io/uken/fluent-plugin-elasticsearch/throughput.svg)](https://waffle.io/uken/fluent-plugin-elasticsearch/metrics)
1455
+
1456
+ ## Running tests
1457
+
1458
+ Install dev dependencies:
1459
+
1460
+ ```sh
1461
+ $ gem install bundler
1462
+ $ bundle install
1463
+ $ bundle exec rake test
1464
+ # To just run the test you are working on:
1465
+ $ bundle exec rake test TEST=test/plugin/test_out_elasticsearch.rb TESTOPTS='--verbose --name=test_custom_template_with_rollover_index_create_and_custom_ilm'
1466
+
1467
+ ```