fluent-plugin-opensearch 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -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/coverage.yaml +22 -0
  7. data/.github/workflows/issue-auto-closer.yml +12 -0
  8. data/.github/workflows/linux.yml +26 -0
  9. data/.github/workflows/macos.yml +26 -0
  10. data/.github/workflows/windows.yml +26 -0
  11. data/.gitignore +18 -0
  12. data/CONTRIBUTING.md +24 -0
  13. data/Gemfile +10 -0
  14. data/History.md +6 -0
  15. data/ISSUE_TEMPLATE.md +26 -0
  16. data/LICENSE.txt +201 -0
  17. data/PULL_REQUEST_TEMPLATE.md +9 -0
  18. data/README.OpenSearchGenID.md +116 -0
  19. data/README.OpenSearchInput.md +291 -0
  20. data/README.Troubleshooting.md +482 -0
  21. data/README.md +1556 -0
  22. data/Rakefile +37 -0
  23. data/fluent-plugin-opensearch.gemspec +38 -0
  24. data/gemfiles/Gemfile.elasticsearch.v6 +12 -0
  25. data/lib/fluent/log-ext.rb +64 -0
  26. data/lib/fluent/plugin/filter_opensearch_genid.rb +103 -0
  27. data/lib/fluent/plugin/in_opensearch.rb +351 -0
  28. data/lib/fluent/plugin/oj_serializer.rb +48 -0
  29. data/lib/fluent/plugin/opensearch_constants.rb +39 -0
  30. data/lib/fluent/plugin/opensearch_error.rb +31 -0
  31. data/lib/fluent/plugin/opensearch_error_handler.rb +166 -0
  32. data/lib/fluent/plugin/opensearch_fallback_selector.rb +36 -0
  33. data/lib/fluent/plugin/opensearch_index_template.rb +155 -0
  34. data/lib/fluent/plugin/opensearch_simple_sniffer.rb +36 -0
  35. data/lib/fluent/plugin/opensearch_tls.rb +96 -0
  36. data/lib/fluent/plugin/out_opensearch.rb +1124 -0
  37. data/lib/fluent/plugin/out_opensearch_data_stream.rb +214 -0
  38. data/test/helper.rb +61 -0
  39. data/test/plugin/test_alias_template.json +9 -0
  40. data/test/plugin/test_filter_opensearch_genid.rb +241 -0
  41. data/test/plugin/test_in_opensearch.rb +493 -0
  42. data/test/plugin/test_index_alias_template.json +11 -0
  43. data/test/plugin/test_index_template.json +25 -0
  44. data/test/plugin/test_oj_serializer.rb +45 -0
  45. data/test/plugin/test_opensearch_error_handler.rb +689 -0
  46. data/test/plugin/test_opensearch_fallback_selector.rb +100 -0
  47. data/test/plugin/test_opensearch_tls.rb +171 -0
  48. data/test/plugin/test_out_opensearch.rb +3953 -0
  49. data/test/plugin/test_out_opensearch_data_stream.rb +474 -0
  50. data/test/plugin/test_template.json +23 -0
  51. data/test/test_log-ext.rb +61 -0
  52. metadata +262 -0
