fluent-plugin-elasticsearch 3.3.1 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/README.md +14 -14
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +22 -4
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +0 -16
- data/test/plugin/test_out_elasticsearch.rb +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65a43866400112b8742307709fb258518efdee379cdbb56b324ed365d8a4e1d7
|
4
|
+
data.tar.gz: 716149f2c5aa5380bbfc95e916d730572546bfae2520ed0b792dc6b6a828d78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d98dc4fef7b9fe208d549fc93f8a4809bfb56f156bee069bf0f599891d13b29adad5d119e9e7a2274f31aede5a13879dbf16223f98a3642d598f9f71eb2665f
|
7
|
+
data.tar.gz: ab08e35c256740009631cf5d8fa13c9f8ab9edc98f172e106d111177b4a069db13ba27a60f201c71411727bdb9cac63de716d0b6d9e4ae2184a3eac8ae12131f
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -138,7 +138,7 @@ host user-custom-host.domain # default localhost
|
|
138
138
|
|
139
139
|
You can specify Elasticsearch host by this parameter.
|
140
140
|
|
141
|
-
**Note:** Since v3.3.
|
141
|
+
**Note:** Since v3.3.2, `host` parameter supports builtin placeholders. If you want to send events dynamically into different hosts at runtime with `elasticsearch_dynamic` output plugin, please consider to switch to use plain `elasticsearch` output plugin. In more detail for builtin placeholders, please refer to [Placeholders](#placeholders) section.
|
142
142
|
|
143
143
|
### emit_error_for_missing_id
|
144
144
|
|
@@ -158,7 +158,7 @@ hosts host1:port1,host2:port2,host3:port3
|
|
158
158
|
You can specify multiple Elasticsearch hosts with separator ",".
|
159
159
|
|
160
160
|
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.
|
161
|
-
**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
|
161
|
+
**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"
|
162
162
|
|
163
163
|
**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.
|
164
164
|
|
@@ -190,7 +190,7 @@ Specify `ssl_verify false` to skip ssl verification (defaults to true)
|
|
190
190
|
logstash_format true # defaults to false
|
191
191
|
```
|
192
192
|
|
193
|
-
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}-#{
|
193
|
+
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}-#{formatted_date}`
|
194
194
|
|
195
195
|
:warning: Setting this option to `true` will ignore the `index_name` setting. The default index name prefix is `logstash-`.
|
196
196
|
|
@@ -236,7 +236,7 @@ pipeline pipeline_id
|
|
236
236
|
|
237
237
|
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.
|
238
238
|
|
239
|
-
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
|
239
|
+
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`.
|
240
240
|
|
241
241
|
For example to parse ISO8601 times with sub-second precision:
|
242
242
|
|
@@ -530,7 +530,7 @@ This following record `{"name": "Johnny", "request_id": "87d89af7daffad6"}` will
|
|
530
530
|
{ "name": "Johnny", "request_id": "87d89af7daffad6" }
|
531
531
|
```
|
532
532
|
|
533
|
-
Fluentd re-emits events that failed to be indexed/ingested in Elasticsearch with a new and unique `_id` value, this means that congested Elasticsearch clusters that reject events (due to command queue overflow, for example) will cause Fluentd to re-emit the event with a new `_id`, however Elasticsearch 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 Elasticsearch from creating
|
533
|
+
Fluentd re-emits events that failed to be indexed/ingested in Elasticsearch with a new and unique `_id` value, this means that congested Elasticsearch clusters that reject events (due to command queue overflow, for example) will cause Fluentd to re-emit the event with a new `_id`, however Elasticsearch 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 Elasticsearch from creating duplicate events.
|
534
534
|
|
535
535
|
```
|
536
536
|
id_key _hash
|
@@ -540,7 +540,7 @@ Example configuration for [fluent-plugin-genhashvalue](https://github.com/mtakem
|
|
540
540
|
```
|
541
541
|
<filter logs.**>
|
542
542
|
@type genhashvalue
|
543
|
-
keys
|
543
|
+
keys session_id,request_id
|
544
544
|
hash_type md5 # md5/sha1/sha256/sha512
|
545
545
|
base64_enc true
|
546
546
|
base91_enc false
|
@@ -745,7 +745,7 @@ http_backend typhoeus
|
|
745
745
|
|
746
746
|
### prefer_oj_serializer
|
747
747
|
|
748
|
-
With default
|
748
|
+
With default behavior, Elasticsearch client uses `Yajl` as JSON encoder/decoder.
|
749
749
|
`Oj` is the alternative high performance JSON encoder/decoder.
|
750
750
|
When this parameter sets as `true`, Elasticsearch client uses `Oj` as JSON encoder/decoder.
|
751
751
|
|
@@ -833,7 +833,7 @@ Here is a sample config:
|
|
833
833
|
@type elasticsearch
|
834
834
|
id_key _hash # specify same key name which is specified in hash_id_key
|
835
835
|
remove_keys _hash # Elasticsearch doesn't like keys that start with _
|
836
|
-
# other settings are
|
836
|
+
# other settings are omitted.
|
837
837
|
</match>
|
838
838
|
```
|
839
839
|
|
@@ -961,7 +961,7 @@ If you want configurations to depend on information in messages, you can use `el
|
|
961
961
|
|
962
962
|
v0.14 placeholders can handle `${tag}` for tag, `%Y%m%d` like strftime format, and custom record keys like as `record["mykey"]`.
|
963
963
|
|
964
|
-
Note that custom chunk key is
|
964
|
+
Note that custom chunk key is different notations for `record_reformer` and `record_modifier`.
|
965
965
|
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.
|
966
966
|
|
967
967
|
They are used as below:
|
@@ -1052,7 +1052,7 @@ Or, fluent-plugin-elasticsearch v2.11.7 or later, users can inspect version inco
|
|
1052
1052
|
validate_client_version true
|
1053
1053
|
```
|
1054
1054
|
|
1055
|
-
If you get the following error message, please consider to install
|
1055
|
+
If you get the following error message, please consider to install compatible elasticsearch client gems:
|
1056
1056
|
|
1057
1057
|
```
|
1058
1058
|
Detected ES 5 but you use ES client 6.1.0.
|
@@ -1068,7 +1068,7 @@ A common cause of failure is that you are trying to connect to an Elasticsearch
|
|
1068
1068
|
For example, `out_elasticsearch` set up ssl_version to TLSv1 due to historical reason.
|
1069
1069
|
Modern Elasticsearch ecosystem requests to communicate with TLS v1.2 or later.
|
1070
1070
|
But, in this case, `out_elasticsearch` conceals transporter part failure log by default.
|
1071
|
-
If you want to
|
1071
|
+
If you want to acquire transporter log, please consider to set the following configuration:
|
1072
1072
|
|
1073
1073
|
```
|
1074
1074
|
with_transporter_log true
|
@@ -1157,7 +1157,7 @@ Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/bin/f
|
|
1157
1157
|
Oct 31 9:44:45 <ES-Host> systemd[1]: fluentd.service: Control process exited, code=exited status=1
|
1158
1158
|
```
|
1159
1159
|
|
1160
|
-
If you want to
|
1160
|
+
If you want to acquire transporter log, please consider to set the following configuration:
|
1161
1161
|
|
1162
1162
|
```
|
1163
1163
|
with_transporter_log true
|
@@ -1171,7 +1171,7 @@ Then, the following log is shown in Fluentd log:
|
|
1171
1171
|
2018-10-31 10:00:57 +0900 [error]: #7 [Faraday::ConnectionFailed] Connection reset by peer - SSL_connect (Errno::ECONNRESET) {:host=>"<ES-Host>", :port=>9400, :scheme=>"https", :protocol=>"https"}
|
1172
1172
|
```
|
1173
1173
|
|
1174
|
-
The above logs indicates that using
|
1174
|
+
The above logs indicates that using incompatible SSL/TLS version between fluent-plugin-elasticsearch and nginx, which is reverse proxy, is root cause of this issue.
|
1175
1175
|
|
1176
1176
|
If you want to use TLS v1.2, please use `ssl_version` parameter like as:
|
1177
1177
|
|
@@ -1302,7 +1302,7 @@ If you use vanilla Fluentd, you can install it by:
|
|
1302
1302
|
gem install typhoeus
|
1303
1303
|
```
|
1304
1304
|
|
1305
|
-
But, you use td-agent instead of
|
1305
|
+
But, you use td-agent instead of vanilla Fluentd, you have to use `td-agent-gem`:
|
1306
1306
|
|
1307
1307
|
```
|
1308
1308
|
td-agent-gem install typhoeus
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'fluent-plugin-elasticsearch'
|
6
|
-
s.version = '3.3.
|
6
|
+
s.version = '3.3.2'
|
7
7
|
s.authors = ['diogo', 'pitr']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
|
9
9
|
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
@@ -274,6 +274,7 @@ EOC
|
|
274
274
|
end
|
275
275
|
|
276
276
|
@routing_key_name = configure_routing_key_name
|
277
|
+
@current_config = nil
|
277
278
|
end
|
278
279
|
|
279
280
|
def backend_options
|
@@ -353,7 +354,10 @@ EOC
|
|
353
354
|
# check here to see if we already have a client connection for the given host
|
354
355
|
connection_options = get_connection_options(host)
|
355
356
|
|
357
|
+
@_es = nil unless is_existing_connection(connection_options[:hosts])
|
358
|
+
|
356
359
|
@_es ||= begin
|
360
|
+
@current_config = connection_options[:hosts].clone
|
357
361
|
adapter_conf = lambda {|f| f.adapter @http_backend, @backend_options }
|
358
362
|
local_reload_connections = @reload_connections
|
359
363
|
if local_reload_connections && @reload_after > DEFAULT_RELOAD_AFTER
|
@@ -427,8 +431,8 @@ EOC
|
|
427
431
|
}
|
428
432
|
end
|
429
433
|
|
430
|
-
def connection_options_description
|
431
|
-
get_connection_options[:hosts].map do |host_info|
|
434
|
+
def connection_options_description(con_host=nil)
|
435
|
+
get_connection_options(con_host)[:hosts].map do |host_info|
|
432
436
|
attributes = host_info.dup
|
433
437
|
attributes[:password] = 'obfuscated' if attributes.has_key?(:password)
|
434
438
|
attributes.inspect
|
@@ -565,7 +569,6 @@ EOC
|
|
565
569
|
end
|
566
570
|
end
|
567
571
|
|
568
|
-
|
569
572
|
bulk_message.each do |info, msgs|
|
570
573
|
send_bulk(msgs, tag, chunk, bulk_message_count[info], extracted_values, info) unless msgs.empty?
|
571
574
|
msgs.clear
|
@@ -678,8 +681,23 @@ EOC
|
|
678
681
|
@_es = nil if @reconnect_on_error
|
679
682
|
@_es_info = nil if @reconnect_on_error
|
680
683
|
# FIXME: identify unrecoverable errors and raise UnrecoverableRequestFailure instead
|
681
|
-
raise RecoverableRequestFailure, "could not push logs to Elasticsearch cluster (#{connection_options_description}): #{e.message}"
|
684
|
+
raise RecoverableRequestFailure, "could not push logs to Elasticsearch cluster (#{connection_options_description(info.host)}): #{e.message}"
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
def is_existing_connection(host)
|
689
|
+
# check if the host provided match the current connection
|
690
|
+
return false if @_es.nil?
|
691
|
+
return false if @current_config.nil?
|
692
|
+
return false if host.length != @current_config.length
|
693
|
+
|
694
|
+
for i in 0...host.length
|
695
|
+
if !host[i][:host].eql? @current_config[i][:host] || host[i][:port] != @current_config[i][:port]
|
696
|
+
return false
|
697
|
+
end
|
682
698
|
end
|
699
|
+
|
700
|
+
return true
|
683
701
|
end
|
684
702
|
end
|
685
703
|
end
|
@@ -28,7 +28,6 @@ module Fluent::Plugin
|
|
28
28
|
@dynamic_config[key] = value.to_s
|
29
29
|
}
|
30
30
|
# end eval all configs
|
31
|
-
@current_config = nil
|
32
31
|
end
|
33
32
|
|
34
33
|
def create_meta_config_map
|
@@ -259,20 +258,5 @@ module Fluent::Plugin
|
|
259
258
|
return false if [:@buffer_type].include?(param)
|
260
259
|
return self.instance_variable_get(param).is_a?(String)
|
261
260
|
end
|
262
|
-
|
263
|
-
def is_existing_connection(host)
|
264
|
-
# check if the host provided match the current connection
|
265
|
-
return false if @_es.nil?
|
266
|
-
return false if @current_config.nil?
|
267
|
-
return false if host.length != @current_config.length
|
268
|
-
|
269
|
-
for i in 0...host.length
|
270
|
-
if !host[i][:host].eql? @current_config[i][:host] || host[i][:port] != @current_config[i][:port]
|
271
|
-
return false
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
return true
|
276
|
-
end
|
277
261
|
end
|
278
262
|
end
|
@@ -1535,12 +1535,16 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1535
1535
|
]
|
1536
1536
|
))
|
1537
1537
|
time = Time.parse Date.today.iso8601
|
1538
|
-
|
1539
|
-
|
1538
|
+
first_pipeline_id = "1"
|
1539
|
+
second_pipeline_id = "2"
|
1540
|
+
first_request = stub_elastic("http://myhost-1:9200/_bulk")
|
1541
|
+
second_request = stub_elastic("http://myhost-2:9200/_bulk")
|
1540
1542
|
driver.run(default_tag: 'test') do
|
1541
|
-
driver.feed(time.to_i, sample_record.merge({"pipeline_id" =>
|
1543
|
+
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => first_pipeline_id}))
|
1544
|
+
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => second_pipeline_id}))
|
1542
1545
|
end
|
1543
|
-
assert_requested(
|
1546
|
+
assert_requested(first_request)
|
1547
|
+
assert_requested(second_request)
|
1544
1548
|
end
|
1545
1549
|
end
|
1546
1550
|
|
@@ -1558,7 +1562,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1558
1562
|
assert_equal(logstash_index, index_cmds.first['index']['_index'])
|
1559
1563
|
end
|
1560
1564
|
|
1561
|
-
|
1565
|
+
def test_writes_to_logstash_index_with_specified_dateformat
|
1562
1566
|
driver.configure("logstash_format true
|
1563
1567
|
logstash_dateformat %Y.%m")
|
1564
1568
|
time = Time.parse Date.today.iso8601
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- diogo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-03-
|
12
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|