test-input-opensearch-1 0.0.3

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 +29 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  6. data/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +9 -0
  7. data/.github/workflows/coverage.yaml +22 -0
  8. data/.github/workflows/issue-auto-closer.yml +12 -0
  9. data/.github/workflows/linux.yml +26 -0
  10. data/.github/workflows/macos.yml +26 -0
  11. data/.github/workflows/windows.yml +26 -0
  12. data/.gitignore +18 -0
  13. data/CONTRIBUTING.md +24 -0
  14. data/Gemfile +10 -0
  15. data/History.md +67 -0
  16. data/LICENSE.txt +201 -0
  17. data/README.OpenSearchGenID.md +116 -0
  18. data/README.OpenSearchInput.md +396 -0
  19. data/README.Troubleshooting.md +482 -0
  20. data/README.md +1622 -0
  21. data/Rakefile +37 -0
  22. data/fluent-plugin-opensearch.gemspec +39 -0
  23. data/gemfiles/Gemfile.elasticsearch.v6 +12 -0
  24. data/lib/fluent/log-ext.rb +64 -0
  25. data/lib/fluent/plugin/filter_opensearch_genid.rb +103 -0
  26. data/lib/fluent/plugin/in_opensearch.rb +441 -0
  27. data/lib/fluent/plugin/oj_serializer.rb +48 -0
  28. data/lib/fluent/plugin/opensearch_constants.rb +39 -0
  29. data/lib/fluent/plugin/opensearch_error.rb +31 -0
  30. data/lib/fluent/plugin/opensearch_error_handler.rb +182 -0
  31. data/lib/fluent/plugin/opensearch_fallback_selector.rb +36 -0
  32. data/lib/fluent/plugin/opensearch_index_template.rb +155 -0
  33. data/lib/fluent/plugin/opensearch_simple_sniffer.rb +36 -0
  34. data/lib/fluent/plugin/opensearch_tls.rb +96 -0
  35. data/lib/fluent/plugin/out_opensearch.rb +1158 -0
  36. data/lib/fluent/plugin/out_opensearch_data_stream.rb +231 -0
  37. data/test/helper.rb +60 -0
  38. data/test/plugin/datastream_template.json +4 -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 +500 -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 +770 -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 +3980 -0
  49. data/test/plugin/test_out_opensearch_data_stream.rb +746 -0
  50. data/test/plugin/test_template.json +23 -0
  51. data/test/test_log-ext.rb +61 -0
  52. metadata +291 -0
