fluent-plugin-elasticsearch 5.4.2 → 5.4.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 +4 -1
- data/README.md +44 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +3 -1
- data/test/plugin/test_out_elasticsearch_data_stream.rb +87 -2
- 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: 542a7706becd1b24f8d3e6ad8957015dba5f721b3a93047ec4bea80313df8200
|
4
|
+
data.tar.gz: 8104645d96578abf0f4357a22c83a7f9cbc548e7bbc35ef5eeb8726deaada6f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a2a932a766170b197f3ded762c89912f743cec3ddcef3e7719d8ca57b504f6f7b51bc17bac02ef5073fd1fade3366140a7d775351c8b86b1f05693a76be122
|
7
|
+
data.tar.gz: 35b82c172909a1f47dc74507c7ea9df451576b9cb1c8dcba85fdb094b3568b2187aafa1aecbd3367ef2ab0a347a30f90d8b663780e3261bdefc5dcb2b24f0133
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -1561,6 +1561,50 @@ Default value is `false`.
|
|
1561
1561
|
|
1562
1562
|
**NOTE:** This parameter requests to install elasticsearch-xpack gem.
|
1563
1563
|
|
1564
|
+
### data_stream_template_use_index_patterns_wildcard
|
1565
|
+
|
1566
|
+
Specify whether index patterns should include a wildcard (*) when creating an index template. This is particularly useful to prevent errors in scenarios where index templates are generated automatically, and multiple services with distinct suffixes are in use.
|
1567
|
+
|
1568
|
+
Default value is `true`.
|
1569
|
+
|
1570
|
+
Consider the following JSON error response when index patterns clash due to wildcard usage:
|
1571
|
+
```json
|
1572
|
+
{
|
1573
|
+
"error": {
|
1574
|
+
"root_cause": [
|
1575
|
+
{
|
1576
|
+
"type": "illegal_argument_exception",
|
1577
|
+
"reason": "index template [eks-kube-apiserver] has index patterns [eks-kube-apiserver*] matching patterns from existing templates [eks-kube-apiserver-audit] with patterns (eks-kube-apiserver-audit => [eks-kube-apiserver-audit*]) that have the same priority [0], multiple index templates may not match during index creation, please use a different priority"
|
1578
|
+
}
|
1579
|
+
],
|
1580
|
+
"type": "illegal_argument_exception",
|
1581
|
+
"reason": "index template [eks-kube-apiserver] has index patterns [eks-kube-apiserver*] matching patterns from existing templates [eks-kube-apiserver-audit] with patterns (eks-kube-apiserver-audit => [eks-kube-apiserver-audit*]) that have the same priority [0], multiple index templates may not match during index creation, please use a different priority"
|
1582
|
+
},
|
1583
|
+
"status": 400
|
1584
|
+
}
|
1585
|
+
```
|
1586
|
+
|
1587
|
+
#### Usage Examples
|
1588
|
+
|
1589
|
+
When `data_stream_template_use_index_patterns_wildcard` is set to `true` (default):
|
1590
|
+
|
1591
|
+
```
|
1592
|
+
data_stream_name: foo
|
1593
|
+
data_stream_template_use_index_patterns_wildcard: true
|
1594
|
+
```
|
1595
|
+
|
1596
|
+
In this case, the resulting index patterns will be: `["foo*"]`
|
1597
|
+
|
1598
|
+
When `data_stream_template_use_index_patterns_wildcard` is set to `false`:
|
1599
|
+
|
1600
|
+
```
|
1601
|
+
data_stream_name: foo
|
1602
|
+
data_stream_template_use_index_patterns_wildcard: false
|
1603
|
+
```
|
1604
|
+
|
1605
|
+
The resulting index patterns will be: `["foo"]`
|
1606
|
+
|
1607
|
+
|
1564
1608
|
## Troubleshooting
|
1565
1609
|
|
1566
1610
|
See [Troubleshooting document](README.Troubleshooting.md)
|
@@ -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.4.
|
6
|
+
s.version = '5.4.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 @@ module Fluent::Plugin
|
|
13
13
|
config_param :data_stream_template_name, :string, :default => nil
|
14
14
|
config_param :data_stream_ilm_policy, :string, :default => nil
|
15
15
|
config_param :data_stream_ilm_policy_overwrite, :bool, :default => false
|
16
|
+
config_param :data_stream_template_use_index_patterns_wildcard, :bool, :default => true
|
16
17
|
|
17
18
|
# Elasticsearch 7.9 or later always support new style of index template.
|
18
19
|
config_set_default :use_legacy_template, false
|
@@ -112,8 +113,9 @@ module Fluent::Plugin
|
|
112
113
|
|
113
114
|
def create_index_template(datastream_name, template_name, ilm_name, host = nil)
|
114
115
|
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
|
116
|
+
wildcard = @data_stream_template_use_index_patterns_wildcard ? '*' : ''
|
115
117
|
body = {
|
116
|
-
"index_patterns" => ["#{datastream_name}
|
118
|
+
"index_patterns" => ["#{datastream_name}#{wildcard}"],
|
117
119
|
"data_stream" => {},
|
118
120
|
"template" => {
|
119
121
|
"settings" => {
|
@@ -34,6 +34,10 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
34
34
|
'_ilm'.freeze
|
35
35
|
end
|
36
36
|
|
37
|
+
def index_template_endpoint
|
38
|
+
'_index_template'.freeze
|
39
|
+
end
|
40
|
+
|
37
41
|
def driver(conf='', es_version=elasticsearch_version.to_i, client_version=elasticsearch_version)
|
38
42
|
# For request stub to detect compatibility.
|
39
43
|
@es_version ||= es_version
|
@@ -124,7 +128,6 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
124
128
|
stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'})
|
125
129
|
end
|
126
130
|
|
127
|
-
|
128
131
|
def push_bulk_request(req_body)
|
129
132
|
# bulk data must be pair of OP and records
|
130
133
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
@@ -486,7 +489,8 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
486
489
|
'@type' => ELASTIC_DATA_STREAM_TYPE,
|
487
490
|
'data_stream_name' => 'foo',
|
488
491
|
'data_stream_ilm_name' => "foo_ilm_policy",
|
489
|
-
'data_stream_template_name' => "foo_tpl"
|
492
|
+
'data_stream_template_name' => "foo_tpl",
|
493
|
+
'data_stream_template_use_index_patterns_wildcard' => false
|
490
494
|
})
|
491
495
|
assert_equal "foo", driver(conf).instance.data_stream_name
|
492
496
|
end
|
@@ -556,6 +560,21 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
556
560
|
assert_equal true, driver(config).instance.compression
|
557
561
|
end
|
558
562
|
|
563
|
+
def test_configure_wildcard_usage
|
564
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
565
|
+
|
566
|
+
config = %{
|
567
|
+
data_stream_name foo
|
568
|
+
data_stream_template_name foo_tpl
|
569
|
+
data_stream_ilm_name foo_ilm_policy
|
570
|
+
data_stream_template_use_index_patterns_wildcard false
|
571
|
+
}
|
572
|
+
|
573
|
+
stub_default
|
574
|
+
|
575
|
+
assert_equal false, driver(config).instance.data_stream_template_use_index_patterns_wildcard
|
576
|
+
end
|
577
|
+
|
559
578
|
def test_check_compression_strategy
|
560
579
|
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
561
580
|
|
@@ -722,6 +741,72 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
722
741
|
assert_equal "foo_policy", driver(conf).instance.data_stream_ilm_name
|
723
742
|
end
|
724
743
|
|
744
|
+
def test_template_index_patterns_with_wildcard
|
745
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
746
|
+
|
747
|
+
stub_existent_ilm?
|
748
|
+
|
749
|
+
stub_nonexistent_data_stream?
|
750
|
+
stub_data_stream
|
751
|
+
|
752
|
+
stub_nonexistent_template?("foo_template")
|
753
|
+
stub_request(:put, "http://localhost:9200/#{index_template_endpoint}/foo_template").with do |req|
|
754
|
+
# bulk data must be pair of OP and records
|
755
|
+
# {"create": {}}\nhttp://localhost:9200/_index_template//foo_template
|
756
|
+
# {"@timestamp": ...}
|
757
|
+
push_bulk_request(req.body)
|
758
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
759
|
+
|
760
|
+
conf = config_element(
|
761
|
+
'ROOT', '', {
|
762
|
+
'@type' => ELASTIC_DATA_STREAM_TYPE,
|
763
|
+
'data_stream_name' => 'foo',
|
764
|
+
'data_stream_ilm_name' => 'foo_ilm_policy',
|
765
|
+
'data_stream_template_use_index_patterns_wildcard' => false
|
766
|
+
})
|
767
|
+
|
768
|
+
assert_nothing_raised {
|
769
|
+
driver(conf)
|
770
|
+
}
|
771
|
+
|
772
|
+
assert_requested(:put, "http://localhost:9200/#{index_template_endpoint}/foo_template",
|
773
|
+
body: '{"index_patterns":["foo"],"data_stream":{},"template":{"settings":{"index.lifecycle.name":"foo_ilm_policy"}}}',
|
774
|
+
times: 1)
|
775
|
+
end
|
776
|
+
|
777
|
+
def test_template_index_patterns_without_wildcard
|
778
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
779
|
+
|
780
|
+
stub_existent_ilm?
|
781
|
+
|
782
|
+
stub_nonexistent_data_stream?
|
783
|
+
stub_data_stream
|
784
|
+
|
785
|
+
stub_nonexistent_template?("foo_template")
|
786
|
+
stub_request(:put, "http://localhost:9200/#{index_template_endpoint}/foo_template").with do |req|
|
787
|
+
# bulk data must be pair of OP and records
|
788
|
+
# {"create": {}}\nhttp://localhost:9200/_index_template//foo_template
|
789
|
+
# {"@timestamp": ...}
|
790
|
+
push_bulk_request(req.body)
|
791
|
+
end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
792
|
+
|
793
|
+
conf = config_element(
|
794
|
+
'ROOT', '', {
|
795
|
+
'@type' => ELASTIC_DATA_STREAM_TYPE,
|
796
|
+
'data_stream_name' => 'foo',
|
797
|
+
'data_stream_ilm_name' => 'foo_ilm_policy',
|
798
|
+
'data_stream_template_use_index_patterns_wildcard' => true
|
799
|
+
})
|
800
|
+
|
801
|
+
assert_nothing_raised {
|
802
|
+
driver(conf)
|
803
|
+
}
|
804
|
+
|
805
|
+
assert_requested(:put, "http://localhost:9200/#{index_template_endpoint}/foo_template",
|
806
|
+
body: '{"index_patterns":["foo*"],"data_stream":{},"template":{"settings":{"index.lifecycle.name":"foo_ilm_policy"}}}',
|
807
|
+
times: 1)
|
808
|
+
end
|
809
|
+
|
725
810
|
def test_placeholder
|
726
811
|
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
727
812
|
|
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.4.
|
4
|
+
version: 5.4.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:
|
13
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|