data/README.md ADDED
@@ -0,0 +1,1556 @@
1
+ # Fluent::Plugin::OpenSearch, a plugin for [Fluentd](http://fluentd.org)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-opensearch.png)](http://badge.fury.io/rb/fluent-plugin-opensearch)
4
+ ![Testing on Windows](https://github.com/fluent/fluent-plugin-opensearch/workflows/Testing%20on%20Windows/badge.svg?branch=main)
5
+ ![Testing on macOS](https://github.com/fluent/fluent-plugin-opensearch/workflows/Testing%20on%20macOS/badge.svg?branch=main)
6
+ ![Testing on Ubuntu](https://github.com/fluent/fluent-plugin-opensearch/workflows/Testing%20on%20Ubuntu/badge.svg?branch=main)
7
+ [![Coverage Status](https://coveralls.io/repos/github/fluent/fluent-plugin-opensearch/badge.svg?branch=upload-coverage-into-coveralls)](https://coveralls.io/github/fluent/fluent-plugin-opensearch?branch=main)
8
+
9
+ Send your logs to OpenSearch (and search them with OpenSearch Dashboard maybe?)
10
+
11
+ * [Installation](#installation)
12
+ * [Usage](#usage)
13
+ + [Index templates](#index-templates)
14
+ * [Configuration](#configuration)
15
+ + [host](#host)
16
+ + [port](#port)
17
+ + [emit_error_for_missing_id](#emit_error_for_missing_id)
18
+ + [hosts](#hosts)
19
+ + [user, password, path, scheme, ssl_verify](#user-password-path-scheme-ssl_verify)
20
+ + [logstash_format](#logstash_format)
21
+ + [logstash_prefix](#logstash_prefix)
22
+ + [logstash_prefix_separator](#logstash_prefix_separator)
23
+ + [logstash_dateformat](#logstash_dateformat)
24
+ + [pipeline](#pipeline)
25
+ + [time_key_format](#time_key_format)
26
+ + [time_precision](#time_precision)
27
+ + [time_key](#time_key)
28
+ + [time_key_exclude_timestamp](#time_key_exclude_timestamp)
29
+ + [include_timestamp](#include_timestamp)
30
+ + [utc_index](#utc_index)
31
+ + [suppress_type_name](#suppress_type_name)
32
+ + [target_index_key](#target_index_key)
33
+ + [target_type_key](#target_type_key)
34
+ + [target_index_affinity](#target_index_affinity)
35
+ + [template_name](#template_name)
36
+ + [template_file](#template_file)
37
+ + [template_overwrite](#template_overwrite)
38
+ + [customize_template](#customize_template)
39
+ + [index_date_pattern](#index_date_pattern)
40
+ + [application_name](#application_name)
41
+ + [index_prefix](#index_prefix)
42
+ + [templates](#templates)
43
+ + [max_retry_putting_template](#max_retry_putting_template)
44
+ + [fail_on_putting_template_retry_exceed](#fail_on_putting_template_retry_exceed)
45
+ + [fail_on_detecting_os_version_retry_exceed](#fail_on_detecting_os_version_retry_exceed)
46
+ + [max_retry_get_os_version](#max_retry_get_os_version)
47
+ + [request_timeout](#request_timeout)
48
+ + [reload_connections](#reload_connections)
49
+ + [reload_on_failure](#reload_on_failure)
50
+ + [resurrect_after](#resurrect_after)
51
+ + [include_tag_key, tag_key](#include_tag_key-tag_key)
52
+ + [id_key](#id_key)
53
+ + [parent_key](#parent_key)
54
+ + [routing_key](#routing_key)
55
+ + [remove_keys](#remove_keys)
56
+ + [remove_keys_on_update](#remove_keys_on_update)
57
+ + [remove_keys_on_update_key](#remove_keys_on_update_key)
58
+ + [retry_tag](#retry_tag)
59
+ + [write_operation](#write_operation)
60
+ + [time_parse_error_tag](#time_parse_error_tag)
61
+ + [reconnect_on_error](#reconnect_on_error)
62
+ + [with_transporter_log](#with_transporter_log)
63
+ + [content_type](#content_type)
64
+ + [include_index_in_url](#include_index_in_url)
65
+ + [http_backend](#http_backend)
66
+ + [http_backend_excon_nonblock](#http_backend_excon_nonblock)
67
+ + [prefer_oj_serializer](#prefer_oj_serializer)
68
+ + [compression_level](#compression_level)
69
+ + [Client/host certificate options](#clienthost-certificate-options)
70
+ + [Proxy Support](#proxy-support)
71
+ + [Buffer options](#buffer-options)
72
+ + [Hash flattening](#hash-flattening)
73
+ + [Generate Hash ID](#generate-hash-id)
74
+ + [sniffer_class_name](#sniffer-class-name)
75
+ + [selector_class_name](#selector-class-name)
76
+ + [reload_after](#reload-after)
77
+ + [validate_client_version](#validate-client-version)
78
+ + [unrecoverable_error_types](#unrecoverable-error-types)
79
+ + [verify os version at startup](#verify_os_version_at_startup)
80
+ + [default_opensearch_version](#default_opensearch_version)
81
+ + [custom_headers](#custom_headers)
82
+ + [api_key](#api_key)
83
+ + [Not seeing a config you need?](#not-seeing-a-config-you-need)
84
+ + [Dynamic configuration](#dynamic-configuration)
85
+ + [Placeholders](#placeholders)
86
+ + [Multi workers](#multi-workers)
87
+ + [log_os_400_reason](#log_os_400_reason)
88
+ + [suppress_doc_wrap](#suppress_doc_wrap)
89
+ + [ignore_exceptions](#ignore_exceptions)
90
+ + [exception_backup](#exception_backup)
91
+ + [bulk_message_request_threshold](#bulk_message_request_threshold)
92
+ + [truncate_caches_interval](#truncate_caches_interval)
93
+ + [use_legacy_template](#use_legacy_template)
94
+ + [metadata section](#metadata-section)
95
+ + [include_chunk_id](#include_chunk_id)
96
+ + [chunk_id_key](#chunk_id_key)
97
+ * [Configuration - OpenSearch Input](#configuration---opensearch-input)
98
+ * [Configuration - OpenSearch Filter GenID](#configuration---opensearch-filter-genid)
99
+ * [Configuration - OpenSearch Output Data Stream](#configuration---opensearch-output-data-stream)
100
+ * [Configuration - AWS OpenSearch Service](#configuration---aws-opensearch-service)
101
+ * [Troubleshooting](#troubleshooting)
102
+ * [Contact](#contact)
103
+ * [Contributing](#contributing)
104
+ * [Running tests](#running-tests)
105
+
106
+ ## Requirements
107
+
108
+ | fluent-plugin-opensearch | fluentd | ruby |
109
+ |:----------------------------:|:-----------:|:------:|
110
+ | >= 1.0.0 | >= v1.x | >= 2.4 |
111
+
112
+ NOTE: This documentation is for fluent-plugin-opensearch 1.x or later.
113
+
114
+ ## Installation
115
+
116
+ ```sh
117
+ $ gem install fluent-plugin-opensearch
118
+ ```
119
+
120
+ ## Usage
121
+
122
+ In your Fluentd configuration, use `@type opensearch`. Additional configuration is optional, default values would look like this:
123
+
124
+ ```
125
+ <match my.logs>
126
+ @type opensearch
127
+ host localhost
128
+ port 9200
129
+ index_name fluentd
130
+ </match>
131
+ ```
132
+
133
+ NOTE: `type_name` parameter is fixed value and cannot change and configure from `_doc` value for OpenSearch 1.
134
+
135
+ ### Index templates
136
+
137
+ This plugin creates OpenSearch indices by merely writing to them. Consider using [Index Templates](https://opensearch.org/docs/latest/opensearch/index-templates/) to gain control of what get indexed and how.
138
+
139
+ ## Configuration
140
+
141
+ ### host
142
+
143
+ ```
144
+ host user-custom-host.domain # default localhost
145
+ ```
146
+
147
+ You can specify OpenSearch host by this parameter.
148
+
149
+ To use IPv6 address on `host` parameter, you can use the following styles:
150
+
151
+ #### string style
152
+
153
+ To use string style, you must quote IPv6 address due to prevent to be interpreted as JSON:
154
+
155
+ ```
156
+ host "[2404:7a80:d440:3000:192a:a292:bd7f:ca10]"
157
+ ```
158
+
159
+ #### raw style
160
+
161
+ You can also specify raw IPv6 address. This will be handled as `[specified IPv6 address]`:
162
+
163
+ ```
164
+ host 2404:7a80:d440:3000:192a:a292:bd7f:ca10
165
+ ```
166
+
167
+ ### port
168
+
169
+ ```
170
+ port 9201 # defaults to 9200
171
+ ```
172
+
173
+ You can specify OpenSearch port by this parameter.
174
+
175
+ ### emit_error_for_missing_id
176
+
177
+ ```
178
+ emit_error_for_missing_id true
179
+ ```
180
+ When `write_operation` is configured to anything other then `index`, setting this value to `true` will
181
+ cause the plugin to `emit_error_event` of any records which do not include an `_id` field. The default (`false`)
182
+ behavior is to silently drop the records.
183
+
184
+ ### hosts
185
+
186
+ ```
187
+ hosts host1:port1,host2:port2,host3:port3
188
+ ```
189
+
190
+ You can specify multiple OpenSearch hosts with separator ",".
191
+
192
+ If you specify multiple hosts, this plugin will load balance updates to OpenSearch. This is an [opensearch-ruby](https://github.com/opensearch-project/opensearch-ruby) feature, the default strategy is round-robin.
193
+
194
+ If you specify `hosts` option, `host` and `port` options are ignored.
195
+
196
+ ```
197
+ host user-custom-host.domain # ignored
198
+ port 9200 # ignored
199
+ hosts host1:port1,host2:port2,host3:port3
200
+ ```
201
+
202
+ If you specify `hosts` option without port, `port` option is used.
203
+
204
+ ```
205
+ port 9200
206
+ hosts host1:port1,host2:port2,host3 # port3 is 9200
207
+ ```
208
+
209
+ **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 OpenSearch cluster"
210
+
211
+ **Note:** Embedded the username/password in the URL syntax is not recommended to use because it was found to cause serious connection problems. Please do not use its style on your settings and use the `user` and `password` field (described below) instead.
212
+
213
+ #### IPv6 addresses
214
+
215
+ When you want to specify IPv6 addresses, you must specify schema together:
216
+
217
+ ```
218
+ 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
219
+ ```
220
+
221
+ If you don't specify hosts with schema together, OpenSearch plugin complains Invalid URI for them.
222
+
223
+ ### user, password, path, scheme, ssl_verify
224
+
225
+ ```
226
+ user demo
227
+ password secret
228
+ path /elastic_search/
229
+ scheme https
230
+ ```
231
+
232
+ You can specify user and password for HTTP Basic authentication.
233
+
234
+ And this plugin will escape required URL encoded characters within `%{}` placeholders.
235
+
236
+ ```
237
+ user %{demo+}
238
+ password %{@secret}
239
+ ```
240
+
241
+ Specify `ssl_verify false` to skip ssl verification (defaults to true)
242
+
243
+ ### logstash_format
244
+
245
+ ```
246
+ logstash_format true # defaults to false
247
+ ```
248
+
249
+ This is meant to make writing data into OpenSearch 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}`
250
+
251
+ :warning: Setting this option to `true` will ignore the `index_name` setting. The default index name prefix is `logstash-`.
252
+
253
+ ### include_timestamp
254
+
255
+ ```
256
+ include_timestamp true # defaults to false
257
+ ```
258
+
259
+ 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 OpenSearch and utilize the rollover API.
260
+
261
+ ### logstash_prefix
262
+
263
+ ```
264
+ logstash_prefix mylogs # defaults to "logstash"
265
+ ```
266
+
267
+ ### logstash_prefix_separator
268
+
269
+ ```
270
+ logstash_prefix_separator _ # defaults to "-"
271
+ ```
272
+
273
+ ### logstash_dateformat
274
+
275
+ 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.
276
+
277
+ ```
278
+ logstash_dateformat %Y.%m. # defaults to "%Y.%m.%d"
279
+ ```
280
+
281
+ ### pipeline
282
+
283
+ This param is to set a pipeline id of your opensearch to be added into the request, you can configure ingest node.
284
+
285
+ ```
286
+ pipeline pipeline_id
287
+ ```
288
+
289
+ ### time_key_format
290
+
291
+ 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.
292
+
293
+ 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. You can get a further performance improvement by installing the "strptime" gem: `fluent-gem install strptime`.
294
+
295
+ For example to parse ISO8601 times with sub-second precision:
296
+
297
+ ```
298
+ time_key_format %Y-%m-%dT%H:%M:%S.%N%z
299
+ ```
300
+
301
+ ### time_precision
302
+
303
+ 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.
304
+
305
+ 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).
306
+
307
+ ### time_key
308
+
309
+ 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.
310
+
311
+ ```
312
+ {"@timestamp": "2014-04-07T000:00:00-00:00"}
313
+ ```
314
+
315
+ 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.
316
+
317
+ Suppose you have settings
318
+
319
+ ```
320
+ logstash_format true
321
+ time_key vtm
322
+ ```
323
+
324
+ Your input is:
325
+ ```
326
+ {
327
+ "title": "developer",
328
+ "vtm": "2014-12-19T08:01:03Z"
329
+ }
330
+ ```
331
+
332
+ The output will be
333
+ ```
334
+ {
335
+ "title": "developer",
336
+ "@timestamp": "2014-12-19T08:01:03Z",
337
+ "vtm": "2014-12-19T08:01:03Z"
338
+ }
339
+ ```
340
+
341
+ See `time_key_exclude_timestamp` to avoid adding `@timestamp`.
342
+
343
+ ### time_key_exclude_timestamp
344
+
345
+ ```
346
+ time_key_exclude_timestamp false
347
+ ```
348
+
349
+ 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.
350
+
351
+ ### utc_index
352
+
353
+ ```
354
+ utc_index true
355
+ ```
356
+
357
+ 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.
358
+
359
+ ### target_index_key
360
+
361
+ 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.
362
+
363
+ 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.
364
+
365
+ Suppose you have the following settings
366
+
367
+ ```
368
+ target_index_key @target_index
369
+ index_name fallback
370
+ ```
371
+
372
+ If your input is:
373
+ ```
374
+ {
375
+ "title": "developer",
376
+ "@timestamp": "2014-12-19T08:01:03Z",
377
+ "@target_index": "logstash-2014.12.19"
378
+ }
379
+ ```
380
+
381
+ The output would be
382
+
383
+ ```
384
+ {
385
+ "title": "developer",
386
+ "@timestamp": "2014-12-19T08:01:03Z",
387
+ }
388
+ ```
389
+
390
+ and this record will be written to the specified index (`logstash-2014.12.19`) rather than `fallback`.
391
+
392
+ ### target_type_key
393
+
394
+ 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").
395
+
396
+ ### target_index_affinity
397
+
398
+ Enable plugin to dynamically select logstash time based target index in update/upsert operations based on already indexed data rather than current time of indexing.
399
+
400
+ ```
401
+ target_index_affinity true # defaults to false
402
+ ```
403
+
404
+ By default plugin writes data of logstash format index based on current time. For example daily based index after mignight data is written to newly created index. This is normally ok when data is coming from single source and not updated after indexing.
405
+
406
+ But if you have a use case where data is also updated after indexing and `id_key` is used to identify the document uniquely for updating. Logstash format is wanted to be used for easy data managing and retention. Updates are done right after indexing to complete the data (all data not available from single source) and no updates are done anymore later point on time. In this case problem happends at index rotation time where write to 2 indexes with same id_key value may happen.
407
+
408
+ This setting will search existing data by using elastic search's [id query](https://www.elastic.co/guide/en/opensearch/reference/current/query-dsl-ids-query.html) using `id_key` value (with logstash_prefix and logstash_prefix_separator index pattarn e.g. `logstash-*`). The index of found data is used for update/upsert. When no data is found, data is written to current logstash index as normally.
409
+
410
+ This setting requires following other settings:
411
+ ```
412
+ logstash_format true
413
+ id_key myId # Some field on your data to identify the data uniquely
414
+ write_operation upsert # upsert or update
415
+ ```
416
+
417
+ Suppose you have the following situation where you have 2 different match to consume data from 2 different Kafka topics independently but close in time with each other (order not known).
418
+
419
+ ```
420
+ <match data1>
421
+ @type opensearch
422
+ ...
423
+ id_key myId
424
+ write_operation upsert
425
+ logstash_format true
426
+ logstash_dateformat %Y.%m.%d
427
+ logstash_prefix myindexprefix
428
+ target_index_affinity true
429
+ ...
430
+
431
+ <match data2>
432
+ @type opensearch
433
+ ...
434
+ id_key myId
435
+ write_operation upsert
436
+ logstash_format true
437
+ logstash_dateformat %Y.%m.%d
438
+ logstash_prefix myindexprefix
439
+ target_index_affinity true
440
+ ...
441
+ ```
442
+
443
+ If your first (data1) input is:
444
+ ```
445
+ {
446
+ "myId": "myuniqueId1",
447
+ "datafield1": "some value",
448
+ }
449
+ ```
450
+
451
+ and your second (data2) input is:
452
+ ```
453
+ {
454
+ "myId": "myuniqueId1",
455
+ "datafield99": "some important data from other source tightly related to id myuniqueId1 and wanted to be in same document.",
456
+ }
457
+ ```
458
+
459
+ Date today is 10.05.2021 so data is written to index `myindexprefix-2021.05.10` when both data1 and data2 is consumed during today.
460
+ But when we are close to index rotation and data1 is consumed and indexed at `2021-05-10T23:59:55.59707672Z` and data2
461
+ is consumed a bit later at `2021-05-11T00:00:58.222079Z` i.e. logstash index has been rotated and normally data2 would have been written
462
+ to index `myindexprefix-2021.05.11`. But with target_index_affinity setting as value true, data2 is now written to index `myindexprefix-2021.05.10`
463
+ into same document with data1 as wanted and duplicated document is avoided.
464
+
465
+ ### template_name
466
+
467
+ 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.
468
+
469
+ 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).
470
+
471
+ [template_file](#template_file) must also be specified.
472
+
473
+ ### template_file
474
+
475
+ The path to the file containing the template to install.
476
+
477
+ [template_name](#template_name) must also be specified.
478
+
479
+ ### templates
480
+
481
+ Specify index templates in form of hash. Can contain multiple templates.
482
+
483
+ ```
484
+ templates { "template_name_1": "path_to_template_1_file", "template_name_2": "path_to_template_2_file"}
485
+ ```
486
+
487
+ **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`.
488
+
489
+ ### customize_template
490
+
491
+ 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.
492
+
493
+ ```
494
+ customize_template {"string_1": "subs_value_1", "string_2": "subs_value_2"}
495
+ ```
496
+
497
+ If [template_file](#template_file) and [template_name](#template_name) are set, then this parameter will be in effect otherwise ignored.
498
+
499
+ ### index_date_pattern
500
+
501
+ Specify this to override the index date pattern for creating a rollover index. The default is to use "now/d",
502
+ for example: <logstash-default-{now/d}-000001>. Overriding this changes the rollover time period. Setting
503
+ "now/w{xxxx.ww}" would create weekly rollover indexes instead of daily.
504
+
505
+ ```
506
+ index_date_pattern "now/w{xxxx.ww}" # defaults to "now/d"
507
+ ```
508
+
509
+ If empty string(`""`) is specified in `index_date_pattern`, index date pattern is not used.
510
+ OpenSearch plugin just creates <`target_index`-`application_name`-000001> rollover index instead of <`target_index`-`application_name`-`{index_date_pattern}`-000001>.
511
+
512
+ If [customize_template](#customize_template) is set, then this parameter will be in effect otherwise ignored.
513
+
514
+ ### index_prefix
515
+
516
+ This parameter is marked as obsoleted.
517
+
518
+ ### application_name
519
+
520
+ Specify the application name for the rollover index to be created.
521
+ ```
522
+ application_name default # defaults to "default"
523
+ ```
524
+
525
+ ### template_overwrite
526
+
527
+ Always update the template, even if it already exists.
528
+
529
+ ```
530
+ template_overwrite true # defaults to false
531
+ ```
532
+
533
+ One of [template_file](#template_file) or [templates](#templates) must also be specified if this is set.
534
+
535
+ ### max_retry_putting_template
536
+
537
+ You can specify times of retry putting template.
538
+
539
+ This is useful when OpenSearch plugin cannot connect OpenSearch to put template.
540
+ Usually, booting up clustered OpenSearch containers are much slower than launching Fluentd container.
541
+
542
+ ```
543
+ max_retry_putting_template 15 # defaults to 10
544
+ ```
545
+
546
+ ### fail_on_putting_template_retry_exceed
547
+
548
+ Indicates whether to fail when `max_retry_putting_template` is exceeded.
549
+ If you have multiple output plugin, you could use this property to do not fail on fluentd statup.
550
+
551
+ ```
552
+ fail_on_putting_template_retry_exceed false # defaults to true
553
+ ```
554
+
555
+ ### fail_on_detecting_os_version_retry_exceed
556
+
557
+ Indicates whether to fail when `max_retry_get_os_version` is exceeded.
558
+ If you want to use fallback mechanism for obtaining OpenSearch version, you could use this property to do not fail on fluentd statup.
559
+
560
+ ```
561
+ fail_on_detecting_os_version_retry_exceed false
562
+ ```
563
+
564
+ And the following parameters should be working with:
565
+
566
+ ```
567
+ verify_os_version_at_startup true
568
+ max_retry_get_os_version 2 # greater than 0.
569
+ default_opensearch_version 1 # This version is used when occurring fallback.
570
+ ```
571
+
572
+ ### max_retry_get_os_version
573
+
574
+ You can specify times of retry obtaining OpenSearch version.
575
+
576
+ This is useful when OpenSearch plugin cannot connect OpenSearch to obtain OpenSearch version.
577
+ Usually, booting up clustered OpenSearch containers are much slower than launching Fluentd container.
578
+
579
+ ```
580
+ max_retry_get_os_version 17 # defaults to 15
581
+ ```
582
+
583
+ ### request_timeout
584
+
585
+ You can specify HTTP request timeout.
586
+
587
+ This is useful when OpenSearch cannot return response for bulk request within the default of 5 seconds.
588
+
589
+ ```
590
+ request_timeout 15s # defaults to 5s
591
+ ```
592
+
593
+ ### reload_connections
594
+
595
+ You can tune how the opensearch-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 OpenSearch cluster is behind a Reverse Proxy, as Fluentd process may not have direct network access to the OpenSearch nodes.
596
+
597
+ ```
598
+ reload_connections false # defaults to true
599
+ ```
600
+
601
+ ### reload_on_failure
602
+
603
+ Indicates that the opensearch-transport will try to reload the nodes addresses if there is a failure while making the
604
+ request, this can be useful to quickly remove a dead node from the list of addresses.
605
+
606
+ ```
607
+ reload_on_failure true # defaults to false
608
+ ```
609
+
610
+ ### resurrect_after
611
+
612
+ You can set in the opensearch-transport how often dead connections from the opensearch-transport's pool will be resurrected.
613
+
614
+ ```
615
+ resurrect_after 5s # defaults to 60s
616
+ ```
617
+
618
+ ### include_tag_key, tag_key
619
+
620
+ ```
621
+ include_tag_key true # defaults to false
622
+ tag_key tag # defaults to tag
623
+ ```
624
+
625
+ This will add the Fluentd tag in the JSON record. For instance, if you have a config like this:
626
+
627
+ ```
628
+ <match my.logs>
629
+ @type opensearch
630
+ include_tag_key true
631
+ tag_key _key
632
+ </match>
633
+ ```
634
+
635
+ The record inserted into OpenSearch would be
636
+
637
+ ```
638
+ {"_key": "my.logs", "name": "Johnny Doeie"}
639
+ ```
640
+
641
+ ### id_key
642
+
643
+ ```
644
+ id_key request_id # use "request_id" field as a record id in ES
645
+ ```
646
+
647
+ By default, all records inserted into OpenSearch get a random _id. This option allows to use a field in the record as an identifier.
648
+
649
+ This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will trigger the following OpenSearch command
650
+
651
+ ```
652
+ { "index" : { "_index": "logstash-2013.01.01", "_type": "fluentd", "_id": "87d89af7daffad6" } }
653
+ { "name": "Johnny", "request_id": "87d89af7daffad6" }
654
+ ```
655
+
656
+ Fluentd re-emits events that failed to be indexed/ingested in OpenSearch with a new and unique `_id` value, this means that congested OpenSearch clusters that reject events (due to command queue overflow, for example) will cause Fluentd to re-emit the event with a new `_id`, however OpenSearch 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 OpenSearch from creating duplicate events.
657
+
658
+ ```
659
+ id_key _hash
660
+ ```
661
+
662
+ Example configuration for [fluent-plugin-genhashvalue](https://github.com/mtakemi/fluent-plugin-genhashvalue) (review the documentation of the plugin for more details)
663
+ ```
664
+ <filter logs.**>
665
+ @type genhashvalue
666
+ keys session_id,request_id
667
+ hash_type md5 # md5/sha1/sha256/sha512
668
+ base64_enc true
669
+ base91_enc false
670
+ set_key _hash
671
+ separator _
672
+ inc_time_as_key true
673
+ inc_tag_as_key true
674
+ </filter>
675
+ ```
676
+
677
+ :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
678
+
679
+ #### Using nested key
680
+
681
+ Nested key specifying syntax is also supported.
682
+
683
+ With the following configuration
684
+
685
+ ```aconf
686
+ id_key $.nested.request_id
687
+ ```
688
+
689
+ and the following nested record
690
+
691
+ ```json
692
+ {"nested":{"name": "Johnny", "request_id": "87d89af7daffad6"}}
693
+ ```
694
+
695
+ will trigger the following OpenSearch command
696
+
697
+ ```
698
+ {"index":{"_index":"fluentd","_type":"fluentd","_id":"87d89af7daffad6"}}
699
+ {"nested":{"name":"Johnny","request_id":"87d89af7daffad6"}}
700
+ ```
701
+
702
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
703
+
704
+ ### parent_key
705
+
706
+ ```
707
+ parent_key a_parent # use "a_parent" field value to set _parent in opensearch command
708
+ ```
709
+
710
+ If your input is
711
+ ```
712
+ { "name": "Johnny", "a_parent": "my_parent" }
713
+ ```
714
+
715
+ OpenSearch command would be
716
+
717
+ ```
718
+ { "index" : { "_index": "****", "_type": "****", "_id": "****", "_parent": "my_parent" } }
719
+ { "name": "Johnny", "a_parent": "my_parent" }
720
+ ```
721
+
722
+ if `parent_key` is not configed or the `parent_key` is absent in input record, nothing will happen.
723
+
724
+ #### Using nested key
725
+
726
+ Nested key specifying syntax is also supported.
727
+
728
+ With the following configuration
729
+
730
+ ```aconf
731
+ parent_key $.nested.a_parent
732
+ ```
733
+
734
+ and the following nested record
735
+
736
+ ```json
737
+ {"nested":{ "name": "Johnny", "a_parent": "my_parent" }}
738
+ ```
739
+
740
+ will trigger the following OpenSearch command
741
+
742
+ ```
743
+ {"index":{"_index":"fluentd","_type":"fluentd","_parent":"my_parent"}}
744
+ {"nested":{"name":"Johnny","a_parent":"my_parent"}}
745
+ ```
746
+
747
+ :warning: Note that [Hash flattening](#hash-flattening) may be conflict nested record feature.
748
+
749
+ ### routing_key
750
+
751
+ Similar to `parent_key` config, will add `_routing` into opensearch command if `routing_key` is set and the field does exist in input event.
752
+
753
+ ### remove_keys
754
+
755
+ ```
756
+ parent_key a_parent
757
+ routing_key a_routing
758
+ remove_keys a_parent, a_routing # a_parent and a_routing fields won't be sent to opensearch
759
+ ```
760
+
761
+ ### remove_keys_on_update
762
+
763
+ Remove keys on update will not update the configured keys in opensearch when a record is being updated.
764
+ This setting only has any effect if the write operation is update or upsert.
765
+
766
+ If the write setting is upsert then these keys are only removed if the record is being
767
+ updated, if the record does not exist (by id) then all of the keys are indexed.
768
+
769
+ ```
770
+ remove_keys_on_update foo,bar
771
+ ```
772
+
773
+ ### remove_keys_on_update_key
774
+
775
+ 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.
776
+ The configured key is removed before indexing in opensearch. If both `remove_keys_on_update` and `remove_keys_on_update_key` is
777
+ 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
778
+ `remove_keys_on_update` is used as a fallback.
779
+
780
+ ```
781
+ remove_keys_on_update_key keys_to_skip
782
+ ```
783
+
784
+ ### retry_tag
785
+
786
+ This setting allows custom routing of messages in response to bulk request failures. The default behavior is to emit
787
+ failed records using the same tag that was provided. When set to a value other then `nil`, failed messages are emitted
788
+ with the specified tag:
789
+
790
+ ```
791
+ retry_tag 'retry_es'
792
+ ```
793
+ **NOTE:** `retry_tag` is optional. If you would rather use labels to reroute retries, add a label (e.g '@label @SOMELABEL') to your fluent
794
+ opensearch plugin configuration. Retry records are, by default, submitted for retry to the ROOT label, which means
795
+ records will flow through your fluentd pipeline from the beginning. This may nor may not be a problem if the pipeline
796
+ is idempotent - that is - you can process a record again with no changes. Use tagging or labeling to ensure your retry
797
+ records are not processed again by your fluentd processing pipeline.
798
+
799
+ ### write_operation
800
+
801
+ The write_operation can be any of:
802
+
803
+ | Operation | Description |
804
+ | ------------- | ----------- |
805
+ | index (default) | new data is added while existing data (based on its id) is replaced (reindexed).|
806
+ | create | adds new data - if the data already exists (based on its id), the op is skipped.|
807
+ | update | updates existing data (based on its id). If no data is found, the op is skipped.|
808
+ | upsert | known as merge or insert if the data does not exist, updates if the data exists (based on its id).|
809
+
810
+ **Please note, id is required in create, update, and upsert scenario. Without id, the message will be dropped.**
811
+
812
+ ### time_parse_error_tag
813
+
814
+ With `logstash_format true`, opensearch 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.
815
+
816
+ Default value is `opensearch_plugin.output.time.error`. Note that this default values is quite different from Elasticsearch plugin.
817
+
818
+ ### reconnect_on_error
819
+ Indicates that the plugin should reset connection on any error (reconnect on next send).
820
+ By default it will reconnect only on "host unreachable exceptions".
821
+ We recommended to set this true in the presence of opensearch shield.
822
+ ```
823
+ reconnect_on_error true # defaults to false
824
+ ```
825
+
826
+ ### with_transporter_log
827
+
828
+ This is debugging purpose option to enable to obtain transporter layer log.
829
+ Default value is `false` for backward compatibility.
830
+
831
+ We recommend to set this true if you start to debug this plugin.
832
+
833
+ ```
834
+ with_transporter_log true
835
+ ```
836
+
837
+ ### content_type
838
+
839
+ With `content_type application/x-ndjson`, opensearch plugin adds `application/x-ndjson` as `Content-Type` in payload.
840
+
841
+ Default value is `application/json` which is default Content-Type of OpenSearch requests.
842
+ If you will not use template, it recommends to set `content_type application/x-ndjson`.
843
+
844
+ ```
845
+ content_type application/x-ndjson
846
+ ```
847
+
848
+ ### include_index_in_url
849
+
850
+ With this option set to true, Fluentd manifests the index name in the request URL (rather than in the request body).
851
+ You can use this option to enforce an URL-based access control.
852
+
853
+ ```
854
+ include_index_in_url true
855
+ ```
856
+
857
+ ### http_backend
858
+
859
+ With `http_backend typhoeus`, opensearch plugin uses typhoeus faraday http backend.
860
+ Typhoeus can handle HTTP keepalive.
861
+
862
+ Default value is `excon` which is default http_backend of opensearch plugin.
863
+
864
+ ```
865
+ http_backend typhoeus
866
+ ```
867
+
868
+ ### http_backend_excon_nonblock
869
+
870
+ With `http_backend_excon_nonblock false`, opensearch plugin use excon with nonblock=false.
871
+ If you use opensearch plugin with jRuby for https, you may need to consider to set `false` to avoid follwoing problems.
872
+ - https://github.com/geemus/excon/issues/106
873
+ - https://github.com/jruby/jruby-ossl/issues/19
874
+
875
+ 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
876
+
877
+ Default value is `true`.
878
+
879
+ ```
880
+ http_backend_excon_nonblock false
881
+ ```
882
+
883
+ ### compression_level
884
+ You can add gzip compression of output data. In this case `default_compression`, `best_compression` or `best speed` option should be chosen.
885
+ By default there is no compression, default value for this option is `no_compression`
886
+ ```
887
+ compression_level best_compression
888
+ ```
889
+
890
+ ### prefer_oj_serializer
891
+
892
+ With default behavior, OpenSearch client uses `Yajl` as JSON encoder/decoder.
893
+ `Oj` is the alternative high performance JSON encoder/decoder.
894
+ When this parameter sets as `true`, OpenSearch client uses `Oj` as JSON encoder/decoder.
895
+
896
+ Default value is `false`.
897
+
898
+ ```
899
+ prefer_oj_serializer true
900
+ ```
901
+
902
+ ### Client/host certificate options
903
+
904
+ Need to verify OpenSearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
905
+ ```
906
+ ca_file /path/to/your/ca/cert
907
+ ```
908
+
909
+ Does your OpenSearch cluster want to verify client connections? You can specify the following parameters to use your client certificate, key, and key password for your connection.
910
+ ```
911
+ client_cert /path/to/your/client/cert
912
+ client_key /path/to/your/private/key
913
+ client_key_pass password
914
+ ```
915
+
916
+ If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
917
+ ```
918
+ ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
919
+ ```
920
+
921
+ :warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
922
+
923
+ In OpenSearch plugin v4.0.2 with Ruby 2.5 or later combination, OpenSearch plugin also support `ssl_max_version` and `ssl_min_version`.
924
+
925
+ ```
926
+ ssl_max_version TLSv1_3
927
+ ssl_min_version TLSv1_2
928
+ ```
929
+
930
+ OpenSearch 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.
931
+
932
+ If they are *not* specified in the OpenSearch plugin configuration, `ssl_max_version` and `ssl_min_version` is set up with:
933
+
934
+ In OpenSearch plugin v1.0.0 or later with Ruby 2.5 or later environment, `ssl_max_version` should be `TLSv1_3` and `ssl_min_version` should be `TLSv1_2`.
935
+
936
+ ### Proxy Support
937
+
938
+ Starting with version 0.8.0, this gem uses excon, which supports proxy with environment variables - https://github.com/excon/excon#proxy-support
939
+
940
+ ### Buffer options
941
+
942
+ `fluentd-plugin-opensearch` extends [Fluentd's builtin Output plugin](https://docs.fluentd.org/output#overview) and use `compat_parameters` plugin helper. It adds the following options:
943
+
944
+ ```
945
+ buffer_type memory
946
+ flush_interval 60s
947
+ retry_limit 17
948
+ retry_wait 1.0
949
+ num_threads 1
950
+ ```
951
+
952
+ The value for option `buffer_chunk_limit` should not exceed value `http.max_content_length` in your OpenSearch setup (by default it is 100mb).
953
+
954
+ **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)
955
+
956
+ **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.
957
+
958
+ ### Hash flattening
959
+
960
+ OpenSearch 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:
961
+
962
+ {"people" => 100}
963
+ {"people" => {"some" => "thing"}}
964
+
965
+ The second log line will be rejected by the OpenSearch parser because objects and concrete values can't live in the same field. To combat this, you can enable hash flattening.
966
+
967
+ ```
968
+ flatten_hashes true
969
+ flatten_hashes_separator _
970
+ ```
971
+
972
+ This will produce opensearch output that looks like this:
973
+ {"people_some" => "thing"}
974
+
975
+ Note that the flattener does not deal with arrays at this time.
976
+
977
+ ### Generate Hash ID
978
+
979
+ By default, the fluentd opensearch plugin does not emit records with a \_id field, leaving it to OpenSearch to generate a unique \_id as the record is indexed. When an OpenSearch cluster is congested and begins to take longer to respond than the configured request_timeout, the fluentd opensearch plugin will re-send the same bulk request. Since OpenSearch 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.
980
+
981
+ The bundled opensearch\_genid filter can generate a unique \_hash key for each record, this key may be passed to the id_key parameter in the opensearch plugin to communicate to OpenSearch the uniqueness of the requests so that duplicates will be rejected or simply replace the existing records.
982
+ Here is a sample config:
983
+
984
+ ```
985
+ <filter **>
986
+ @type opensearch_genid
987
+ hash_id_key _hash # storing generated hash id key (default is _hash)
988
+ </filter>
989
+ <match **>
990
+ @type opensearch
991
+ id_key _hash # specify same key name which is specified in hash_id_key
992
+ remove_keys _hash # OpenSearch doesn't like keys that start with _
993
+ # other settings are omitted.
994
+ </match>
995
+ ```
996
+
997
+ ### Sniffer Class Name
998
+
999
+ The default Sniffer used by the `OpenSearch::Transport` class works well when Fluentd has a direct connection
1000
+ to all of the OpenSearch servers and can make effective use of the `_nodes` API. This doesn't work well
1001
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
1002
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
1003
+ there is a new `Fluent::Plugin::OpenSearchSimpleSniffer` class which reuses the hosts given in the configuration, which
1004
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
1005
+ connections to `logging-os` to reload every 100 operations:
1006
+
1007
+ ```
1008
+ host logging-os
1009
+ port 9200
1010
+ reload_connections true
1011
+ sniffer_class_name Fluent::Plugin::OpenSearchSimpleSniffer
1012
+ reload_after 100
1013
+ ```
1014
+
1015
+ #### Tips
1016
+
1017
+ The included sniffer class is not required `out_opensearch`.
1018
+ You should tell Fluentd where the sniffer class exists.
1019
+
1020
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1021
+
1022
+ ```
1023
+ sniffer=$(td-agent-gem contents fluent-plugin-opensearch|grep opensearch_simple_sniffer.rb)
1024
+ TD_AGENT_OPTIONS="--use-v1-config -r $sniffer"
1025
+ ```
1026
+
1027
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1028
+
1029
+ ```
1030
+ sniffer=$(td-agent-gem contents fluent-plugin-opensearch|grep opensearch_simple_sniffer.rb)
1031
+ $ fluentd -r $sniffer [AND YOUR OTHER OPTIONS]
1032
+ ```
1033
+
1034
+ ### Selector Class Name
1035
+
1036
+ The default selector used by the `OpenSearch::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.
1037
+ The parameter `selector_class_name` gives you the ability to provide your own Selector class to implement whatever selection nodes logic you require.
1038
+
1039
+ The below configuration is using plugin built-in `ElasticseatchFallbackSelector`:
1040
+
1041
+ ```
1042
+ hosts exhausted-host:9201,normal-host:9200
1043
+ selector_class_name "Fluent::Plugin::ElasticseatchFallbackSelector"
1044
+ ```
1045
+
1046
+ #### Tips
1047
+
1048
+ The included selector class is required in `out_opensearch` by default.
1049
+ But, your custom selector class is not required in `out_opensearch`.
1050
+ You should tell Fluentd where the selector class exists.
1051
+
1052
+ If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
1053
+
1054
+ ```
1055
+ selector=/path/to/your_awesome_selector.rb
1056
+ TD_AGENT_OPTIONS="--use-v1-config -r $selector"
1057
+ ```
1058
+
1059
+ If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
1060
+
1061
+ ```
1062
+ selector=/path/to/your_awesome_selector.rb
1063
+ $ fluentd -r $selector [AND YOUR OTHER OPTIONS]
1064
+ ```
1065
+
1066
+ ### Reload After
1067
+
1068
+ When `reload_connections true`, this is the integer number of operations after which the plugin will
1069
+ reload the connections. The default value is 10000.
1070
+
1071
+ ### Validate Client Version
1072
+
1073
+ When you use mismatched OpenSearch server and client libraries, fluent-plugin-opensearch cannot send data into OpenSearch. The default value is `false`.
1074
+
1075
+ ```
1076
+ validate_client_version true
1077
+ ```
1078
+
1079
+ ### Unrecoverable Error Types
1080
+
1081
+ Default `unrecoverable_error_types` parameter is set up strictly.
1082
+ Because `rejected_execution_exception` is caused by exceeding OpenSearch's thread pool capacity.
1083
+ Advanced users can increase its capacity, but normal users should follow default behavior.
1084
+
1085
+ If you want to increase it and forcibly retrying bulk request, please consider to change `unrecoverable_error_types` parameter from default value.
1086
+
1087
+ Change default value of `thread_pool.bulk.queue_size` in opensearch.yml:
1088
+ e.g.)
1089
+
1090
+ ```yaml
1091
+ thread_pool.bulk.queue_size: 1000
1092
+ ```
1093
+
1094
+ Then, remove `rejected_execution_exception` from `unrecoverable_error_types` parameter:
1095
+
1096
+ ```
1097
+ unrecoverable_error_types ["out_of_memory_error"]
1098
+ ```
1099
+
1100
+ ### verify_os_version_at_startup
1101
+
1102
+ Because OpenSearch plugin will ought to change behavior each of OpenSearch major versions.
1103
+
1104
+ For example, OpenSearch 1 requests to handle only `_doc` type_name in index.
1105
+
1106
+ If you want to disable to verify OpenSearch version at start up, set it as `false`.
1107
+
1108
+ When using the following configuration, OpenSearch plugin intends to communicate into OpenSearch 1.
1109
+
1110
+ ```
1111
+ verify_os_version_at_startup false
1112
+ default_opensearch_version 1
1113
+ ```
1114
+
1115
+ The default value is `true`.
1116
+
1117
+ ### default_opensearch_version
1118
+
1119
+ This parameter changes that OpenSearch plugin assumes the default OpenSearch version. The default value is `1`.
1120
+
1121
+ ### custom_headers
1122
+
1123
+ This parameter adds additional headers to request. The default value is `{}`.
1124
+
1125
+ ```
1126
+ custom_headers {"token":"secret"}
1127
+ ```
1128
+
1129
+ ### Not seeing a config you need?
1130
+
1131
+ 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.
1132
+
1133
+ Alternatively, consider using [fluent-plugin-forest](https://github.com/tagomoris/fluent-plugin-forest). For example, to configure multiple tags to be sent to different OpenSearch indices:
1134
+
1135
+ ```
1136
+ <match my.logs.*>
1137
+ @type forest
1138
+ subtype opensearch
1139
+ remove_prefix my.logs
1140
+ <template>
1141
+ logstash_prefix ${tag}
1142
+ # ...
1143
+ </template>
1144
+ </match>
1145
+ ```
1146
+
1147
+ And yet another option is described in Dynamic Configuration section.
1148
+
1149
+ **Note**: If you use or evaluate Fluentd v0.14, you can use builtin placeholders. In more detail, please refer to [Placeholders](#placeholders) section.
1150
+
1151
+ ### Placeholders
1152
+
1153
+ v0.14 placeholders can handle `${tag}` for tag, `%Y%m%d` like strftime format, and custom record keys like as `record["mykey"]`.
1154
+
1155
+ Note that custom chunk key is different notations for `record_reformer` and `record_modifier`.
1156
+ 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.
1157
+
1158
+ They are used as below:
1159
+
1160
+ #### tag
1161
+
1162
+ ```aconf
1163
+ <match my.logs>
1164
+ @type opensearch
1165
+ index_name elastic.${tag} #=> replaced with each event's tag. e.g.) elastic.test.tag
1166
+ <buffer tag>
1167
+ @type memory
1168
+ </buffer>
1169
+ # <snip>
1170
+ </match>
1171
+ ```
1172
+
1173
+ #### time
1174
+
1175
+ ```aconf
1176
+ <match my.logs>
1177
+ @type opensearch
1178
+ index_name elastic.%Y%m%d #=> e.g.) elastic.20170811
1179
+ <buffer tag, time>
1180
+ @type memory
1181
+ timekey 3600
1182
+ </buffer>
1183
+ # <snip>
1184
+ </match>
1185
+ ```
1186
+
1187
+ #### custom key
1188
+
1189
+ ```log
1190
+ records = {key1: "value1", key2: "value2"}
1191
+ ```
1192
+
1193
+ ```aconf
1194
+ <match my.logs>
1195
+ @type opensearch
1196
+ index_name elastic.${key1}.${key2} # => e.g.) elastic.value1.value2
1197
+ <buffer tag, key1, key2>
1198
+ @type memory
1199
+ </buffer>
1200
+ # <snip>
1201
+ </match>
1202
+ ```
1203
+
1204
+ ## Multi workers
1205
+
1206
+ 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:
1207
+
1208
+ ```
1209
+ <system>
1210
+ workers N # where N is a natural number (N >= 1).
1211
+ </system>
1212
+ ```
1213
+
1214
+ ## log_os_400_reason
1215
+
1216
+ By default, the error logger won't record the reason for a 400 error from the OpenSearch 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.
1217
+
1218
+ Default value is `false`.
1219
+
1220
+ ## suppress_doc_wrap
1221
+
1222
+ 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.
1223
+
1224
+ Default value is `false`.
1225
+
1226
+ ## ignore_exceptions
1227
+
1228
+ 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
1229
+
1230
+ ```
1231
+ ignore_exceptions ["OpenSearch::Transport::Transport::ServerError"]
1232
+ ```
1233
+
1234
+ will match all subclasses of `ServerError` - `OpenSearch::Transport::Transport::Errors::BadRequest`, `OpenSearch::Transport::Transport::Errors::ServiceUnavailable`, etc.
1235
+
1236
+ Default value is empty list (no exception is ignored).
1237
+
1238
+ ## exception_backup
1239
+
1240
+ Indicates whether to backup chunk when ignore exception occurs.
1241
+
1242
+ Default value is `true`.
1243
+
1244
+ ## bulk_message_request_threshold
1245
+
1246
+ Configure `bulk_message` request splitting threshold size.
1247
+
1248
+ Default value is `-1`(unlimited).
1249
+
1250
+ If you specify this size as negative number, `bulk_message` request splitting feature will be disabled.
1251
+
1252
+ ## truncate_caches_interval
1253
+
1254
+ Specify truncating caches interval.
1255
+
1256
+ If it is set, timer for clearing `alias_indexes` and `template_names` caches will be launched and executed.
1257
+
1258
+ Default value is `nil`.
1259
+
1260
+ ## use_legacy_template
1261
+
1262
+ Use legacy template or not.
1263
+
1264
+ Composable template documentation is [Put Index Template API | OpenSearch Reference](https://opensearch.org/docs/latest/opensearch/index-templates/). OpenSearch still supports legacy template but we recommend to migrate to use Composable template.
1265
+
1266
+ Please confirm that whether the using OpenSearch cluster(s) support the composable template feature or not when turn on the brand new feature with this parameter.
1267
+
1268
+ ## <metadata\> section
1269
+
1270
+ Users can specify whether including `chunk_id` information into records or not:
1271
+
1272
+ ```aconf
1273
+ <match your.awesome.routing.tag>
1274
+ @type opensearch
1275
+ # Other configurations.
1276
+ <metadata>
1277
+ include_chunk_id true
1278
+ # chunk_id_key chunk_id # Default value is "chunk_id".
1279
+ </metadata>
1280
+ </match>
1281
+ ```
1282
+
1283
+ ### include_chunk_id
1284
+
1285
+ Whether including `chunk_id` for not. Default value is `false`.
1286
+
1287
+ ```aconf
1288
+ <match your.awesome.routing.tag>
1289
+ @type opensearch
1290
+ # Other configurations.
1291
+ <metadata>
1292
+ include_chunk_id true
1293
+ </metadata>
1294
+ </match>
1295
+ ```
1296
+
1297
+
1298
+ ### chunk_id_key
1299
+
1300
+ Specify `chunk_id_key` to store `chunk_id` information into records. Default value is `chunk_id`.
1301
+
1302
+ ```aconf
1303
+ <match your.awesome.routing.tag>
1304
+ @type opensearch
1305
+ # Other configurations.
1306
+ <metadata>
1307
+ include_chunk_id
1308
+ chunk_id_key chunk_hex
1309
+ </metadata>
1310
+ </match>
1311
+ ```
1312
+
1313
+ ## Configuration - OpenSearch Input
1314
+
1315
+ See [OpenSearch Input plugin document](README.OpenSearchInput.md)
1316
+
1317
+ ## Configuration - OpenSearch Filter GenID
1318
+
1319
+ See [OpenSearch Filter GenID document](README.OpenSearchGenID.md)
1320
+
1321
+ ## Configuration - OpenSearch Output Data Stream
1322
+
1323
+ Since Elasticsearch 7.9 that is predessor software of OpenSearch, Data Streams was introduced.
1324
+
1325
+ **NOTE:** This feature is slated to official support. Currently, this fetaure is beta.
1326
+
1327
+ You can enable this feature by specifying `@type opensearch_data_stream`.
1328
+
1329
+ ```
1330
+ @type opensearch_data_stream
1331
+ data_stream_name test
1332
+ ```
1333
+
1334
+ The matching index template will be also created automatically.
1335
+
1336
+ ### data_stream_name
1337
+
1338
+ You can specify OpenSearch data stream name by this parameter.
1339
+ This parameter is mandatory for `opensearch_data_stream`.
1340
+
1341
+ ### data_stream_template_name
1342
+
1343
+ You can specify an existing matching index template for the data stream. If not present, it creates a new matching index template.
1344
+
1345
+ Default value is `data_stream_name`.
1346
+
1347
+ ## Configuration - AWS OpenSearch Service
1348
+
1349
+ This settings are effective for AWS OpenSearch Service that is successor of AWS Elasticsearch service.
1350
+
1351
+
1352
+ ### \<endpoint\> section
1353
+
1354
+ AWS OpenSearch Service related settings are placed in `<endpoint>` directive.
1355
+ This is because `elasticsearch-ruby` does not work with OpenSearch and `opensearch-ruby` does not work with Elasticsearch.
1356
+
1357
+ Configuration example is below:
1358
+
1359
+ ```aconf
1360
+ <match es.**>
1361
+ type opensearch
1362
+ logstash_format true
1363
+ include_tag_key true
1364
+ flush_interval 1s
1365
+
1366
+ <endpoint>
1367
+ url https://CLUSTER_ENDPOINT_URL
1368
+ region YOUR_AWS_REGION
1369
+ # access_key_id "secret"
1370
+ # secret_access_key "foo_secret"
1371
+ </endpoint>
1372
+ </match>
1373
+ ```
1374
+
1375
+ #### region
1376
+
1377
+ Specify AWS region.
1378
+
1379
+ ```aconf
1380
+ <endpoint>
1381
+ region us-east-2 # e.g.) AWS Ohio region
1382
+ # other stuffs.
1383
+ </endpoint>
1384
+ ```
1385
+
1386
+ #### url
1387
+
1388
+ Specify AWS OpenSearch Service endpoint.
1389
+
1390
+ ```aconf
1391
+ <endpoint>
1392
+ url https://CLUSTER_ENDPOINT_URL
1393
+ # other stuffs.
1394
+ </endpoint>
1395
+ ```
1396
+
1397
+ **NOTE:** This plugin will remove trailing slashes automatically. You don't need to pay attension to the trailing slash characters.
1398
+
1399
+ #### access_key_id
1400
+
1401
+ Specify AWS access key.
1402
+
1403
+ ```aconf
1404
+ <endpoint>
1405
+ access_key_id YOUR_AWS_ACCESS_KEY
1406
+ # other stuffs.
1407
+ </endpoint>
1408
+ ```
1409
+
1410
+ #### secret_access_key
1411
+
1412
+ Specify AWS secret access key.
1413
+
1414
+ ```aconf
1415
+ <endpoint>
1416
+ secret_access_key YOUR_AWS_SECRET_ACCESS_KEY
1417
+ # other stuffs.
1418
+ </endpoint>
1419
+ ```
1420
+
1421
+ ### IAM
1422
+
1423
+ If you don't want to use `access_key_id` and `secret_access_key` on your endpoint configuration, you should use IAM policies instead.
1424
+
1425
+ #### Assign an IAM instance role
1426
+
1427
+ The first step needs to assign an IAM instance role (ROLE) to your EC2 instances. You should change its name appropriately.
1428
+ The attaching role should not contain no policy: We're using the role as the authenticating factor and placing the policy into the OpenSearch cluster.
1429
+
1430
+ Then, you should configure a policy for the OpenSearch cluster policy with substitution s for the capitalized terms:
1431
+
1432
+ ```json
1433
+ {
1434
+ "Version": "2012-10-17",
1435
+ "Statement": [
1436
+ {
1437
+ "Effect": "Allow",
1438
+ "Principal": {
1439
+ "AWS": "arn:aws:iam::ACCOUNT:role/ROLE"
1440
+ },
1441
+ "Action": "es:*",
1442
+ "Resource": "arn:aws:es:AWS_REGION:ACCOUNT:domain/OPENSEARCH_DOMAIN/*"
1443
+ },
1444
+ {
1445
+ "Effect": "Allow",
1446
+ "Principal": {
1447
+ "AWS": "*"
1448
+ },
1449
+ "Action": "es:*",
1450
+ "Resource": "arn:aws:es:AWS_REGION:ACCOUNT:domain/OPENSEARCH_DOMAIN/*",
1451
+ "Condition": {
1452
+ "IpAddress": {
1453
+ "aws:SourceIp": [
1454
+ "1.2.3.4/32",
1455
+ "5.6.7.8/32"
1456
+ ]
1457
+ }
1458
+ }
1459
+ }
1460
+ ]
1461
+ }
1462
+ ```
1463
+
1464
+ The above policy will allow your Fluentd hosts and any traffic coming from the specified IP addresses (you querying OpenSearch Dashboard) to access the various endpoints. While not ideally secure it should allow you to get up and ingesting logs without anything
1465
+
1466
+ #### Use STS assumed role as the authenticating factor
1467
+
1468
+ Additionally, you can use a STS assumed role as the authenticating factor and instruct the plugin to assume this role.
1469
+ This is useful for cross-account access and when assigning a standard role is not possible. In this case, the endpoint configuration looks like:
1470
+
1471
+ ```aconf
1472
+ <endpoint>
1473
+ url https://CLUSTER_ENDPOINT_URL
1474
+ region YOUR_AWS_REGION
1475
+ assume_role_arn arn:aws:sts::ACCOUNT:role/ROLE
1476
+ assume_role_session_name SESSION_ID # Defaults to fluentd if omitted
1477
+ sts_credentials_region YOUR_AWS_STS_REGION # Defaults to region if omitted
1478
+ </endpoint>
1479
+ ```
1480
+
1481
+ The policy attached into your OpenSearch cluster becomes something like:
1482
+
1483
+ ```json
1484
+ {
1485
+ "Version": "2012-10-17",
1486
+ "Statement": [
1487
+ {
1488
+ "Effect": "Allow",
1489
+ "Principal": {
1490
+ "AWS": "arn:aws:sts::ACCOUNT:assumed-role/ROLE/SESSION_ID"
1491
+ },
1492
+ "Action": "es:*",
1493
+ "Resource": "arn:aws:es:AWS_REGION:ACCOUNT:domain/ES_DOMAIN/*"
1494
+ }
1495
+ ]
1496
+ }
1497
+ ```
1498
+
1499
+ #### Ensure the environment to assume roles
1500
+
1501
+ You'll need to ensure that the environment where the Fluentd plugin runs to have the capability to assume this role, by attaching a policy something like this to the instance profile:
1502
+
1503
+ ```json
1504
+ {
1505
+ "Version": "2012-10-17",
1506
+ "Statement": {
1507
+ "Effect": "Allow",
1508
+ "Action": "sts:AssumeRole",
1509
+ "Resource": "arn:aws:iam::ACCOUNT:role/ROLE"
1510
+ }
1511
+ }
1512
+ ```
1513
+
1514
+ ### EKS
1515
+
1516
+ If you want to use IAM roles for service accounts on your Amazon EKS clusters, please refer to the official documentation and specify a Service Account for your fluentd Pod.
1517
+
1518
+ In this case, the endpoint configuration looks like:
1519
+
1520
+ ```aconf
1521
+ <endpoint>
1522
+ url https://CLUSTER_ENDPOINT_URL
1523
+ region eu-west-1
1524
+ assume_role_arn "#{ENV['AWS_ROLE_ARN']}"
1525
+ assume_role_web_identity_token_file "#{ENV['AWS_WEB_IDENTITY_TOKEN_FILE']}"
1526
+ </endpoint>
1527
+ ```
1528
+
1529
+ ## Troubleshooting
1530
+
1531
+ See [Troubleshooting document](README.Troubleshooting.md)
1532
+
1533
+ ## Contact
1534
+
1535
+ If you have a question, [open an Issue](https://github.com/fluent/fluent-plugin-opensearch/issues).
1536
+
1537
+ ## Contributing
1538
+
1539
+ There are usually a few feature requests, tagged [Easy](https://github.com/fluent/fluent-plugin-opensearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AEasy), [Normal](https://github.com/fluent/fluent-plugin-opensearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3ANormal) and [Hard](https://github.com/fluent/fluent-plugin-opensearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AHard). Feel free to work on any one of them.
1540
+
1541
+ Pull Requests are welcomed.
1542
+
1543
+ Becore send a pull request or report an issue, please read [the contribution guideline](CONTRIBUTING.md).
1544
+
1545
+ ## Running tests
1546
+
1547
+ Install dev dependencies:
1548
+
1549
+ ```sh
1550
+ $ gem install bundler
1551
+ $ bundle install
1552
+ $ bundle exec rake test
1553
+ # To just run the test you are working on:
1554
+ $ bundle exec rake test TEST=test/plugin/test_out_opensearch.rb TESTOPTS='--verbose --name=test_bulk_error_retags_with_error_when_configured_and_fullfilled_buffer'
1555
+
1556
+ ```