@@ -0,0 +1,396 @@
1
+ ## Index
2
+
3
+ * [Installation](#installation)
4
+ * [Usage](#usage)
5
+ * [Configuration](#configuration)
6
+ + [host](#host)
7
+ + [port](#port)
8
+ + [hosts](#hosts)
9
+ + [user, password, path, scheme, ssl_verify](#user-password-path-scheme-ssl_verify)
10
+ + [parse_timestamp](#parse_timestamp)
11
+ + [timestampkey_format](#timestampkey_format)
12
+ + [timestamp_key](#timestamp_key)
13
+ + [timestamp_parse_error_tag](#timestamp_parse_error_tag)
14
+ + [http_backend](#http_backend)
15
+ + [request_timeout](#request_timeout)
16
+ + [reload_connections](#reload_connections)
17
+ + [reload_on_failure](#reload_on_failure)
18
+ + [resurrect_after](#resurrect_after)
19
+ + [with_transporter_log](#with_transporter_log)
20
+ + [emit_error_label_event](#emit-error-label-event)
21
+ + [Client/host certificate options](#clienthost-certificate-options)
22
+ + [sniffer_class_name](#sniffer-class-name)
23
+ + [custom_headers](#custom_headers)
24
+ + [docinfo_fields](#docinfo_fields)
25
+ + [docinfo_target](#docinfo_target)
26
+ + [docinfo](#docinfo)
27
+ + [check_connection](#check_connection)
28
+ + [retry_forever](#retry_forever)
29
+ + [retry_timeout](#retry_timeout)
30
+ + [retry_max_times](#retry_max_times)
31
+ + [retry_type](#retry_type)
32
+ + [retry_wait](#retry_wait)
33
+ + [retry_exponential_backoff_base](#retry_exponential_backoff_base)
34
+ + [retry_max_interval](#retry_max_interval)
35
+ + [retry_randomize](#retry_randomize)
36
+
37
+ * [Advanced Usage](#advanced-usage)
38
+
39
+ ## Usage
40
+
41
+ In your Fluentd configuration, use `@type opensearch` and specify `tag your.awesome.tag`. Additional configuration is optional, default values would look like this:
42
+
43
+ ```
44
+ <source>
45
+ @type opensearch
46
+ host localhost
47
+ port 9200
48
+ index_name fluentd
49
+ type_name fluentd
50
+ tag my.logs
51
+ </source>
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ ### host
57
+
58
+ ```
59
+ host user-custom-host.domain # default localhost
60
+ ```
61
+
62
+ You can specify OpenSearch host by this parameter.
63
+
64
+
65
+ ### port
66
+
67
+ ```
68
+ port 9201 # defaults to 9200
69
+ ```
70
+
71
+ You can specify OpenSearch port by this parameter.
72
+
73
+ ### hosts
74
+
75
+ ```
76
+ hosts host1:port1,host2:port2,host3:port3
77
+ ```
78
+
79
+ You can specify multiple OpenSearch hosts with separator ",".
80
+
81
+ 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.
82
+
83
+ If you specify `hosts` option, `host` and `port` options are ignored.
84
+
85
+ ```
86
+ host user-custom-host.domain # ignored
87
+ port 9200 # ignored
88
+ hosts host1:port1,host2:port2,host3:port3
89
+ ```
90
+
91
+ If you specify `hosts` option without port, `port` option is used.
92
+
93
+ ```
94
+ port 9200
95
+ hosts host1:port1,host2:port2,host3 # port3 is 9200
96
+ ```
97
+
98
+ **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"
99
+
100
+ ### user, password, path, scheme, ssl_verify
101
+
102
+ ```
103
+ user demo
104
+ password secret
105
+ path /elastic_search/
106
+ scheme https
107
+ ```
108
+
109
+ You can specify user and password for HTTP Basic authentication.
110
+
111
+ And this plugin will escape required URL encoded characters within `%{}` placeholders.
112
+
113
+ ```
114
+ user %{demo+}
115
+ password %{@secret}
116
+ ```
117
+
118
+ Specify `ssl_verify false` to skip ssl verification (defaults to true)
119
+
120
+ ### parse_timestamp
121
+
122
+ ```
123
+ parse_timestamp true # defaults to false
124
+ ```
125
+
126
+ Parse a `@timestamp` field and add parsed time to the event.
127
+
128
+ ### timestamp_key_format
129
+
130
+ The format of the time stamp field (`@timestamp` or what you specify in OpenSearch). This parameter only has an effect when [parse_timestamp](#parse_timestamp) 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.
131
+
132
+ 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`.
133
+
134
+ For example to parse ISO8601 times with sub-second precision:
135
+
136
+ ```
137
+ timestamp_key_format %Y-%m-%dT%H:%M:%S.%N%z
138
+ ```
139
+
140
+ ### timestamp_parse_error_tag
141
+
142
+ With `parse_timestamp true`, opensearch input plugin parses timestamp field for consuming event time. If the consumed record has invalid timestamp value, this plugin emits an error event to `@ERROR` label with `timestamp_parse_error_tag` configured tag.
143
+
144
+ Default value is `opensearch_plugin.input.time.error`.
145
+
146
+ ### http_backend
147
+
148
+ With `http_backend typhoeus`, opensearch plugin uses typhoeus faraday http backend.
149
+ Typhoeus can handle HTTP keepalive.
150
+
151
+ Default value is `excon` which is default http_backend of opensearch plugin.
152
+
153
+ ```
154
+ http_backend typhoeus
155
+ ```
156
+
157
+
158
+ ### request_timeout
159
+
160
+ You can specify HTTP request timeout.
161
+
162
+ This is useful when OpenSearch cannot return response for bulk request within the default of 5 seconds.
163
+
164
+ ```
165
+ request_timeout 15s # defaults to 5s
166
+ ```
167
+
168
+ ### reload_connections
169
+
170
+ 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.
171
+
172
+ ```
173
+ reload_connections false # defaults to true
174
+ ```
175
+
176
+ ### reload_on_failure
177
+
178
+ Indicates that the opensearch-transport will try to reload the nodes addresses if there is a failure while making the
179
+ request, this can be useful to quickly remove a dead node from the list of addresses.
180
+
181
+ ```
182
+ reload_on_failure true # defaults to false
183
+ ```
184
+
185
+ ### resurrect_after
186
+
187
+ You can set in the opensearch-transport how often dead connections from the opensearch-transport's pool will be resurrected.
188
+
189
+ ```
190
+ resurrect_after 5s # defaults to 60s
191
+ ```
192
+
193
+ ### with_transporter_log
194
+
195
+ This is debugging purpose option to enable to obtain transporter layer log.
196
+ Default value is `false` for backward compatibility.
197
+
198
+ We recommend to set this true if you start to debug this plugin.
199
+
200
+ ```
201
+ with_transporter_log true
202
+ ```
203
+
204
+ ### emit_error_label_event
205
+
206
+ Default `emit_error_label_event` value is `true`.
207
+
208
+ Emitting error label events is default behavior.
209
+
210
+ When using the followin configuration, OpenSearch plugin will cut error events on error handler:
211
+
212
+ ```aconf
213
+ emit_error_label_event false
214
+ ```
215
+
216
+ ### Client/host certificate options
217
+
218
+ Need to verify OpenSearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
219
+ ```
220
+ ca_file /path/to/your/ca/cert
221
+ ```
222
+
223
+ 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.
224
+ ```
225
+ client_cert /path/to/your/client/cert
226
+ client_key /path/to/your/private/key
227
+ client_key_pass password
228
+ ```
229
+
230
+ If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
231
+ ```
232
+ ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
233
+ ```
234
+
235
+ :warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
236
+
237
+ ### Sniffer Class Name
238
+
239
+ The default Sniffer used by the `OpenSearch::Transport` class works well when Fluentd has a direct connection
240
+ to all of the OpenSearch servers and can make effective use of the `_nodes` API. This doesn't work well
241
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
242
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
243
+ there is a new `Fluent::Plugin::OpenSearchSimpleSniffer` class which reuses the hosts given in the configuration, which
244
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
245
+ connections to `logging-es` to reload every 100 operations:
246
+
247
+ ```
248
+ host logging-es
249
+ port 9200
250
+ reload_connections true
251
+ sniffer_class_name Fluent::Plugin::OpenSearchSimpleSniffer
252
+ reload_after 100
253
+ ```
254
+
255
+ ### custom_headers
256
+
257
+ This parameter adds additional headers to request. The default value is `{}`.
258
+
259
+ ```
260
+ custom_headers {"token":"secret"}
261
+ ```
262
+
263
+ ### docinfo_fields
264
+
265
+ This parameter specifies docinfo record keys. The default values are `['_index', '_type', '_id']`.
266
+
267
+ ```
268
+ docinfo_fields ['_index', '_id']
269
+ ```
270
+
271
+ ### docinfo_target
272
+
273
+ This parameter specifies docinfo storing key. The default value is `@metadata`.
274
+
275
+ ```
276
+ docinfo_target metadata
277
+ ```
278
+
279
+ ### docinfo
280
+
281
+ This parameter specifies whether docinfo information including or not. The default value is `false`.
282
+
283
+ ```
284
+ docinfo false
285
+ ```
286
+
287
+ ### check_connection
288
+
289
+ The parameter for checking on connection availability with Elasticsearch or Opensearch hosts. The default value is `true`.
290
+
291
+ ```
292
+ check_connection true
293
+ ```
294
+ ### retry_forever
295
+
296
+ The parameter If true, plugin will ignore retry_timeout and retry_max_times options and retry forever. The default value is `true`.
297
+
298
+ ```
299
+ retry_forever true
300
+ ```
301
+
302
+ ### retry_timeout
303
+
304
+ The parameter maximum time (seconds) to retry again the failed try, until the plugin discards the retry.
305
+ If the next retry is going to exceed this time limit, the last retry will be made at exactly this time limit..
306
+ The default value is `72h`.
307
+ 72hours == 17 times with exponential backoff (not to change default behavior)
308
+
309
+ ```
310
+ retry_timeout 72 * 60 * 60
311
+ ```
312
+
313
+ ### retry_max_times
314
+
315
+ The parameter maximum number of times to retry the failed try. The default value is `5`
316
+
317
+ ```
318
+ retry_max_times 5
319
+ ```
320
+
321
+ ### retry_type
322
+
323
+ The parameter needs for how long need to wait (time in seconds) to retry again:
324
+ `exponential_backoff`: wait in seconds will become large exponentially per failure,
325
+ `periodic`: plugin will retry periodically with fixed intervals (configured via retry_wait). The default value is `:exponential_backoff`
326
+ Periodic -> fixed :retry_wait
327
+ Exponential backoff: k is number of retry times
328
+ c: constant factor, @retry_wait
329
+ b: base factor, @retry_exponential_backoff_base
330
+ k: times
331
+ total retry time: c + c * b^1 + (...) + c*b^k = c*b^(k+1) - 1
332
+
333
+ ```
334
+ retry_type exponential_backoff
335
+ ```
336
+
337
+ ### retry_wait
338
+
339
+ The parameter needs for wait in seconds before the next retry to again or constant factor of exponential backoff. The default value is `5`
340
+
341
+ ```
342
+ retry_wait 5
343
+ ```
344
+
345
+ ### retry_exponential_backoff_base
346
+
347
+ The parameter The base number of exponential backoff for retries. The default value is `2`
348
+
349
+ ```
350
+ retry_exponential_backoff_base 2
351
+ ```
352
+
353
+ ### retry_max_interval
354
+
355
+ The parameter maximum interval (seconds) for exponential backoff between retries while failing. The default value is `nil`
356
+
357
+ ```
358
+ retry_max_interval nil
359
+ ```
360
+
361
+ ### retry_randomize
362
+
363
+ The parameter If true, the plugin will retry after randomized interval not to do burst retries. The default value is `false`
364
+
365
+ ```
366
+ retry_randomize false
367
+ ```
368
+
369
+ ## Advanced Usage
370
+
371
+ OpenSearch Input plugin and OpenSearch output plugin can combine to transfer records into another cluster.
372
+
373
+ ```aconf
374
+ <source>
375
+ @type opensearch
376
+ host original-cluster.local
377
+ port 9200
378
+ tag raw.opensearch
379
+ index_name logstash-*
380
+ docinfo true
381
+ # repeat false
382
+ # num_slices 2
383
+ # with_transporter_log true
384
+ </source>
385
+ <match raw.opensearch>
386
+ @type opensearch
387
+ host transferred-cluster.local
388
+ port 9200
389
+ index_name ${$.@metadata._index}
390
+ type_name ${$.@metadata._type} # This parameter will be deprecated due to Removal of mapping types since ES7.
391
+ id_key ${$.@metadata._id} # This parameter is needed for prevent duplicated records.
392
+ <buffer tag, $.@metadata._index, $.@metadata._type, $.@metadata._id>
393
+ @type memory # should use file buffer for preventing chunk lost
394
+ </buffer>
395
+ </match>
396
+ ```