fluent-plugin-input-opensearch 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.editorconfig +9 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- data/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +9 -0
- data/.github/workflows/coverage.yaml +22 -0
- data/.github/workflows/issue-auto-closer.yml +12 -0
- data/.github/workflows/linux.yml +26 -0
- data/.github/workflows/macos.yml +26 -0
- data/.github/workflows/windows.yml +26 -0
- data/.gitignore +18 -0
- data/CONTRIBUTING.md +24 -0
- data/Gemfile +10 -0
- data/History.md +67 -0
- data/LICENSE.txt +201 -0
- data/README.OpenSearchGenID.md +116 -0
- data/README.OpenSearchInput.md +314 -0
- data/README.Troubleshooting.md +482 -0
- data/README.md +1622 -0
- data/Rakefile +37 -0
- data/fluent-plugin-opensearch.gemspec +39 -0
- data/gemfiles/Gemfile.elasticsearch.v6 +12 -0
- data/lib/fluent/log-ext.rb +64 -0
- data/lib/fluent/plugin/filter_opensearch_genid.rb +103 -0
- data/lib/fluent/plugin/in_opensearch.rb +410 -0
- data/lib/fluent/plugin/oj_serializer.rb +48 -0
- data/lib/fluent/plugin/opensearch_constants.rb +39 -0
- data/lib/fluent/plugin/opensearch_error.rb +31 -0
- data/lib/fluent/plugin/opensearch_error_handler.rb +182 -0
- data/lib/fluent/plugin/opensearch_fallback_selector.rb +36 -0
- data/lib/fluent/plugin/opensearch_index_template.rb +155 -0
- data/lib/fluent/plugin/opensearch_simple_sniffer.rb +36 -0
- data/lib/fluent/plugin/opensearch_tls.rb +96 -0
- data/lib/fluent/plugin/out_opensearch.rb +1158 -0
- data/lib/fluent/plugin/out_opensearch_data_stream.rb +229 -0
- data/test/helper.rb +60 -0
- data/test/plugin/datastream_template.json +4 -0
- data/test/plugin/test_alias_template.json +9 -0
- data/test/plugin/test_filter_opensearch_genid.rb +241 -0
- data/test/plugin/test_in_opensearch.rb +500 -0
- data/test/plugin/test_index_alias_template.json +11 -0
- data/test/plugin/test_index_template.json +25 -0
- data/test/plugin/test_oj_serializer.rb +45 -0
- data/test/plugin/test_opensearch_error_handler.rb +770 -0
- data/test/plugin/test_opensearch_fallback_selector.rb +100 -0
- data/test/plugin/test_opensearch_tls.rb +171 -0
- data/test/plugin/test_out_opensearch.rb +3980 -0
- data/test/plugin/test_out_opensearch_data_stream.rb +746 -0
- data/test/plugin/test_template.json +23 -0
- data/test/test_log-ext.rb +61 -0
- metadata +291 -0
@@ -0,0 +1,314 @@
|
|
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
|
+
+ [infinite_check_connection](#infinite_check_connection)
|
28
|
+
* [Advanced Usage](#advanced-usage)
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
In your Fluentd configuration, use `@type opensearch` and specify `tag your.awesome.tag`. Additional configuration is optional, default values would look like this:
|
33
|
+
|
34
|
+
```
|
35
|
+
<source>
|
36
|
+
@type opensearch
|
37
|
+
host localhost
|
38
|
+
port 9200
|
39
|
+
index_name fluentd
|
40
|
+
type_name fluentd
|
41
|
+
tag my.logs
|
42
|
+
</source>
|
43
|
+
```
|
44
|
+
|
45
|
+
## Configuration
|
46
|
+
|
47
|
+
### host
|
48
|
+
|
49
|
+
```
|
50
|
+
host user-custom-host.domain # default localhost
|
51
|
+
```
|
52
|
+
|
53
|
+
You can specify OpenSearch host by this parameter.
|
54
|
+
|
55
|
+
|
56
|
+
### port
|
57
|
+
|
58
|
+
```
|
59
|
+
port 9201 # defaults to 9200
|
60
|
+
```
|
61
|
+
|
62
|
+
You can specify OpenSearch port by this parameter.
|
63
|
+
|
64
|
+
### hosts
|
65
|
+
|
66
|
+
```
|
67
|
+
hosts host1:port1,host2:port2,host3:port3
|
68
|
+
```
|
69
|
+
|
70
|
+
You can specify multiple OpenSearch hosts with separator ",".
|
71
|
+
|
72
|
+
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.
|
73
|
+
|
74
|
+
If you specify `hosts` option, `host` and `port` options are ignored.
|
75
|
+
|
76
|
+
```
|
77
|
+
host user-custom-host.domain # ignored
|
78
|
+
port 9200 # ignored
|
79
|
+
hosts host1:port1,host2:port2,host3:port3
|
80
|
+
```
|
81
|
+
|
82
|
+
If you specify `hosts` option without port, `port` option is used.
|
83
|
+
|
84
|
+
```
|
85
|
+
port 9200
|
86
|
+
hosts host1:port1,host2:port2,host3 # port3 is 9200
|
87
|
+
```
|
88
|
+
|
89
|
+
**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"
|
90
|
+
|
91
|
+
### user, password, path, scheme, ssl_verify
|
92
|
+
|
93
|
+
```
|
94
|
+
user demo
|
95
|
+
password secret
|
96
|
+
path /elastic_search/
|
97
|
+
scheme https
|
98
|
+
```
|
99
|
+
|
100
|
+
You can specify user and password for HTTP Basic authentication.
|
101
|
+
|
102
|
+
And this plugin will escape required URL encoded characters within `%{}` placeholders.
|
103
|
+
|
104
|
+
```
|
105
|
+
user %{demo+}
|
106
|
+
password %{@secret}
|
107
|
+
```
|
108
|
+
|
109
|
+
Specify `ssl_verify false` to skip ssl verification (defaults to true)
|
110
|
+
|
111
|
+
### parse_timestamp
|
112
|
+
|
113
|
+
```
|
114
|
+
parse_timestamp true # defaults to false
|
115
|
+
```
|
116
|
+
|
117
|
+
Parse a `@timestamp` field and add parsed time to the event.
|
118
|
+
|
119
|
+
### timestamp_key_format
|
120
|
+
|
121
|
+
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.
|
122
|
+
|
123
|
+
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`.
|
124
|
+
|
125
|
+
For example to parse ISO8601 times with sub-second precision:
|
126
|
+
|
127
|
+
```
|
128
|
+
timestamp_key_format %Y-%m-%dT%H:%M:%S.%N%z
|
129
|
+
```
|
130
|
+
|
131
|
+
### timestamp_parse_error_tag
|
132
|
+
|
133
|
+
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.
|
134
|
+
|
135
|
+
Default value is `opensearch_plugin.input.time.error`.
|
136
|
+
|
137
|
+
### http_backend
|
138
|
+
|
139
|
+
With `http_backend typhoeus`, opensearch plugin uses typhoeus faraday http backend.
|
140
|
+
Typhoeus can handle HTTP keepalive.
|
141
|
+
|
142
|
+
Default value is `excon` which is default http_backend of opensearch plugin.
|
143
|
+
|
144
|
+
```
|
145
|
+
http_backend typhoeus
|
146
|
+
```
|
147
|
+
|
148
|
+
|
149
|
+
### request_timeout
|
150
|
+
|
151
|
+
You can specify HTTP request timeout.
|
152
|
+
|
153
|
+
This is useful when OpenSearch cannot return response for bulk request within the default of 5 seconds.
|
154
|
+
|
155
|
+
```
|
156
|
+
request_timeout 15s # defaults to 5s
|
157
|
+
```
|
158
|
+
|
159
|
+
### reload_connections
|
160
|
+
|
161
|
+
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.
|
162
|
+
|
163
|
+
```
|
164
|
+
reload_connections false # defaults to true
|
165
|
+
```
|
166
|
+
|
167
|
+
### reload_on_failure
|
168
|
+
|
169
|
+
Indicates that the opensearch-transport will try to reload the nodes addresses if there is a failure while making the
|
170
|
+
request, this can be useful to quickly remove a dead node from the list of addresses.
|
171
|
+
|
172
|
+
```
|
173
|
+
reload_on_failure true # defaults to false
|
174
|
+
```
|
175
|
+
|
176
|
+
### resurrect_after
|
177
|
+
|
178
|
+
You can set in the opensearch-transport how often dead connections from the opensearch-transport's pool will be resurrected.
|
179
|
+
|
180
|
+
```
|
181
|
+
resurrect_after 5s # defaults to 60s
|
182
|
+
```
|
183
|
+
|
184
|
+
### with_transporter_log
|
185
|
+
|
186
|
+
This is debugging purpose option to enable to obtain transporter layer log.
|
187
|
+
Default value is `false` for backward compatibility.
|
188
|
+
|
189
|
+
We recommend to set this true if you start to debug this plugin.
|
190
|
+
|
191
|
+
```
|
192
|
+
with_transporter_log true
|
193
|
+
```
|
194
|
+
|
195
|
+
### emit_error_label_event
|
196
|
+
|
197
|
+
Default `emit_error_label_event` value is `true`.
|
198
|
+
|
199
|
+
Emitting error label events is default behavior.
|
200
|
+
|
201
|
+
When using the followin configuration, OpenSearch plugin will cut error events on error handler:
|
202
|
+
|
203
|
+
```aconf
|
204
|
+
emit_error_label_event false
|
205
|
+
```
|
206
|
+
|
207
|
+
### Client/host certificate options
|
208
|
+
|
209
|
+
Need to verify OpenSearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
|
210
|
+
```
|
211
|
+
ca_file /path/to/your/ca/cert
|
212
|
+
```
|
213
|
+
|
214
|
+
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.
|
215
|
+
```
|
216
|
+
client_cert /path/to/your/client/cert
|
217
|
+
client_key /path/to/your/private/key
|
218
|
+
client_key_pass password
|
219
|
+
```
|
220
|
+
|
221
|
+
If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
|
222
|
+
```
|
223
|
+
ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
|
224
|
+
```
|
225
|
+
|
226
|
+
:warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
|
227
|
+
|
228
|
+
### Sniffer Class Name
|
229
|
+
|
230
|
+
The default Sniffer used by the `OpenSearch::Transport` class works well when Fluentd has a direct connection
|
231
|
+
to all of the OpenSearch servers and can make effective use of the `_nodes` API. This doesn't work well
|
232
|
+
when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
|
233
|
+
ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
|
234
|
+
there is a new `Fluent::Plugin::OpenSearchSimpleSniffer` class which reuses the hosts given in the configuration, which
|
235
|
+
is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
|
236
|
+
connections to `logging-es` to reload every 100 operations:
|
237
|
+
|
238
|
+
```
|
239
|
+
host logging-es
|
240
|
+
port 9200
|
241
|
+
reload_connections true
|
242
|
+
sniffer_class_name Fluent::Plugin::OpenSearchSimpleSniffer
|
243
|
+
reload_after 100
|
244
|
+
```
|
245
|
+
|
246
|
+
### custom_headers
|
247
|
+
|
248
|
+
This parameter adds additional headers to request. The default value is `{}`.
|
249
|
+
|
250
|
+
```
|
251
|
+
custom_headers {"token":"secret"}
|
252
|
+
```
|
253
|
+
|
254
|
+
### docinfo_fields
|
255
|
+
|
256
|
+
This parameter specifies docinfo record keys. The default values are `['_index', '_type', '_id']`.
|
257
|
+
|
258
|
+
```
|
259
|
+
docinfo_fields ['_index', '_id']
|
260
|
+
```
|
261
|
+
|
262
|
+
### docinfo_target
|
263
|
+
|
264
|
+
This parameter specifies docinfo storing key. The default value is `@metadata`.
|
265
|
+
|
266
|
+
```
|
267
|
+
docinfo_target metadata
|
268
|
+
```
|
269
|
+
|
270
|
+
### docinfo
|
271
|
+
|
272
|
+
This parameter specifies whether docinfo information including or not. The default value is `false`.
|
273
|
+
|
274
|
+
```
|
275
|
+
docinfo false
|
276
|
+
```
|
277
|
+
|
278
|
+
### infinite_check_connection
|
279
|
+
|
280
|
+
The parameter infinite checking on connection availability with Elasticsearch or opensearch hosts, every request_timeout (default 5) seconds. The default value is `true,`. But if value is `false` then checking of connection will be only 3 times
|
281
|
+
|
282
|
+
```
|
283
|
+
infinite_check_connection true
|
284
|
+
```
|
285
|
+
|
286
|
+
|
287
|
+
## Advanced Usage
|
288
|
+
|
289
|
+
OpenSearch Input plugin and OpenSearch output plugin can combine to transfer records into another cluster.
|
290
|
+
|
291
|
+
```aconf
|
292
|
+
<source>
|
293
|
+
@type opensearch
|
294
|
+
host original-cluster.local
|
295
|
+
port 9200
|
296
|
+
tag raw.opensearch
|
297
|
+
index_name logstash-*
|
298
|
+
docinfo true
|
299
|
+
# repeat false
|
300
|
+
# num_slices 2
|
301
|
+
# with_transporter_log true
|
302
|
+
</source>
|
303
|
+
<match raw.opensearch>
|
304
|
+
@type opensearch
|
305
|
+
host transferred-cluster.local
|
306
|
+
port 9200
|
307
|
+
index_name ${$.@metadata._index}
|
308
|
+
type_name ${$.@metadata._type} # This parameter will be deprecated due to Removal of mapping types since ES7.
|
309
|
+
id_key ${$.@metadata._id} # This parameter is needed for prevent duplicated records.
|
310
|
+
<buffer tag, $.@metadata._index, $.@metadata._type, $.@metadata._id>
|
311
|
+
@type memory # should use file buffer for preventing chunk lost
|
312
|
+
</buffer>
|
313
|
+
</match>
|
314
|
+
```
|