fluent-plugin-elasticsearch 5.1.4 → 5.1.5
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.
- checksums.yaml +4 -4
- data/History.md +5 -0
- data/README.md +16 -1
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +31 -20
- data/test/plugin/test_out_elasticsearch_data_stream.rb +161 -24
- 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: 0ae6214f54783c402097e26276b9247f1d58866b08cdc80be47d3b4638516d54
|
4
|
+
data.tar.gz: b69af374d04f84b2b1137189916c2b78f25eae71c2294d9a0cc196c30c09db29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29173c2331bc0e533aa1d3aa66aa555bad7802e5fbb4207641b11aebc0a18c0d4e44ebed0b167c8fe4bddf403d2dd5a61349afeffecfc28a65359c3bb4cce26b
|
7
|
+
data.tar.gz: 7fdf58624182bdd4e354cad2d4f9ba001cff5a8c8c0ba02ac043607a87e2372311deb85bc0306d3aa167e98170a6049f33f3203b202ebcf25eac75e65dc23a17
|
data/History.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
### [Unreleased]
|
4
4
|
|
5
|
+
### 5.1.5
|
6
|
+
- Make retryable DataStreams creation at configure phase (#943)
|
7
|
+
- Handle @hosts parameter on data_stream plugin (#942)
|
8
|
+
- allow specifying custom ILM policies for data streams (#933)
|
9
|
+
|
5
10
|
### 5.1.4
|
6
11
|
- Handle ES8 or above more strictly (#931)
|
7
12
|
- fixing double "\_policy" in index lifecycle management policy for elasticsearch\_data\_stream output (#930)
|
data/README.md
CHANGED
@@ -1521,7 +1521,7 @@ You can enable this feature by specifying `@type elasticsearch_data_stream`.
|
|
1521
1521
|
data_stream_name test
|
1522
1522
|
```
|
1523
1523
|
|
1524
|
-
When `@type elasticsearch_data_stream` is used, unless specified with `data_stream_ilm_name` and `data_stream_template_name`, ILM default policy is set to the specified data stream.
|
1524
|
+
When `@type elasticsearch_data_stream` is used, unless specified with `data_stream_ilm_name` and `data_stream_template_name` or `data_stream_ilm_policy`, ILM default policy is set to the specified data stream.
|
1525
1525
|
Then, the matching index template is also created automatically.
|
1526
1526
|
|
1527
1527
|
### data_stream_name
|
@@ -1545,6 +1545,21 @@ There are some limitations about naming rule.
|
|
1545
1545
|
|
1546
1546
|
In more detail, please refer to the [Path parameters](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-data-stream.html#indices-create-data-stream-api-path-params).
|
1547
1547
|
|
1548
|
+
|
1549
|
+
### data_stream_ilm_policy
|
1550
|
+
|
1551
|
+
You can specify the ILM policy contents as hash. If not present, it will apply the ILM default policy.
|
1552
|
+
|
1553
|
+
**NOTE:** This parameter requests to install elasticsearch-xpack gem.
|
1554
|
+
|
1555
|
+
### data_stream_ilm_policy_overwrite
|
1556
|
+
|
1557
|
+
Specify whether the data stream ILM policy should be overwritten.
|
1558
|
+
|
1559
|
+
Default value is `false`.
|
1560
|
+
|
1561
|
+
**NOTE:** This parameter requests to install elasticsearch-xpack gem.
|
1562
|
+
|
1548
1563
|
## Troubleshooting
|
1549
1564
|
|
1550
1565
|
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.1.
|
6
|
+
s.version = '5.1.5'
|
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}
|
@@ -11,6 +11,9 @@ module Fluent::Plugin
|
|
11
11
|
config_param :data_stream_name, :string
|
12
12
|
config_param :data_stream_ilm_name, :string, :default => nil
|
13
13
|
config_param :data_stream_template_name, :string, :default => nil
|
14
|
+
config_param :data_stream_ilm_policy, :string, :default => nil
|
15
|
+
config_param :data_stream_ilm_policy_overwrite, :bool, :default => false
|
16
|
+
|
14
17
|
# Elasticsearch 7.9 or later always support new style of index template.
|
15
18
|
config_set_default :use_legacy_template, false
|
16
19
|
|
@@ -29,6 +32,7 @@ module Fluent::Plugin
|
|
29
32
|
|
30
33
|
@data_stream_ilm_name = "#{@data_stream_name}_policy" if @data_stream_ilm_name.nil?
|
31
34
|
@data_stream_template_name = "#{@data_stream_name}_template" if @data_stream_template_name.nil?
|
35
|
+
@data_stream_ilm_policy = File.read(File.join(File.dirname(__FILE__), "default-ilm-policy.json")) if @data_stream_ilm_policy.nil?
|
32
36
|
|
33
37
|
# ref. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-data-stream.html
|
34
38
|
unless placeholder?(:data_stream_name_placeholder, @data_stream_name)
|
@@ -38,13 +42,16 @@ module Fluent::Plugin
|
|
38
42
|
@data_stream_names = []
|
39
43
|
end
|
40
44
|
|
41
|
-
@client = client
|
42
45
|
unless @use_placeholder
|
43
46
|
begin
|
44
47
|
@data_stream_names = [@data_stream_name]
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
retry_operate(@max_retry_putting_template,
|
49
|
+
@fail_on_putting_template_retry_exceed,
|
50
|
+
@catch_transport_exception_on_retry) do
|
51
|
+
create_ilm_policy(@data_stream_name, @data_stream_template_name, @data_stream_ilm_name)
|
52
|
+
create_index_template(@data_stream_name, @data_stream_template_name, @data_stream_ilm_name)
|
53
|
+
create_data_stream(@data_stream_name)
|
54
|
+
end
|
48
55
|
rescue => e
|
49
56
|
raise Fluent::ConfigError, "Failed to create data stream: <#{@data_stream_name}> #{e.message}"
|
50
57
|
end
|
@@ -76,21 +83,24 @@ module Fluent::Plugin
|
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
79
|
-
def create_ilm_policy(datastream_name, template_name, ilm_name, host)
|
80
|
-
|
86
|
+
def create_ilm_policy(datastream_name, template_name, ilm_name, host = nil)
|
87
|
+
unless @data_stream_ilm_policy_overwrite
|
88
|
+
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host) or ilm_policy_exists?(ilm_name, host)
|
89
|
+
end
|
90
|
+
|
81
91
|
params = {
|
82
92
|
policy_id: ilm_name,
|
83
|
-
body:
|
93
|
+
body: @data_stream_ilm_policy
|
84
94
|
}
|
85
95
|
retry_operate(@max_retry_putting_template,
|
86
96
|
@fail_on_putting_template_retry_exceed,
|
87
97
|
@catch_transport_exception_on_retry) do
|
88
|
-
|
98
|
+
client(host).xpack.ilm.put_policy(params)
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
92
|
-
def create_index_template(datastream_name, template_name, ilm_name, host)
|
93
|
-
return if data_stream_exist?(datastream_name) or template_exists?(template_name, host)
|
102
|
+
def create_index_template(datastream_name, template_name, ilm_name, host = nil)
|
103
|
+
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
|
94
104
|
body = {
|
95
105
|
"index_patterns" => ["#{datastream_name}*"],
|
96
106
|
"data_stream" => {},
|
@@ -107,16 +117,16 @@ module Fluent::Plugin
|
|
107
117
|
retry_operate(@max_retry_putting_template,
|
108
118
|
@fail_on_putting_template_retry_exceed,
|
109
119
|
@catch_transport_exception_on_retry) do
|
110
|
-
|
120
|
+
client(host).indices.put_index_template(params)
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
114
|
-
def data_stream_exist?(datastream_name)
|
124
|
+
def data_stream_exist?(datastream_name, host = nil)
|
115
125
|
params = {
|
116
126
|
name: datastream_name
|
117
127
|
}
|
118
128
|
begin
|
119
|
-
response =
|
129
|
+
response = client(host).indices.get_data_stream(params)
|
120
130
|
return (not response.is_a?(Elasticsearch::Transport::Transport::Errors::NotFound))
|
121
131
|
rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
|
122
132
|
log.info "Specified data stream does not exist. Will be created: <#{e}>"
|
@@ -124,21 +134,21 @@ module Fluent::Plugin
|
|
124
134
|
end
|
125
135
|
end
|
126
136
|
|
127
|
-
def create_data_stream(datastream_name)
|
128
|
-
return if data_stream_exist?(datastream_name)
|
137
|
+
def create_data_stream(datastream_name, host = nil)
|
138
|
+
return if data_stream_exist?(datastream_name, host)
|
129
139
|
params = {
|
130
140
|
name: datastream_name
|
131
141
|
}
|
132
142
|
retry_operate(@max_retry_putting_template,
|
133
143
|
@fail_on_putting_template_retry_exceed,
|
134
144
|
@catch_transport_exception_on_retry) do
|
135
|
-
|
145
|
+
client(host).indices.create_data_stream(params)
|
136
146
|
end
|
137
147
|
end
|
138
148
|
|
139
|
-
def ilm_policy_exists?(policy_id)
|
149
|
+
def ilm_policy_exists?(policy_id, host = nil)
|
140
150
|
begin
|
141
|
-
|
151
|
+
client(host).ilm.get_policy(policy_id: policy_id)
|
142
152
|
true
|
143
153
|
rescue
|
144
154
|
false
|
@@ -192,8 +202,9 @@ module Fluent::Plugin
|
|
192
202
|
data_stream_name = @data_stream_name
|
193
203
|
data_stream_template_name = @data_stream_template_name
|
194
204
|
data_stream_ilm_name = @data_stream_ilm_name
|
195
|
-
host =
|
205
|
+
host = nil
|
196
206
|
if @use_placeholder
|
207
|
+
host = extract_placeholders(@host, chunk)
|
197
208
|
data_stream_name = extract_placeholders(@data_stream_name, chunk)
|
198
209
|
data_stream_template_name = extract_placeholders(@data_stream_template_name, chunk)
|
199
210
|
data_stream_ilm_name = extract_placeholders(@data_stream_ilm_name, chunk)
|
@@ -230,7 +241,7 @@ module Fluent::Plugin
|
|
230
241
|
body: bulk_message
|
231
242
|
}
|
232
243
|
begin
|
233
|
-
response =
|
244
|
+
response = client(host).bulk(params)
|
234
245
|
if response['errors']
|
235
246
|
log.error "Could not bulk insert to Data Stream: #{data_stream_name} #{response}"
|
236
247
|
end
|
@@ -62,56 +62,61 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
62
62
|
DUPLICATED_DATA_STREAM_EXCEPTION = {"error": {}, "status": 400}
|
63
63
|
NONEXISTENT_DATA_STREAM_EXCEPTION = {"error": {}, "status": 404}
|
64
64
|
|
65
|
-
def stub_ilm_policy(name="foo_ilm_policy")
|
66
|
-
stub_request(:put, "
|
65
|
+
def stub_ilm_policy(name="foo_ilm_policy", url="http://localhost:9200")
|
66
|
+
stub_request(:put, "#{url}/_ilm/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
67
67
|
end
|
68
68
|
|
69
|
-
def stub_index_template(name="foo_tpl")
|
70
|
-
stub_request(:put, "
|
69
|
+
def stub_index_template(name="foo_tpl", url="http://localhost:9200")
|
70
|
+
stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
71
71
|
end
|
72
72
|
|
73
|
-
def stub_data_stream(name="foo")
|
74
|
-
stub_request(:put, "
|
73
|
+
def stub_data_stream(name="foo", url="http://localhost:9200")
|
74
|
+
stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
75
75
|
end
|
76
76
|
|
77
|
-
def stub_existent_data_stream?(name="foo")
|
78
|
-
stub_request(:get, "
|
77
|
+
def stub_existent_data_stream?(name="foo", url="http://localhost:9200")
|
78
|
+
stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
79
79
|
end
|
80
80
|
|
81
|
-
def stub_existent_ilm?(name="foo_ilm_policy")
|
82
|
-
stub_request(:get, "
|
81
|
+
def stub_existent_ilm?(name="foo_ilm_policy", url="http://localhost:9200")
|
82
|
+
stub_request(:get, "#{url}/_ilm/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
83
83
|
end
|
84
84
|
|
85
|
-
def stub_existent_template?(name="foo_tpl")
|
86
|
-
stub_request(:get, "
|
85
|
+
def stub_existent_template?(name="foo_tpl", url="http://localhost:9200")
|
86
|
+
stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED])
|
87
87
|
end
|
88
88
|
|
89
|
-
def stub_nonexistent_data_stream?(name="foo")
|
90
|
-
stub_request(:get, "
|
89
|
+
def stub_nonexistent_data_stream?(name="foo", url="http://localhost:9200")
|
90
|
+
stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, Elasticsearch::Transport::Transport::Errors::NotFound])
|
91
91
|
end
|
92
92
|
|
93
|
-
def stub_nonexistent_ilm?(name="foo_ilm_policy")
|
94
|
-
stub_request(:get, "
|
93
|
+
def stub_nonexistent_ilm?(name="foo_ilm_policy", url="http://localhost:9200")
|
94
|
+
stub_request(:get, "#{url}/_ilm/policy/#{name}").to_return(:status => [404, Elasticsearch::Transport::Transport::Errors::NotFound])
|
95
95
|
end
|
96
96
|
|
97
|
-
def stub_nonexistent_template?(name="foo_tpl")
|
98
|
-
stub_request(:get, "
|
97
|
+
def stub_nonexistent_template?(name="foo_tpl", url="http://localhost:9200")
|
98
|
+
stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, Elasticsearch::Transport::Transport::Errors::NotFound])
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
102
|
-
stub_request(:
|
101
|
+
def stub_nonexistent_template_retry?(name="foo_tpl", url="http://localhost:9200")
|
102
|
+
stub_request(:get, "#{url}/_index_template/#{name}").
|
103
|
+
to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}' })
|
104
|
+
end
|
105
|
+
|
106
|
+
def stub_bulk_feed(datastream_name="foo", ilm_name="foo_ilm_policy", template_name="foo_tpl", url="http://localhost:9200")
|
107
|
+
stub_request(:post, "#{url}/#{datastream_name}/_bulk").with do |req|
|
103
108
|
# bulk data must be pair of OP and records
|
104
109
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
105
110
|
# {"@timestamp": ...}
|
106
111
|
@bulk_records += req.body.split("\n").size / 2
|
107
112
|
end
|
108
|
-
stub_request(:post, "
|
113
|
+
stub_request(:post, "#{url}/#{ilm_name}/_bulk").with do |req|
|
109
114
|
# bulk data must be pair of OP and records
|
110
115
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
111
116
|
# {"@timestamp": ...}
|
112
117
|
@bulk_records += req.body.split("\n").size / 2
|
113
118
|
end
|
114
|
-
stub_request(:post, "
|
119
|
+
stub_request(:post, "#{url}/#{template_name}/_bulk").with do |req|
|
115
120
|
# bulk data must be pair of OP and records
|
116
121
|
# {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar
|
117
122
|
# {"@timestamp": ...}
|
@@ -119,9 +124,9 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
119
124
|
end
|
120
125
|
end
|
121
126
|
|
122
|
-
def stub_elastic_info(url="http://localhost:9200/", version="7.9.0")
|
127
|
+
def stub_elastic_info(url="http://localhost:9200/", version="7.9.0", headers={})
|
123
128
|
body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
|
124
|
-
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json' } })
|
129
|
+
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json' }.merge(headers) })
|
125
130
|
end
|
126
131
|
|
127
132
|
def stub_default(datastream_name="foo", ilm_name="foo_ilm_policy", template_name="foo_tpl", host="http://localhost:9200")
|
@@ -437,6 +442,56 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
437
442
|
assert_equal "foo", driver(conf).instance.data_stream_name
|
438
443
|
end
|
439
444
|
|
445
|
+
def test_datastream_configure_retry
|
446
|
+
stub_elastic_info
|
447
|
+
stub_nonexistent_ilm?
|
448
|
+
stub_ilm_policy
|
449
|
+
stub_nonexistent_template_retry?
|
450
|
+
stub_index_template
|
451
|
+
stub_nonexistent_data_stream?
|
452
|
+
stub_data_stream
|
453
|
+
conf = config_element(
|
454
|
+
'ROOT', '', {
|
455
|
+
'@type' => ELASTIC_DATA_STREAM_TYPE,
|
456
|
+
'data_stream_name' => 'foo',
|
457
|
+
'data_stream_ilm_name' => "foo_ilm_policy",
|
458
|
+
'data_stream_template_name' => "foo_tpl"
|
459
|
+
})
|
460
|
+
assert_equal "foo", driver(conf).instance.data_stream_name
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_hosts_list_configure
|
464
|
+
config = %{
|
465
|
+
hosts https://john:password@host1:443/elastic/,http://host2
|
466
|
+
path /default_path
|
467
|
+
user default_user
|
468
|
+
password default_password
|
469
|
+
data_stream_name default
|
470
|
+
}
|
471
|
+
stub_elastic_info("https://host1:443/elastic//", "7.9.0",
|
472
|
+
{'Authorization'=>"Basic #{Base64.encode64('john:password').split.first}"})
|
473
|
+
stub_elastic_info("http://host2/default_path/_data_stream/default", "7.9.0",
|
474
|
+
{'Authorization'=>"Basic #{Base64.encode64('john:password').split.first}"})
|
475
|
+
stub_existent_data_stream?("default", "https://host1/elastic/")
|
476
|
+
instance = driver(config).instance
|
477
|
+
|
478
|
+
assert_equal 2, instance.get_connection_options[:hosts].length
|
479
|
+
host1, host2 = instance.get_connection_options[:hosts]
|
480
|
+
|
481
|
+
assert_equal 'host1', host1[:host]
|
482
|
+
assert_equal 443, host1[:port]
|
483
|
+
assert_equal 'https', host1[:scheme]
|
484
|
+
assert_equal 'john', host1[:user]
|
485
|
+
assert_equal 'password', host1[:password]
|
486
|
+
assert_equal '/elastic/', host1[:path]
|
487
|
+
|
488
|
+
assert_equal 'host2', host2[:host]
|
489
|
+
assert_equal 'http', host2[:scheme]
|
490
|
+
assert_equal 'default_user', host2[:user]
|
491
|
+
assert_equal 'default_password', host2[:password]
|
492
|
+
assert_equal '/default_path', host2[:path]
|
493
|
+
end
|
494
|
+
|
440
495
|
def test_existent_data_stream
|
441
496
|
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
442
497
|
|
@@ -659,4 +714,86 @@ class ElasticsearchOutputDataStreamTest < Test::Unit::TestCase
|
|
659
714
|
|
660
715
|
assert_equal(4, connection_resets)
|
661
716
|
end
|
717
|
+
|
718
|
+
def test_doesnt_update_ilm_policy_if_overwrite_unset
|
719
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
720
|
+
|
721
|
+
config = %{
|
722
|
+
data_stream_name foo
|
723
|
+
data_stream_ilm_name foo_ilm_policy
|
724
|
+
data_stream_ilm_policy {"policy":{"phases":{"hot":{"actions":{"rollover":{"max_age":"15d"}}}}}}
|
725
|
+
}
|
726
|
+
|
727
|
+
stub_elastic_info
|
728
|
+
stub_index_template
|
729
|
+
stub_existent_data_stream?
|
730
|
+
stub_existent_ilm?
|
731
|
+
stub_data_stream
|
732
|
+
|
733
|
+
stub_request(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy").
|
734
|
+
to_return(:status => 200, :body => "", :headers => {})
|
735
|
+
|
736
|
+
assert_nothing_raised {
|
737
|
+
driver(config)
|
738
|
+
}
|
739
|
+
assert_requested(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy", times: 0)
|
740
|
+
end
|
741
|
+
|
742
|
+
def test_updates_ilm_policy_if_overwrite_set
|
743
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
744
|
+
|
745
|
+
config = %{
|
746
|
+
data_stream_name foo
|
747
|
+
data_stream_ilm_name foo_ilm_policy
|
748
|
+
data_stream_ilm_policy {"policy":{"phases":{"hot":{"actions":{"rollover":{"max_age":"15d"}}}}}}
|
749
|
+
data_stream_ilm_policy_overwrite true
|
750
|
+
}
|
751
|
+
|
752
|
+
stub_elastic_info
|
753
|
+
stub_index_template
|
754
|
+
stub_existent_data_stream?
|
755
|
+
stub_existent_ilm?
|
756
|
+
stub_data_stream
|
757
|
+
|
758
|
+
stub_request(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy").
|
759
|
+
to_return(:status => 200, :body => "", :headers => {})
|
760
|
+
|
761
|
+
assert_nothing_raised {
|
762
|
+
driver(config)
|
763
|
+
}
|
764
|
+
|
765
|
+
assert_requested(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy", times: 1)
|
766
|
+
assert_requested(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy",
|
767
|
+
body: '{"policy":{"phases":{"hot":{"actions":{"rollover":{"max_age":"15d"}}}}}}',
|
768
|
+
times: 1)
|
769
|
+
end
|
770
|
+
|
771
|
+
def test_creates_custom_ilm_policy_if_none_exists
|
772
|
+
omit REQUIRED_ELASTIC_MESSAGE unless data_stream_supported?
|
773
|
+
|
774
|
+
config = %{
|
775
|
+
data_stream_name foo
|
776
|
+
data_stream_ilm_name foo_ilm_policy
|
777
|
+
data_stream_ilm_policy {"policy":{"phases":{"hot":{"actions":{"rollover":{"max_age":"15d"}}}}}}
|
778
|
+
}
|
779
|
+
|
780
|
+
stub_elastic_info
|
781
|
+
stub_index_template("foo_template")
|
782
|
+
stub_data_stream
|
783
|
+
stub_nonexistent_data_stream?
|
784
|
+
stub_nonexistent_ilm?
|
785
|
+
stub_nonexistent_template?("foo_template")
|
786
|
+
|
787
|
+
stub_request(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy").
|
788
|
+
to_return(:status => 200, :body => "", :headers => {})
|
789
|
+
|
790
|
+
assert_nothing_raised {
|
791
|
+
driver(config)
|
792
|
+
}
|
793
|
+
|
794
|
+
assert_requested(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy", times: 1)
|
795
|
+
assert_requested(:put, "http://localhost:9200/_ilm/policy/foo_ilm_policy",
|
796
|
+
body: '{"policy":{"phases":{"hot":{"actions":{"rollover":{"max_age":"15d"}}}}}}',
|
797
|
+
times: 1)
|
798
|
+
end
|
662
799
|
end
|
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.1.
|
4
|
+
version: 5.1.5
|
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: 2022-02-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|