fluent-plugin-elasticsearch 1.9.4 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  4. data/.github/workflows/issue-auto-closer.yml +12 -0
  5. data/.github/workflows/linux.yml +26 -0
  6. data/.github/workflows/macos.yml +26 -0
  7. data/.github/workflows/windows.yml +26 -0
  8. data/.travis.yml +33 -6
  9. data/CONTRIBUTING.md +24 -0
  10. data/Gemfile +4 -1
  11. data/History.md +445 -1
  12. data/ISSUE_TEMPLATE.md +19 -0
  13. data/README.ElasticsearchGenID.md +116 -0
  14. data/README.ElasticsearchInput.md +293 -0
  15. data/README.Troubleshooting.md +692 -0
  16. data/README.md +1013 -38
  17. data/appveyor.yml +20 -0
  18. data/fluent-plugin-elasticsearch.gemspec +15 -9
  19. data/{Gemfile.v0.12 → gemfiles/Gemfile.elasticsearch.v6} +6 -5
  20. data/lib/fluent/log-ext.rb +38 -0
  21. data/lib/fluent/plugin/default-ilm-policy.json +14 -0
  22. data/lib/fluent/plugin/elasticsearch_constants.rb +13 -0
  23. data/lib/fluent/plugin/elasticsearch_error.rb +5 -0
  24. data/lib/fluent/plugin/elasticsearch_error_handler.rb +129 -0
  25. data/lib/fluent/plugin/elasticsearch_fallback_selector.rb +9 -0
  26. data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +67 -0
  27. data/lib/fluent/plugin/elasticsearch_index_template.rb +186 -12
  28. data/lib/fluent/plugin/elasticsearch_simple_sniffer.rb +10 -0
  29. data/lib/fluent/plugin/elasticsearch_tls.rb +70 -0
  30. data/lib/fluent/plugin/filter_elasticsearch_genid.rb +77 -0
  31. data/lib/fluent/plugin/in_elasticsearch.rb +325 -0
  32. data/lib/fluent/plugin/oj_serializer.rb +22 -0
  33. data/lib/fluent/plugin/out_elasticsearch.rb +1008 -267
  34. data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +218 -0
  35. data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +232 -214
  36. data/test/plugin/test_alias_template.json +9 -0
  37. data/test/plugin/test_elasticsearch_error_handler.rb +646 -0
  38. data/test/plugin/test_elasticsearch_fallback_selector.rb +74 -0
  39. data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +66 -0
  40. data/test/plugin/test_elasticsearch_tls.rb +145 -0
  41. data/test/plugin/test_filter_elasticsearch_genid.rb +215 -0
  42. data/test/plugin/test_in_elasticsearch.rb +459 -0
  43. data/test/plugin/test_index_alias_template.json +11 -0
  44. data/test/plugin/test_index_template.json +25 -0
  45. data/test/plugin/test_oj_serializer.rb +19 -0
  46. data/test/plugin/test_out_elasticsearch.rb +5029 -387
  47. data/test/plugin/test_out_elasticsearch_data_stream.rb +337 -0
  48. data/test/plugin/test_out_elasticsearch_dynamic.rb +681 -208
  49. data/test/test_log-ext.rb +35 -0
  50. metadata +97 -19
