fluent-plugin-elasticsearch 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +3 -0
- data/README.Troubleshooting.md +91 -0
- data/README.md +30 -2
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +6 -1
- data/test/plugin/test_out_elasticsearch.rb +108 -0
- 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: 6eb418d889b91bf79c37c1cd72789981eb4133bcfc34e21b26e79bb919462272
|
4
|
+
data.tar.gz: 168ddc77fb73216da63f1ce65ed673cf12ab13d6db549fc3e2da81956c938990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4a2a8f63b25ea8785e0d4ef291043a93a86fea8f42638caaf46dd3efe29fd0a12919dd339d8a28c97aef65494ba054a3ff3312a122ab2cd89cb54cb069055c
|
7
|
+
data.tar.gz: 6b13851ce29b2a6f2083ebc57ae733a9ca00d79a9fd09ac4c7630d99a9c6d2da302c48f2e0cd901810e0a851911e14f8355fc336e21afd97d3f33fe205b0c78a
|
data/History.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
## Changelog [[tags]](https://github.com/uken/fluent-plugin-elasticsearch/tags)
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
|
+
- Fix use_legacy_template documentation (#880)
|
5
|
+
- Add FAQ for dynamic index/template (#878)
|
6
|
+
- Handle IPv6 address string on host and hosts parameters (#877)
|
4
7
|
|
5
8
|
### 5.0.2
|
6
9
|
- GitHub Actions: Tweak Ruby versions on test (#875)
|
data/README.Troubleshooting.md
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
+ [Random 400 - Rejected by Elasticsearch is occured, why?](#random-400---rejected-by-elasticsearch-is-occured-why)
|
11
11
|
+ [Fluentd seems to hang if it unable to connect Elasticsearch, why?](#fluentd-seems-to-hang-if-it-unable-to-connect-elasticsearch-why)
|
12
12
|
+ [Enable Index Lifecycle Management](#enable-index-lifecycle-management)
|
13
|
+
+ [Configuring for dynamic index or template](#configuring-for-dynamic-index-or-template)
|
13
14
|
+ [How to specify index codec](#how-to-specify-index-codec)
|
14
15
|
+ [Cannot push logs to Elasticsearch with connect_write timeout reached, why?](#cannot-push-logs-to-elasticsearch-with-connect_write-timeout-reached-why)
|
15
16
|
|
@@ -524,6 +525,96 @@ template_name your-fluentd-template
|
|
524
525
|
template_file /path/to/fluentd-template.json
|
525
526
|
```
|
526
527
|
|
528
|
+
#### Configuring for dynamic index or template
|
529
|
+
|
530
|
+
Some users want to setup ILM for dynamic index/template.
|
531
|
+
`index_petterns` and `template.settings.index.lifecycle.name` in Elasticsearch template will be overwritten by Elasticsearch plugin:
|
532
|
+
|
533
|
+
```json
|
534
|
+
{
|
535
|
+
"index_patterns": ["mock"],
|
536
|
+
"template": {
|
537
|
+
"settings": {
|
538
|
+
"index": {
|
539
|
+
"lifecycle": {
|
540
|
+
"name": "mock",
|
541
|
+
"rollover_alias": "mock"
|
542
|
+
},
|
543
|
+
"number_of_shards": "<<shard>>",
|
544
|
+
"number_of_replicas": "<<replica>>"
|
545
|
+
}
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
```
|
550
|
+
|
551
|
+
This template will be handled with:
|
552
|
+
|
553
|
+
```aconf
|
554
|
+
<source>
|
555
|
+
@type http
|
556
|
+
port 5004
|
557
|
+
bind 0.0.0.0
|
558
|
+
body_size_limit 32m
|
559
|
+
keepalive_timeout 10s
|
560
|
+
<parse>
|
561
|
+
@type json
|
562
|
+
</parse>
|
563
|
+
</source>
|
564
|
+
|
565
|
+
<match kubernetes.var.log.containers.**etl-webserver**.log>
|
566
|
+
@type elasticsearch
|
567
|
+
@id out_es_etl_webserver
|
568
|
+
@log_level info
|
569
|
+
include_tag_key true
|
570
|
+
host $HOST
|
571
|
+
port $PORT
|
572
|
+
path "#{ENV['FLUENT_ELASTICSEARCH_PATH']}"
|
573
|
+
request_timeout "#{ENV['FLUENT_ELASTICSEARCH_REQUEST_TIMEOUT'] || '30s'}"
|
574
|
+
scheme "#{ENV['FLUENT_ELASTICSEARCH_SCHEME'] || 'http'}"
|
575
|
+
ssl_verify "#{ENV['FLUENT_ELASTICSEARCH_SSL_VERIFY'] || 'true'}"
|
576
|
+
ssl_version "#{ENV['FLUENT_ELASTICSEARCH_SSL_VERSION'] || 'TLSv1'}"
|
577
|
+
reload_connections "#{ENV['FLUENT_ELASTICSEARCH_RELOAD_CONNECTIONS'] || 'false'}"
|
578
|
+
reconnect_on_error "#{ENV['FLUENT_ELASTICSEARCH_RECONNECT_ON_ERROR'] || 'true'}"
|
579
|
+
reload_on_failure "#{ENV['FLUENT_ELASTICSEARCH_RELOAD_ON_FAILURE'] || 'true'}"
|
580
|
+
log_es_400_reason "#{ENV['FLUENT_ELASTICSEARCH_LOG_ES_400_REASON'] || 'false'}"
|
581
|
+
logstash_prefix "#{ENV['FLUENT_ELASTICSEARCH_LOGSTASH_PREFIX'] || 'etl-webserver'}"
|
582
|
+
logstash_format "#{ENV['FLUENT_ELASTICSEARCH_LOGSTASH_FORMAT'] || 'false'}"
|
583
|
+
index_name "#{ENV['FLUENT_ELASTICSEARCH_LOGSTASH_INDEX_NAME'] || 'etl-webserver'}"
|
584
|
+
type_name "#{ENV['FLUENT_ELASTICSEARCH_LOGSTASH_TYPE_NAME'] || 'fluentd'}"
|
585
|
+
time_key "#{ENV['FLUENT_ELASTICSEARCH_TIME_KEY'] || '@timestamp'}"
|
586
|
+
include_timestamp "#{ENV['FLUENT_ELASTICSEARCH_INCLUDE_TIMESTAMP'] || 'true'}"
|
587
|
+
|
588
|
+
# ILM Settings - WITH ROLLOVER support
|
589
|
+
# https://github.com/uken/fluent-plugin-elasticsearch#enable-index-lifecycle-management
|
590
|
+
application_name "etl-webserver"
|
591
|
+
index_date_pattern ""
|
592
|
+
# Policy configurations
|
593
|
+
enable_ilm true
|
594
|
+
ilm_policy_id etl-webserver
|
595
|
+
ilm_policy_overwrite true
|
596
|
+
ilm_policy {"policy": {"phases": {"hot": {"min_age": "0ms","actions": {"rollover": {"max_age": "5m","max_size": "3gb"},"set_priority": {"priority": 100}}},"delete": {"min_age": "30d","actions": {"delete": {"delete_searchable_snapshot": true}}}}}}
|
597
|
+
use_legacy_template false
|
598
|
+
template_name etl-webserver
|
599
|
+
template_file /configs/index-template.json
|
600
|
+
template_overwrite true
|
601
|
+
customize_template {"<<shard>>": "3","<<replica>>": "0"}
|
602
|
+
|
603
|
+
<buffer>
|
604
|
+
flush_thread_count "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_FLUSH_THREAD_COUNT'] || '8'}"
|
605
|
+
flush_interval "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_FLUSH_INTERVAL'] || '5s'}"
|
606
|
+
chunk_limit_size "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_CHUNK_LIMIT_SIZE'] || '8MB'}"
|
607
|
+
total_limit_size "#{ENV['FLUENT_ELASTICSEARCH_TOTAL_LIMIT_SIZE'] || '450MB'}"
|
608
|
+
queue_limit_length "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_QUEUE_LIMIT_LENGTH'] || '32'}"
|
609
|
+
retry_max_interval "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_RETRY_MAX_INTERVAL'] || '60s'}"
|
610
|
+
retry_forever false
|
611
|
+
</buffer>
|
612
|
+
</match>
|
613
|
+
```
|
614
|
+
|
615
|
+
For more details, please refer the discussion:
|
616
|
+
https://github.com/uken/fluent-plugin-elasticsearch/issues/867
|
617
|
+
|
527
618
|
### How to specify index codec
|
528
619
|
|
529
620
|
Elasticsearch can handle compression methods for stored data such as LZ4 and best_compression.
|
data/README.md
CHANGED
@@ -171,6 +171,24 @@ You can specify Elasticsearch host by this parameter.
|
|
171
171
|
|
172
172
|
**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.
|
173
173
|
|
174
|
+
To use IPv6 address on `host` parameter, you can use the following styles:
|
175
|
+
|
176
|
+
#### string style
|
177
|
+
|
178
|
+
To use string style, you must quote IPv6 address due to prevent to be interpreted as JSON:
|
179
|
+
|
180
|
+
```
|
181
|
+
host "[2404:7a80:d440:3000:192a:a292:bd7f:ca10]"
|
182
|
+
```
|
183
|
+
|
184
|
+
#### raw style
|
185
|
+
|
186
|
+
You can also specify raw IPv6 address. This will be handled as `[specified IPv6 address]`:
|
187
|
+
|
188
|
+
```
|
189
|
+
host 2404:7a80:d440:3000:192a:a292:bd7f:ca10
|
190
|
+
```
|
191
|
+
|
174
192
|
### port
|
175
193
|
|
176
194
|
```
|
@@ -237,6 +255,16 @@ hosts host1:port1,host2:port2,host3 # port3 is 9200
|
|
237
255
|
|
238
256
|
**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.
|
239
257
|
|
258
|
+
#### IPv6 addresses
|
259
|
+
|
260
|
+
When you want to specify IPv6 addresses, you must specify schema together:
|
261
|
+
|
262
|
+
```
|
263
|
+
hosts http://[2404:7a80:d440:3000:de:7311:6329:2e6c]:port1,http://[2404:7a80:d440:3000:de:7311:6329:1e6c]:port2,http://[2404:7a80:d440:3000:de:6311:6329:2e6c]:port3
|
264
|
+
```
|
265
|
+
|
266
|
+
If you don't specify hosts with schema together, Elasticsearch plugin complains Invalid URI for them.
|
267
|
+
|
240
268
|
### user, password, path, scheme, ssl_verify
|
241
269
|
|
242
270
|
```
|
@@ -1325,9 +1353,9 @@ Default value is `nil`.
|
|
1325
1353
|
|
1326
1354
|
Use legacy template or not.
|
1327
1355
|
|
1328
|
-
Elasticsearch 7.8 or later
|
1356
|
+
For Elasticsearch 7.8 or later, users can specify this parameter as `false` if their [template_file](#template_file) contains a composable index template.
|
1329
1357
|
|
1330
|
-
For Elasticsearch 7.7 or older, users should specify this parameter as `
|
1358
|
+
For Elasticsearch 7.7 or older, users should specify this parameter as `true`.
|
1331
1359
|
|
1332
1360
|
Composable template documentation is [Put Index Template API | Elasticsearch Reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html) and legacy template documentation is [Index Templates | Elasticsearch Reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).
|
1333
1361
|
|
@@ -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 = '5.0.
|
6
|
+
s.version = '5.0.3'
|
7
7
|
s.authors = ['diogo', 'pitr', 'Hiroshi Hatake']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com', 'cosmo0920.wp@gmail.com']
|
9
9
|
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
require 'strptime'
|
14
14
|
rescue LoadError
|
15
15
|
end
|
16
|
+
require 'resolv'
|
16
17
|
|
17
18
|
require 'fluent/plugin/output'
|
18
19
|
require 'fluent/event'
|
@@ -668,7 +669,11 @@ EOC
|
|
668
669
|
end
|
669
670
|
end.compact
|
670
671
|
else
|
671
|
-
|
672
|
+
if Resolv::IPv6::Regex.match(@host)
|
673
|
+
[{host: "[#{@host}]", scheme: @scheme.to_s, port: @port}]
|
674
|
+
else
|
675
|
+
[{host: @host, port: @port, scheme: @scheme.to_s}]
|
676
|
+
end
|
672
677
|
end.each do |host|
|
673
678
|
host.merge!(user: @user, password: @password) if !host[:user] && @user
|
674
679
|
host.merge!(path: @path) if !host[:path] && @path
|
@@ -3612,6 +3612,74 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3612
3612
|
assert_equal '/default_path', host2[:path]
|
3613
3613
|
end
|
3614
3614
|
|
3615
|
+
class IPv6AdressStringHostsTest < self
|
3616
|
+
def test_legacy_hosts_list
|
3617
|
+
config = %{
|
3618
|
+
hosts "[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:50,host2:100,host3"
|
3619
|
+
scheme https
|
3620
|
+
path /es/
|
3621
|
+
port 123
|
3622
|
+
}
|
3623
|
+
instance = driver(config).instance
|
3624
|
+
|
3625
|
+
assert_raise(URI::InvalidURIError) do
|
3626
|
+
instance.get_connection_options[:hosts].length
|
3627
|
+
end
|
3628
|
+
end
|
3629
|
+
|
3630
|
+
def test_hosts_list
|
3631
|
+
config = %{
|
3632
|
+
hosts https://john:password@[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:443/elastic/,http://host2
|
3633
|
+
path /default_path
|
3634
|
+
user default_user
|
3635
|
+
password default_password
|
3636
|
+
}
|
3637
|
+
instance = driver(config).instance
|
3638
|
+
|
3639
|
+
assert_equal 2, instance.get_connection_options[:hosts].length
|
3640
|
+
host1, host2 = instance.get_connection_options[:hosts]
|
3641
|
+
|
3642
|
+
assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
|
3643
|
+
assert_equal 443, host1[:port]
|
3644
|
+
assert_equal 'https', host1[:scheme]
|
3645
|
+
assert_equal 'john', host1[:user]
|
3646
|
+
assert_equal 'password', host1[:password]
|
3647
|
+
assert_equal '/elastic/', host1[:path]
|
3648
|
+
|
3649
|
+
assert_equal 'host2', host2[:host]
|
3650
|
+
assert_equal 'http', host2[:scheme]
|
3651
|
+
assert_equal 'default_user', host2[:user]
|
3652
|
+
assert_equal 'default_password', host2[:password]
|
3653
|
+
assert_equal '/default_path', host2[:path]
|
3654
|
+
end
|
3655
|
+
|
3656
|
+
def test_hosts_list_with_escape_placeholders
|
3657
|
+
config = %{
|
3658
|
+
hosts https://%{j+hn}:%{passw@rd}@[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:443/elastic/,http://host2
|
3659
|
+
path /default_path
|
3660
|
+
user default_user
|
3661
|
+
password default_password
|
3662
|
+
}
|
3663
|
+
instance = driver(config).instance
|
3664
|
+
|
3665
|
+
assert_equal 2, instance.get_connection_options[:hosts].length
|
3666
|
+
host1, host2 = instance.get_connection_options[:hosts]
|
3667
|
+
|
3668
|
+
assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
|
3669
|
+
assert_equal 443, host1[:port]
|
3670
|
+
assert_equal 'https', host1[:scheme]
|
3671
|
+
assert_equal 'j%2Bhn', host1[:user]
|
3672
|
+
assert_equal 'passw%40rd', host1[:password]
|
3673
|
+
assert_equal '/elastic/', host1[:path]
|
3674
|
+
|
3675
|
+
assert_equal 'host2', host2[:host]
|
3676
|
+
assert_equal 'http', host2[:scheme]
|
3677
|
+
assert_equal 'default_user', host2[:user]
|
3678
|
+
assert_equal 'default_password', host2[:password]
|
3679
|
+
assert_equal '/default_path', host2[:path]
|
3680
|
+
end
|
3681
|
+
end
|
3682
|
+
|
3615
3683
|
def test_single_host_params_and_defaults
|
3616
3684
|
config = %{
|
3617
3685
|
host logs.google.com
|
@@ -3665,6 +3733,46 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3665
3733
|
assert(ports.none? { |p| p == 9200 })
|
3666
3734
|
end
|
3667
3735
|
|
3736
|
+
class IPv6AdressStringHostTest < self
|
3737
|
+
def test_single_host_params_and_defaults
|
3738
|
+
config = %{
|
3739
|
+
host 2404:7a80:d440:3000:192a:a292:bd7f:ca19
|
3740
|
+
user john
|
3741
|
+
password doe
|
3742
|
+
}
|
3743
|
+
instance = driver(config).instance
|
3744
|
+
|
3745
|
+
assert_equal 1, instance.get_connection_options[:hosts].length
|
3746
|
+
host1 = instance.get_connection_options[:hosts][0]
|
3747
|
+
|
3748
|
+
assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
|
3749
|
+
assert_equal 9200, host1[:port]
|
3750
|
+
assert_equal 'http', host1[:scheme]
|
3751
|
+
assert_equal 'john', host1[:user]
|
3752
|
+
assert_equal 'doe', host1[:password]
|
3753
|
+
assert_equal nil, host1[:path]
|
3754
|
+
end
|
3755
|
+
|
3756
|
+
def test_single_host_params_and_defaults_with_escape_placeholders
|
3757
|
+
config = %{
|
3758
|
+
host 2404:7a80:d440:3000:192a:a292:bd7f:ca19
|
3759
|
+
user %{j+hn}
|
3760
|
+
password %{d@e}
|
3761
|
+
}
|
3762
|
+
instance = driver(config).instance
|
3763
|
+
|
3764
|
+
assert_equal 1, instance.get_connection_options[:hosts].length
|
3765
|
+
host1 = instance.get_connection_options[:hosts][0]
|
3766
|
+
|
3767
|
+
assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
|
3768
|
+
assert_equal 9200, host1[:port]
|
3769
|
+
assert_equal 'http', host1[:scheme]
|
3770
|
+
assert_equal 'j%2Bhn', host1[:user]
|
3771
|
+
assert_equal 'd%40e', host1[:password]
|
3772
|
+
assert_equal nil, host1[:path]
|
3773
|
+
end
|
3774
|
+
end
|
3775
|
+
|
3668
3776
|
def test_password_is_required_if_specify_user
|
3669
3777
|
config = %{
|
3670
3778
|
user john
|
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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- diogo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|