fluent-plugin-elasticsearch-sm 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.editorconfig +9 -0
- data/.gitignore +17 -0
- data/.travis.yml +11 -0
- data/Gemfile +8 -0
- data/History.md +81 -0
- data/LICENSE.txt +22 -0
- data/PULL_REQUEST_TEMPLATE.md +10 -0
- data/README.md +417 -0
- data/Rakefile +10 -0
- data/lib/fluent/plugin/out_elasticsearch.rb +249 -0
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +239 -0
- data/test/helper.rb +24 -0
- data/test/plugin/test_out_elasticsearch.rb +636 -0
- data/test/plugin/test_out_elasticsearch_dynamic.rb +537 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4417081c4286bced3a388c0790bd66b83172d3ec
|
4
|
+
data.tar.gz: 4a58dc22e2b721dc1f61a861ab7fb75a5586c03b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d5d982898869656e63ce0d69f4e6c3b42a4c98cc428c158ae9b5333492144db86c8281868a4d3a53a69e6f9cf378694c3422e33f00a2f13b32a493f83c36f8c
|
7
|
+
data.tar.gz: c5e777b765689d6a00bf8d078a007f1351a48325a1fd5060d53547fc766e8efe5c43bd2fad33b8bbbe77bc5bf79aede3fbe9d3ead54a17f53b8596683044e1fc
|
data/.coveralls.yml
ADDED
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in fluent-plugin-elasticsearch.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'simplecov', require: false
|
7
|
+
gem 'coveralls', require: false
|
8
|
+
gem 'strptime', require: false if RUBY_ENGINE == "ruby" && RUBY_VERSION =~ /^2/
|
data/History.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
## Changelog
|
2
|
+
|
3
|
+
### Future
|
4
|
+
- add `routing_key` (#158)
|
5
|
+
|
6
|
+
### 1.4.0
|
7
|
+
- add `target_index_key` to specify target index (#153)
|
8
|
+
- add `time_key_format` for faster time format parsing (#154)
|
9
|
+
|
10
|
+
### 1.3.0
|
11
|
+
- add `write_operation`
|
12
|
+
|
13
|
+
### 1.2.1
|
14
|
+
- fix `resurrect_after` in out_elasticsearch_dynamic
|
15
|
+
|
16
|
+
### 1.2.0
|
17
|
+
- out_elasticsearch_dynamic get memory improvement and fix for race condition (#133)
|
18
|
+
- Add `resurrect_after` option (#136)
|
19
|
+
|
20
|
+
### 1.1.0
|
21
|
+
- Support SSL client verification and custom CA file (#123)
|
22
|
+
- Release experimental `type elasticsearch_dynamic` (#127)
|
23
|
+
|
24
|
+
### 1.0.0
|
25
|
+
- password config param is now marked as secret and won't be displayed in logs.
|
26
|
+
|
27
|
+
### 0.9.0
|
28
|
+
- Add `ssl_verify` option (#108)
|
29
|
+
|
30
|
+
### 0.8.0
|
31
|
+
- Replace Patron with Excon HTTP client (#93)
|
32
|
+
|
33
|
+
### 0.7.0
|
34
|
+
- Add new option `time_key` (#85)
|
35
|
+
|
36
|
+
### 0.6.1
|
37
|
+
- 0.10.43 is minimum version required of fluentd (#79)
|
38
|
+
|
39
|
+
### 0.6.0
|
40
|
+
- added `reload_on_failure` and `reload_connections` flags (#78)
|
41
|
+
|
42
|
+
### 0.5.1
|
43
|
+
- fix legacy hosts option, port should be optional (#75)
|
44
|
+
|
45
|
+
### 0.5.0
|
46
|
+
- add full connection URI support (#65)
|
47
|
+
- use `@timestamp` for index (#41)
|
48
|
+
- add support for elasticsearch gem version 1 (#71)
|
49
|
+
- fix connection reset & retry when connection is lost (#67)
|
50
|
+
|
51
|
+
### 0.4.0
|
52
|
+
- add `request_timeout` config (#59)
|
53
|
+
- fix lockup when non-hash values are sent (#52)
|
54
|
+
|
55
|
+
### 0.3.1
|
56
|
+
- force using patron (#46)
|
57
|
+
- do not generate @timestamp if already part of message (#35)
|
58
|
+
|
59
|
+
### 0.3.0
|
60
|
+
- add `parent_key` option (#28)
|
61
|
+
- have travis-ci build on multiple rubies (#30)
|
62
|
+
- add `utc_index` and `hosts` options, switch to using `elasticsearch` gem (#26, #29)
|
63
|
+
|
64
|
+
### 0.2.0
|
65
|
+
- fix encoding issues with JSON conversion and again when sending to elasticsearch (#19, #21)
|
66
|
+
- add logstash_dateformat option (#20)
|
67
|
+
|
68
|
+
### 0.1.4
|
69
|
+
- add logstash_prefix option
|
70
|
+
|
71
|
+
### 0.1.3
|
72
|
+
- raising an exception on non-success response from elasticsearch
|
73
|
+
|
74
|
+
### 0.1.2
|
75
|
+
- add id_key option
|
76
|
+
|
77
|
+
### 0.1.1
|
78
|
+
- fix timezone in logstash key
|
79
|
+
|
80
|
+
### 0.1.0
|
81
|
+
- Initial gem release.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Uken Games
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Pull Request Description HERE
|
2
|
+
|
3
|
+
(check all that apply)
|
4
|
+
- [ ] tests added
|
5
|
+
- [ ] tests passing
|
6
|
+
- [ ] README updated (if needed)
|
7
|
+
- [ ] README Table of Contents updated (if needed)
|
8
|
+
- [ ] History.md and `version` in gemspec are untouched
|
9
|
+
- [ ] backward compatible
|
10
|
+
- [ ] feature works in `elasticsearch_dynamic` (not required but recommended)
|
data/README.md
ADDED
@@ -0,0 +1,417 @@
|
|
1
|
+
# Fluent::Plugin::Elasticsearch, a plugin for [Fluentd](http://fluentd.org)
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-elasticsearch.png)](http://badge.fury.io/rb/fluent-plugin-elasticsearch)
|
4
|
+
[![Build Status](https://travis-ci.org/uken/fluent-plugin-elasticsearch.png?branch=master)](https://travis-ci.org/uken/fluent-plugin-elasticsearch)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/uken/fluent-plugin-elasticsearch/badge.png)](https://coveralls.io/r/uken/fluent-plugin-elasticsearch)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch.png)](https://codeclimate.com/github/uken/fluent-plugin-elasticsearch)
|
7
|
+
[![Issue Stats](http://issuestats.com/github/uken/fluent-plugin-elasticsearch/badge/pr)](http://issuestats.com/github/uken/fluent-plugin-elasticsearch)
|
8
|
+
[![Issue Stats](http://issuestats.com/github/uken/fluent-plugin-elasticsearch/badge/issue)](http://issuestats.com/github/uken/fluent-plugin-elasticsearch)
|
9
|
+
|
10
|
+
Send your logs to ElasticSearch (and search them with Kibana maybe?)
|
11
|
+
|
12
|
+
Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-elasticsearch-service](https://github.com/atomita/fluent-plugin-aws-elasticsearch-service)
|
13
|
+
|
14
|
+
* [Installation](#installation)
|
15
|
+
* [Usage](#usage)
|
16
|
+
+ [Index templates](#index-templates)
|
17
|
+
* [Configuration](#configuration)
|
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_dateformat](#logstash_dateformat)
|
23
|
+
+ [time_key_format](#time_key_format)
|
24
|
+
+ [time_key](#time_key)
|
25
|
+
+ [time_key_exclude_timestamp](#time_key_exclude_timestamp)
|
26
|
+
+ [utc_index](#utc_index)
|
27
|
+
+ [target_index_key](#target_index_key)
|
28
|
+
+ [request_timeout](#request_timeout)
|
29
|
+
+ [reload_connections](#reload_connections)
|
30
|
+
+ [reload_on_failure](#reload_on_failure)
|
31
|
+
+ [resurrect_after](#resurrect_after)
|
32
|
+
+ [include_tag_key, tag_key](#include_tag_key-tag_key)
|
33
|
+
+ [id_key](#id_key)
|
34
|
+
+ [parent_key](#parent_key)
|
35
|
+
+ [routing_key](#routing_key)
|
36
|
+
+ [write_operation](#write_operation)
|
37
|
+
+ [Client/host certificate options](#clienthost-certificate-options)
|
38
|
+
+ [Proxy Support](#proxy-support)
|
39
|
+
+ [Buffered output options](#buffered-output-options)
|
40
|
+
+ [Not seeing a config you need?](#not-seeing-a-config-you-need)
|
41
|
+
+ [Dynamic configuration](#dynamic-configuration)
|
42
|
+
* [Contact](#contact)
|
43
|
+
* [Contributing](#contributing)
|
44
|
+
* [Running tests](#running-tests)
|
45
|
+
|
46
|
+
## Installation
|
47
|
+
|
48
|
+
```sh
|
49
|
+
$ gem install fluent-plugin-elasticsearch
|
50
|
+
```
|
51
|
+
|
52
|
+
## Usage
|
53
|
+
|
54
|
+
In your Fluentd configuration, use `@type elasticsearch`. Additional configuration is optional, default values would look like this:
|
55
|
+
|
56
|
+
```
|
57
|
+
<match my.logs>
|
58
|
+
@type elasticsearch
|
59
|
+
host localhost
|
60
|
+
port 9200
|
61
|
+
index_name fluentd
|
62
|
+
type_name fluentd
|
63
|
+
</match>
|
64
|
+
```
|
65
|
+
|
66
|
+
### Index templates
|
67
|
+
|
68
|
+
This plugin creates ElasticSearch indices by merely writing to them. Consider using [Index Templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) to gain control of what get indexed and how. See [this example](https://github.com/uken/fluent-plugin-elasticsearch/issues/33#issuecomment-38693282) for a good starting point.
|
69
|
+
|
70
|
+
## Configuration
|
71
|
+
|
72
|
+
### hosts
|
73
|
+
|
74
|
+
```
|
75
|
+
hosts host1:port1,host2:port2,host3:port3
|
76
|
+
# or
|
77
|
+
hosts https://customhost.com:443/path,https://username:password@host-failover.com:443
|
78
|
+
```
|
79
|
+
|
80
|
+
You can specify multiple ElasticSearch hosts with separator ",".
|
81
|
+
|
82
|
+
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.
|
83
|
+
|
84
|
+
### user, password, path, scheme, ssl_verify
|
85
|
+
|
86
|
+
If you specify this option, host and port options are ignored.
|
87
|
+
|
88
|
+
```
|
89
|
+
user demo
|
90
|
+
password secret
|
91
|
+
path /elastic_search/
|
92
|
+
scheme https
|
93
|
+
```
|
94
|
+
|
95
|
+
You can specify user and password for HTTP basic auth. If used in conjunction with a hosts list, then these options will be used by default i.e. if you do not provide any of these options within the hosts listed.
|
96
|
+
|
97
|
+
Specify `ssl_verify false` to skip ssl verification (defaults to true)
|
98
|
+
|
99
|
+
### logstash_format
|
100
|
+
|
101
|
+
```
|
102
|
+
logstash_format true # defaults to false
|
103
|
+
```
|
104
|
+
|
105
|
+
This is meant to make writing data into ElasticSearch indices compatible to what [Logstash](https://www.elastic.co/products/logstash) calls them. By doing this, one could take advantage of [Kibana](https://www.elastic.co/products/kibana). See logstash_prefix and logstash_dateformat to customize this index name pattern. The index name will be `#{logstash_prefix}-#{formated_date}`
|
106
|
+
|
107
|
+
### logstash_prefix
|
108
|
+
|
109
|
+
```
|
110
|
+
logstash_prefix mylogs # defaults to "logstash"
|
111
|
+
```
|
112
|
+
|
113
|
+
### logstash_dateformat
|
114
|
+
|
115
|
+
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.
|
116
|
+
|
117
|
+
```
|
118
|
+
logstash_dateformat %Y.%m. # defaults to "%Y.%m.%d"
|
119
|
+
```
|
120
|
+
|
121
|
+
### time_key_format
|
122
|
+
|
123
|
+
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.
|
124
|
+
|
125
|
+
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 improvment by installing the "strptime" gem: `fluent-gem install strptime`.
|
126
|
+
|
127
|
+
For example to parse ISO8601 times with sub-second precision:
|
128
|
+
|
129
|
+
```
|
130
|
+
time_key_format %Y-%m-%dT%H:%M:%S.%N%z
|
131
|
+
```
|
132
|
+
|
133
|
+
### time_key
|
134
|
+
|
135
|
+
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.
|
136
|
+
|
137
|
+
```
|
138
|
+
{"@timestamp":"2014-04-07T000:00:00-00:00"}
|
139
|
+
```
|
140
|
+
|
141
|
+
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.
|
142
|
+
|
143
|
+
Suppose you have settings
|
144
|
+
|
145
|
+
```
|
146
|
+
logstash_format true
|
147
|
+
time_key vtm
|
148
|
+
```
|
149
|
+
|
150
|
+
Your input is:
|
151
|
+
```
|
152
|
+
{
|
153
|
+
"title": "developer",
|
154
|
+
"vtm": "2014-12-19T08:01:03Z"
|
155
|
+
}
|
156
|
+
```
|
157
|
+
|
158
|
+
The output will be
|
159
|
+
```
|
160
|
+
{
|
161
|
+
"title": "developer",
|
162
|
+
"@timestamp": "2014-12-19T08:01:03Z",
|
163
|
+
"vtm": "2014-12-19T08:01:03Z"
|
164
|
+
}
|
165
|
+
```
|
166
|
+
|
167
|
+
See `time_key_exclude_timestamp` to avoid adding `@timestamp`.
|
168
|
+
|
169
|
+
### time_key_exclude_timestamp
|
170
|
+
|
171
|
+
```
|
172
|
+
time_key_exclude_timestamp false
|
173
|
+
```
|
174
|
+
|
175
|
+
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.
|
176
|
+
|
177
|
+
### utc_index
|
178
|
+
|
179
|
+
```
|
180
|
+
utc_index true
|
181
|
+
```
|
182
|
+
|
183
|
+
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.
|
184
|
+
|
185
|
+
### target_index_key
|
186
|
+
|
187
|
+
Tell this plugin to find the index name to write to in the record under this key in preference to other mechanisms.
|
188
|
+
|
189
|
+
If it is present in the record (and the value is non falsey) 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.
|
190
|
+
|
191
|
+
Suppose you have the following settings
|
192
|
+
|
193
|
+
```
|
194
|
+
target_index_key @target_index
|
195
|
+
index_name fallback
|
196
|
+
```
|
197
|
+
|
198
|
+
If your input is:
|
199
|
+
```
|
200
|
+
{
|
201
|
+
"title": "developer",
|
202
|
+
"@timestamp": "2014-12-19T08:01:03Z",
|
203
|
+
"@target_index": "logstash-2014.12.19"
|
204
|
+
}
|
205
|
+
```
|
206
|
+
|
207
|
+
The output would be
|
208
|
+
|
209
|
+
```
|
210
|
+
{
|
211
|
+
"title": "developer",
|
212
|
+
"@timestamp": "2014-12-19T08:01:03Z",
|
213
|
+
}
|
214
|
+
```
|
215
|
+
|
216
|
+
and this record will be written to the specified index (`logstash-2014.12.19`) rather than `fallback`.
|
217
|
+
|
218
|
+
### request_timeout
|
219
|
+
|
220
|
+
You can specify HTTP request timeout.
|
221
|
+
|
222
|
+
This is useful when ElasticSearch cannot return response for bulk request within the default of 5 seconds.
|
223
|
+
|
224
|
+
```
|
225
|
+
request_timeout 15s # defaults to 5s
|
226
|
+
```
|
227
|
+
|
228
|
+
### reload_connections
|
229
|
+
|
230
|
+
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.
|
231
|
+
|
232
|
+
```
|
233
|
+
reload_connections false # defaults to true
|
234
|
+
```
|
235
|
+
|
236
|
+
### reload_on_failure
|
237
|
+
|
238
|
+
Indicates that the elasticsearch-transport will try to reload the nodes addresses if there is a failure while making the
|
239
|
+
request, this can be useful to quickly remove a dead node from the list of addresses.
|
240
|
+
|
241
|
+
```
|
242
|
+
reload_on_failure true # defaults to false
|
243
|
+
```
|
244
|
+
|
245
|
+
### resurrect_after
|
246
|
+
|
247
|
+
You can set in the elasticsearch-transport how often dead connections from the elasticsearch-transport's pool will be resurrected.
|
248
|
+
|
249
|
+
```
|
250
|
+
resurrect_after 5 # defaults to 60s
|
251
|
+
```
|
252
|
+
|
253
|
+
### include_tag_key, tag_key
|
254
|
+
|
255
|
+
```
|
256
|
+
include_tag_key true # defaults to false
|
257
|
+
tag_key tag # defaults to tag
|
258
|
+
```
|
259
|
+
|
260
|
+
This will add the Fluentd tag in the JSON record. For instance, if you have a config like this:
|
261
|
+
|
262
|
+
```
|
263
|
+
<match my.logs>
|
264
|
+
@type elasticsearch
|
265
|
+
include_tag_key true
|
266
|
+
tag_key _key
|
267
|
+
</match>
|
268
|
+
```
|
269
|
+
|
270
|
+
The record inserted into ElasticSearch would be
|
271
|
+
|
272
|
+
```
|
273
|
+
{"_key":"my.logs", "name":"Johnny Doeie"}
|
274
|
+
```
|
275
|
+
|
276
|
+
### id_key
|
277
|
+
|
278
|
+
```
|
279
|
+
id_key request_id # use "request_id" field as a record id in ES
|
280
|
+
```
|
281
|
+
|
282
|
+
By default, all records inserted into ElasticSearch get a random _id. This option allows to use a field in the record as an identifier.
|
283
|
+
|
284
|
+
This following record `{"name":"Johnny","request_id":"87d89af7daffad6"}` will trigger the following ElasticSearch command
|
285
|
+
|
286
|
+
```
|
287
|
+
{ "index" : { "_index" : "logstash-2013.01.01, "_type" : "fluentd", "_id" : "87d89af7daffad6" } }
|
288
|
+
{ "name": "Johnny", "request_id": "87d89af7daffad6" }
|
289
|
+
```
|
290
|
+
|
291
|
+
### parent_key
|
292
|
+
|
293
|
+
```
|
294
|
+
parent_key a_parent # use "a_parent" field value to set _parent in elasticsearch command
|
295
|
+
```
|
296
|
+
|
297
|
+
If your input is
|
298
|
+
```
|
299
|
+
{ "name": "Johnny", "a_parent": "my_parent" }
|
300
|
+
```
|
301
|
+
|
302
|
+
ElasticSearch command would be
|
303
|
+
|
304
|
+
```
|
305
|
+
{ "index" : { "_index" : "****", "_type" : "****", "_id" : "****", "_parent" : "my_parent" } }
|
306
|
+
{ "name": "Johnny", "a_parent": "my_parent" }
|
307
|
+
```
|
308
|
+
|
309
|
+
if `parent_key` is not configed or the `parent_key` is absent in input record, nothing will happen.
|
310
|
+
|
311
|
+
### routing_key
|
312
|
+
|
313
|
+
Similar to `parent_key` config, will add `_routing` into elasticsearch command if `routing_key` is set and the field does exist in input event.
|
314
|
+
|
315
|
+
### write_operation
|
316
|
+
|
317
|
+
The write_operation can be any of:
|
318
|
+
|
319
|
+
| Operation | Description |
|
320
|
+
| ------------- | ----------- |
|
321
|
+
| index (default) | new data is added while existing data (based on its id) is replaced (reindexed).|
|
322
|
+
| create | adds new data - if the data already exists (based on its id), the op is skipped.|
|
323
|
+
| update | updates existing data (based on its id). If no data is found, the op is skipped.|
|
324
|
+
| upsert | known as merge or insert if the data does not exist, updates if the data exists (based on its id).|
|
325
|
+
|
326
|
+
**Please note, id is required in create, update, and upsert scenario. Without id, the message will be dropped.**
|
327
|
+
|
328
|
+
### Client/host certificate options
|
329
|
+
|
330
|
+
Need to verify ElasticSearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
|
331
|
+
```
|
332
|
+
ca_file /path/to/your/ca/cert
|
333
|
+
```
|
334
|
+
|
335
|
+
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.
|
336
|
+
```
|
337
|
+
client_cert /path/to/your/client/cert
|
338
|
+
client_key /path/to/your/private/key
|
339
|
+
client_key_pass password
|
340
|
+
```
|
341
|
+
|
342
|
+
### Proxy Support
|
343
|
+
|
344
|
+
Starting with version 0.8.0, this gem uses excon, which supports proxy with environment variables - https://github.com/excon/excon#proxy-support
|
345
|
+
|
346
|
+
### Buffered output options
|
347
|
+
|
348
|
+
`fluentd-plugin-elasticsearch` extends [Fluentd's builtin Buffered Output plugin](http://docs.fluentd.org/articles/buffer-plugin-overview). It adds the following options:
|
349
|
+
|
350
|
+
```
|
351
|
+
buffer_type memory
|
352
|
+
flush_interval 60
|
353
|
+
retry_limit 17
|
354
|
+
retry_wait 1.0
|
355
|
+
num_threads 1
|
356
|
+
```
|
357
|
+
|
358
|
+
The value for option `buffer_chunk_limit` should not exceed value `http.max_content_length` in your Elasticsearch setup (by default it is 100mb).
|
359
|
+
|
360
|
+
### Not seeing a config you need?
|
361
|
+
|
362
|
+
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.
|
363
|
+
|
364
|
+
Alternatively, consider using [fluent-plugin-forest](https://github.com/tagomoris/fluent-plugin-forest). For example, to configure multiple tags to be sent to different ElasticSearch indices:
|
365
|
+
|
366
|
+
```
|
367
|
+
<match my.logs.*>
|
368
|
+
@type forest
|
369
|
+
subtype elasticsearch
|
370
|
+
remove_prefix my.logs
|
371
|
+
<template>
|
372
|
+
logstash_prefix ${tag}
|
373
|
+
# ...
|
374
|
+
</template>
|
375
|
+
</match>
|
376
|
+
```
|
377
|
+
|
378
|
+
And yet another option is described in Dynamic Configuration section.
|
379
|
+
|
380
|
+
### Dynamic configuration
|
381
|
+
|
382
|
+
If you want configurations to depend on information in messages, you can use `elasticsearch_dynamic`. This is an experimental variation of the ElasticSearch plugin allows configuration values to be specified in ways such as the below:
|
383
|
+
|
384
|
+
```
|
385
|
+
<match my.logs.*>
|
386
|
+
@type elasticsearch_dynamic
|
387
|
+
hosts ${record['host1']}:9200,${record['host2']}:9200
|
388
|
+
index_name my_index.${Time.at(time).getutc.strftime(@logstash_dateformat)}
|
389
|
+
logstash_prefix ${tag_parts[3]}
|
390
|
+
port ${9200+rand(4)}
|
391
|
+
index_name ${tag_parts[2]}-${Time.at(time).getutc.strftime(@logstash_dateformat)}
|
392
|
+
</match>
|
393
|
+
```
|
394
|
+
|
395
|
+
**Please note, this uses Ruby's `eval` for every message, so there are performance and security implications.**
|
396
|
+
|
397
|
+
## Contact
|
398
|
+
|
399
|
+
If you have a question, [open an Issue](https://github.com/uken/fluent-plugin-elasticsearch/issues).
|
400
|
+
|
401
|
+
## Contributing
|
402
|
+
|
403
|
+
There are usually a few feature requests, tagged [Easy](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AEasy), [Normal](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3ANormal) and [Hard](https://github.com/uken/fluent-plugin-elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3Alevel%3AHard). Feel free to work on any one of them.
|
404
|
+
|
405
|
+
Pull Requests are welcomed.
|
406
|
+
|
407
|
+
[![Pull Request Graph](https://graphs.waffle.io/uken/fluent-plugin-elasticsearch/throughput.svg)](https://waffle.io/uken/fluent-plugin-elasticsearch/metrics)
|
408
|
+
|
409
|
+
## Running tests
|
410
|
+
|
411
|
+
Install dev dependencies:
|
412
|
+
|
413
|
+
```sh
|
414
|
+
$ gem install bundler
|
415
|
+
$ bundle install
|
416
|
+
$ bundle exec rake test
|
417
|
+
```
|