@@ -0,0 +1,293 @@
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
+ + [Client/host certificate options](#clienthost-certificate-options)
21
+ + [sniffer_class_name](#sniffer-class-name)
22
+ + [custom_headers](#custom_headers)
23
+ + [docinfo_fields](#docinfo_fields)
24
+ + [docinfo_target](#docinfo_target)
25
+ + [docinfo](#docinfo)
26
+ * [Advanced Usage](#advanced-usage)
27
+
28
+ ## Usage
29
+
30
+ In your Fluentd configuration, use `@type elasticsearch` and specify `tag your.awesome.tag`. Additional configuration is optional, default values would look like this:
31
+
32
+ ```
33
+ <source>
34
+ @type elasticsearch
35
+ host localhost
36
+ port 9200
37
+ index_name fluentd
38
+ type_name fluentd
39
+ tag my.logs
40
+ </source>
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ ### host
46
+
47
+ ```
48
+ host user-custom-host.domain # default localhost
49
+ ```
50
+
51
+ You can specify Elasticsearch host by this parameter.
52
+
53
+
54
+ ### port
55
+
56
+ ```
57
+ port 9201 # defaults to 9200
58
+ ```
59
+
60
+ You can specify Elasticsearch port by this parameter.
61
+
62
+ ### hosts
63
+
64
+ ```
65
+ hosts host1:port1,host2:port2,host3:port3
66
+ ```
67
+
68
+ You can specify multiple Elasticsearch hosts with separator ",".
69
+
70
+ If you specify multiple hosts, this plugin will load balance updates to Elasticsearch. This is an [elasticsearch-ruby](https://github.com/elasticsearch/elasticsearch-ruby) feature, the default strategy is round-robin.
71
+
72
+ If you specify `hosts` option, `host` and `port` options are ignored.
73
+
74
+ ```
75
+ host user-custom-host.domain # ignored
76
+ port 9200 # ignored
77
+ hosts host1:port1,host2:port2,host3:port3
78
+ ```
79
+
80
+ If you specify `hosts` option without port, `port` option is used.
81
+
82
+ ```
83
+ port 9200
84
+ hosts host1:port1,host2:port2,host3 # port3 is 9200
85
+ ```
86
+
87
+ **Note:** If you will use scheme https, do not include "https://" in your hosts ie. host "https://domain", this will cause ES cluster to be unreachable and you will receive an error "Can not reach Elasticsearch cluster"
88
+
89
+ **Note:** Up until v2.8.5, it was allowed to embed the username/password in the URL. However, this syntax is deprecated as of v2.8.6 because it was found to cause serious connection problems (See #394). Please migrate your settings to use the `user` and `password` field (described below) instead.
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 Elasticsearch). 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`, elasticsearch 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 `elasticsearch_plugin.input.time.error`.
136
+
137
+ ### http_backend
138
+
139
+ With `http_backend typhoeus`, elasticsearch plugin uses typhoeus faraday http backend.
140
+ Typhoeus can handle HTTP keepalive.
141
+
142
+ Default value is `excon` which is default http_backend of elasticsearch 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 Elasticsearch 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 elasticsearch-transport host reloading feature works. By default it will reload the host list from the server every 10,000th request to spread the load. This can be an issue if your Elasticsearch cluster is behind a Reverse Proxy, as Fluentd process may not have direct network access to the Elasticsearch nodes.
162
+
163
+ ```
164
+ reload_connections false # defaults to true
165
+ ```
166
+
167
+ ### reload_on_failure
168
+
169
+ Indicates that the elasticsearch-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 elasticsearch-transport how often dead connections from the elasticsearch-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
+ ### Client/host certificate options
196
+
197
+ Need to verify Elasticsearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
198
+ ```
199
+ ca_file /path/to/your/ca/cert
200
+ ```
201
+
202
+ Does your Elasticsearch cluster want to verify client connections? You can specify the following parameters to use your client certificate, key, and key password for your connection.
203
+ ```
204
+ client_cert /path/to/your/client/cert
205
+ client_key /path/to/your/private/key
206
+ client_key_pass password
207
+ ```
208
+
209
+ If you want to configure SSL/TLS version, you can specify ssl\_version parameter.
210
+ ```
211
+ ssl_version TLSv1_2 # or [SSLv23, TLSv1, TLSv1_1]
212
+ ```
213
+
214
+ :warning: If SSL/TLS enabled, it might have to be required to set ssl\_version.
215
+
216
+ ### Sniffer Class Name
217
+
218
+ The default Sniffer used by the `Elasticsearch::Transport` class works well when Fluentd has a direct connection
219
+ to all of the Elasticsearch servers and can make effective use of the `_nodes` API. This doesn't work well
220
+ when Fluentd must connect through a load balancer or proxy. The parameter `sniffer_class_name` gives you the
221
+ ability to provide your own Sniffer class to implement whatever connection reload logic you require. In addition,
222
+ there is a new `Fluent::Plugin::ElasticsearchSimpleSniffer` class which reuses the hosts given in the configuration, which
223
+ is typically the hostname of the load balancer or proxy. For example, a configuration like this would cause
224
+ connections to `logging-es` to reload every 100 operations:
225
+
226
+ ```
227
+ host logging-es
228
+ port 9200
229
+ reload_connections true
230
+ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
231
+ reload_after 100
232
+ ```
233
+
234
+ ### custom_headers
235
+
236
+ This parameter adds additional headers to request. The default value is `{}`.
237
+
238
+ ```
239
+ custom_headers {"token":"secret"}
240
+ ```
241
+
242
+ ### docinfo_fields
243
+
244
+ This parameter specifies docinfo record keys. The default values are `['_index', '_type', '_id']`.
245
+
246
+ ```
247
+ docinfo_fields ['_index', '_id']
248
+ ```
249
+
250
+ ### docinfo_target
251
+
252
+ This parameter specifies docinfo storing key. The default value is `@metadata`.
253
+
254
+ ```
255
+ docinfo_target metadata
256
+ ```
257
+
258
+ ### docinfo
259
+
260
+ This parameter specifies whether docinfo information including or not. The default value is `false`.
261
+
262
+ ```
263
+ docinfo false
264
+ ```
265
+
266
+ ## Advanced Usage
267
+
268
+ Elasticsearch Input plugin and Elasticsearch output plugin can combine to transfer records into another cluster.
269
+
270
+ ```aconf
271
+ <source>
272
+ @type elasticsearch
273
+ host original-cluster.local
274
+ port 9200
275
+ tag raw.elasticsearch
276
+ index_name logstash-*
277
+ docinfo true
278
+ # repeat false
279
+ # num_slices 2
280
+ # with_transporter_log true
281
+ </source>
282
+ <match raw.elasticsearch>
283
+ @type elasticsearch
284
+ host transferred-cluster.local
285
+ port 9200
286
+ index_name ${$.@metadata._index}
287
+ type_name ${$.@metadata._type} # This parameter will be deprecated due to Removal of mapping types since ES7.
288
+ id_key ${$.@metadata._id} # This parameter is needed for prevent duplicated records.
289
+ <buffer tag, $.@metadata._index, $.@metadata._type, $.@metadata._id>
290
+ @type memory # should use file buffer for preventing chunk lost
291
+ </buffer>
292
+ </match>
293
+ ```