fluent-plugin-elasticsearch 4.1.0 → 4.1.1
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 +3 -0
- data/README.md +37 -9
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_index_template.rb +19 -11
- data/lib/fluent/plugin/out_elasticsearch.rb +10 -10
- data/test/plugin/test_out_elasticsearch.rb +23 -105
- 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: 616365bcf32cc6d302718907d145639cbb4786b33cb8a837da24f3934cf7a837
|
4
|
+
data.tar.gz: 77df51b64aa07d12b57b82a093f4a5b8cbd1c1bf9c5c82384163118c050c68cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae68cc2f0a2abbf7cf7a4c11a9bb5dac9a9e09ba9c053109748c671acd304198b45ad949782691a28eadb418e15bc66f1ef16897f810c5f0b5dd0ce04dd7913e
|
7
|
+
data.tar.gz: 484df0670840045d6c55bd1971142cf13a2a0c35cefc0ff96ada3259404d08529d97adbdd736bf9eaf99ad84c51d2124af1d0160c35042a736c875eef8aa5f3c
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -479,6 +479,8 @@ deflector_alias test-current
|
|
479
479
|
|
480
480
|
If [rollover_index](#rollover_index) is set, then this parameter will be in effect otherwise ignored.
|
481
481
|
|
482
|
+
**NOTE:** Since 4.1.1, `deflector_alias` is prohibited to use with `enable_ilm`.
|
483
|
+
|
482
484
|
### index_prefix
|
483
485
|
|
484
486
|
This parameter is marked as obsoleted.
|
@@ -988,9 +990,28 @@ sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
|
|
988
990
|
reload_after 100
|
989
991
|
```
|
990
992
|
|
993
|
+
#### Tips
|
994
|
+
|
995
|
+
The included sniffer class is not required `out_elasticsearch`.
|
996
|
+
You should tell Fluentd where the sniffer class exists.
|
997
|
+
|
998
|
+
If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
|
999
|
+
|
1000
|
+
```
|
1001
|
+
sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
|
1002
|
+
TD_AGENT_OPTIONS="--use-v1-config -r $sniffer"
|
1003
|
+
```
|
1004
|
+
|
1005
|
+
If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
|
1006
|
+
|
1007
|
+
```
|
1008
|
+
sniffer=$(td-agent-gem contents fluent-plugin-elasticsearch|grep elasticsearch_simple_sniffer.rb)
|
1009
|
+
$ fluentd -r $sniffer [AND YOUR OTHER OPTIONS]
|
1010
|
+
```
|
1011
|
+
|
991
1012
|
### Selector Class Name
|
992
1013
|
|
993
|
-
The default selector used by the `Elasticsearch::Transport` class works well when Fluentd should round robin and random selector cases. This doesn't work well when Fluentd should
|
1014
|
+
The default selector used by the `Elasticsearch::Transport` class works well when Fluentd should behave round robin and random selector cases. This doesn't work well when Fluentd should behave fallbacking from exhausted ES cluster to normal ES cluster.
|
994
1015
|
The parameter `selector_class_name` gives you the ability to provide your own Selector class to implement whatever selection nodes logic you require.
|
995
1016
|
|
996
1017
|
The below configuration is using plugin built-in `ElasticseatchFallbackSelector`:
|
@@ -1002,21 +1023,22 @@ selector_class_name "Fluent::Plugin::ElasticseatchFallbackSelector"
|
|
1002
1023
|
|
1003
1024
|
#### Tips
|
1004
1025
|
|
1005
|
-
The included
|
1006
|
-
|
1026
|
+
The included selector class is required in `out_elasticsearch` by default.
|
1027
|
+
But, your custom selector class is not required in `out_elasticsearch`.
|
1028
|
+
You should tell Fluentd where the selector class exists.
|
1007
1029
|
|
1008
1030
|
If you use td-agent, you must put the following lines into `TD_AGENT_DEFAULT` file:
|
1009
1031
|
|
1010
1032
|
```
|
1011
|
-
|
1012
|
-
TD_AGENT_OPTIONS="--use-v1-config -r $
|
1033
|
+
selector=/path/to/your_awesome_selector.rb
|
1034
|
+
TD_AGENT_OPTIONS="--use-v1-config -r $selector"
|
1013
1035
|
```
|
1014
1036
|
|
1015
1037
|
If you use Fluentd directly, you must pass the following lines as Fluentd command line option:
|
1016
1038
|
|
1017
1039
|
```
|
1018
|
-
|
1019
|
-
$ fluentd -r $
|
1040
|
+
selector=/path/to/your_awesome_selector.rb
|
1041
|
+
$ fluentd -r $selector [AND YOUR OTHER OPTIONS]
|
1020
1042
|
```
|
1021
1043
|
|
1022
1044
|
### Reload After
|
@@ -1733,7 +1755,7 @@ ILM target index alias is created with `index_name` or an index which is calcula
|
|
1733
1755
|
|
1734
1756
|
From Elasticsearch plugin v4.0.0, ILM target index will be calculated from `index_name` (normal mode) or `logstash_prefix` (using with `logstash_format`as true).
|
1735
1757
|
|
1736
|
-
|
1758
|
+
**NOTE:** Before Elasticsearch plugin v4.1.0, using `deflector_alias` parameter when ILM is enabled is permitted and handled, but, in the later releases such that 4.1.1 or later, it cannot use with when ILM is enabled.
|
1737
1759
|
|
1738
1760
|
And also, ILM feature users should specify their Elasticsearch template for ILM enabled indices.
|
1739
1761
|
Because ILM settings are injected into their Elasticsearch templates.
|
@@ -1746,7 +1768,13 @@ It usually should be used with default value which is `default`.
|
|
1746
1768
|
|
1747
1769
|
Then, ILM parameters are used in alias index like as:
|
1748
1770
|
|
1749
|
-
|
1771
|
+
##### Simple `index_name` case:
|
1772
|
+
|
1773
|
+
`<index_name><index_separator><application_name>-000001`.
|
1774
|
+
|
1775
|
+
##### `logstash_format` as `true` case:
|
1776
|
+
|
1777
|
+
`<logstash_prefix><logstash_prefix_separator><application_name><logstash_prefix_separator><logstash_dateformat>-000001`.
|
1750
1778
|
|
1751
1779
|
#### Example ILM settings
|
1752
1780
|
|
@@ -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 = '4.1.
|
6
|
+
s.version = '4.1.1'
|
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}
|
@@ -65,11 +65,12 @@ module Fluent::ElasticsearchIndexTemplate
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil)
|
68
|
+
def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil, target_index = nil)
|
69
69
|
inject_template_name = get_template_name(enable_ilm, name, deflector_alias_name)
|
70
70
|
if overwrite
|
71
71
|
template_put(inject_template_name,
|
72
72
|
enable_ilm ? inject_ilm_settings_to_template(deflector_alias_name,
|
73
|
+
target_index,
|
73
74
|
ilm_policy_id,
|
74
75
|
get_template(template_file)) :
|
75
76
|
get_template(template_file), host)
|
@@ -80,6 +81,7 @@ module Fluent::ElasticsearchIndexTemplate
|
|
80
81
|
if !template_exists?(inject_template_name, host)
|
81
82
|
template_put(inject_template_name,
|
82
83
|
enable_ilm ? inject_ilm_settings_to_template(deflector_alias_name,
|
84
|
+
target_index,
|
83
85
|
ilm_policy_id,
|
84
86
|
get_template(template_file)) :
|
85
87
|
get_template(template_file), host)
|
@@ -89,10 +91,12 @@ module Fluent::ElasticsearchIndexTemplate
|
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
|
-
def template_custom_install(template_name, template_file, overwrite, customize_template, enable_ilm, deflector_alias_name, ilm_policy_id, host)
|
94
|
+
def template_custom_install(template_name, template_file, overwrite, customize_template, enable_ilm, deflector_alias_name, ilm_policy_id, host, target_index)
|
93
95
|
template_custom_name = get_template_name(enable_ilm, template_name, deflector_alias_name)
|
94
96
|
custom_template = if enable_ilm
|
95
|
-
inject_ilm_settings_to_template(deflector_alias_name,
|
97
|
+
inject_ilm_settings_to_template(deflector_alias_name,
|
98
|
+
target_index,
|
99
|
+
ilm_policy_id,
|
96
100
|
get_custom_template(template_file,
|
97
101
|
customize_template))
|
98
102
|
else
|
@@ -115,26 +119,30 @@ module Fluent::ElasticsearchIndexTemplate
|
|
115
119
|
enable_ilm ? deflector_alias_name : template_name
|
116
120
|
end
|
117
121
|
|
118
|
-
def inject_ilm_settings_to_template(
|
122
|
+
def inject_ilm_settings_to_template(deflector_alias, target_index, ilm_policy_id, template)
|
119
123
|
log.debug("Overwriting index patterns when Index Lifecycle Management is enabled.")
|
120
124
|
template.delete('template') if template.include?('template')
|
121
|
-
template['index_patterns'] = "#{
|
122
|
-
template['order'] = template['order'] ? template['order'] +
|
125
|
+
template['index_patterns'] = "#{target_index}-*"
|
126
|
+
template['order'] = template['order'] ? template['order'] + target_index.split('-').length : 50 + target_index.split('-').length
|
123
127
|
if template['settings'] && (template['settings']['index.lifecycle.name'] || template['settings']['index.lifecycle.rollover_alias'])
|
124
128
|
log.debug("Overwriting index lifecycle name and rollover alias when Index Lifecycle Management is enabled.")
|
125
129
|
end
|
126
|
-
template['settings'].update({ 'index.lifecycle.name' => ilm_policy_id, 'index.lifecycle.rollover_alias' =>
|
130
|
+
template['settings'].update({ 'index.lifecycle.name' => ilm_policy_id, 'index.lifecycle.rollover_alias' => deflector_alias})
|
127
131
|
template
|
128
132
|
end
|
129
133
|
|
130
|
-
def create_rollover_alias(
|
134
|
+
def create_rollover_alias(target_index, rollover_index, deflector_alias_name, app_name, index_date_pattern, index_separator, enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite, host)
|
131
135
|
# ILM request to create alias.
|
132
136
|
if rollover_index || enable_ilm
|
133
137
|
if !client.indices.exists_alias(:name => deflector_alias_name)
|
134
|
-
if
|
135
|
-
index_name_temp='<'+
|
138
|
+
if @logstash_format
|
139
|
+
index_name_temp = '<'+target_index+'-000001>'
|
136
140
|
else
|
137
|
-
|
141
|
+
if index_date_pattern.empty?
|
142
|
+
index_name_temp = '<'+target_index.downcase+index_separator+app_name.downcase+'-000001>'
|
143
|
+
else
|
144
|
+
index_name_temp = '<'+target_index.downcase+index_separator+app_name.downcase+'-{'+index_date_pattern+'}-000001>'
|
145
|
+
end
|
138
146
|
end
|
139
147
|
indexcreation(index_name_temp, host)
|
140
148
|
body = rollover_alias_payload(deflector_alias_name)
|
@@ -51,7 +51,7 @@ module Fluent::Plugin
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
RequestInfo = Struct.new(:host, :index, :ilm_index)
|
54
|
+
RequestInfo = Struct.new(:host, :index, :ilm_index, :ilm_alias)
|
55
55
|
|
56
56
|
attr_reader :alias_indexes
|
57
57
|
attr_reader :template_names
|
@@ -234,7 +234,7 @@ EOC
|
|
234
234
|
if !dry_run?
|
235
235
|
if @template_name && @template_file
|
236
236
|
if @enable_ilm
|
237
|
-
raise Fluent::ConfigError, "deflector_alias is prohibited to use with
|
237
|
+
raise Fluent::ConfigError, "deflector_alias is prohibited to use with enable_ilm at same time." if @deflector_alias
|
238
238
|
end
|
239
239
|
if @ilm_policy.empty? && @ilm_policy_overwrite
|
240
240
|
raise Fluent::ConfigError, "ilm_policy_overwrite requires a non empty ilm_policy."
|
@@ -771,9 +771,9 @@ EOC
|
|
771
771
|
begin
|
772
772
|
meta, header, record = process_message(tag, meta, header, time, record, extracted_values)
|
773
773
|
info = if @include_index_in_url
|
774
|
-
RequestInfo.new(host, meta.delete("_index".freeze), meta.delete("_alias".freeze))
|
774
|
+
RequestInfo.new(host, meta.delete("_index".freeze), meta["_index".freeze], meta.delete("_alias".freeze))
|
775
775
|
else
|
776
|
-
RequestInfo.new(host, nil, meta.delete("_alias".freeze))
|
776
|
+
RequestInfo.new(host, nil, meta["_index".freeze], meta.delete("_alias".freeze))
|
777
777
|
end
|
778
778
|
|
779
779
|
if split_request?(bulk_message, info)
|
@@ -944,16 +944,16 @@ EOC
|
|
944
944
|
|
945
945
|
def template_installation_actual(deflector_alias, template_name, customize_template, application_name, target_index, ilm_policy_id, host=nil)
|
946
946
|
if template_name && @template_file
|
947
|
-
if @alias_indexes.include?
|
947
|
+
if !@logstash_format && @alias_indexes.include?(deflector_alias)
|
948
948
|
log.debug("Index alias #{deflector_alias} already exists (cached)")
|
949
|
-
elsif @template_names.include?
|
949
|
+
elsif !@logstash_format && @template_names.include?(template_name)
|
950
950
|
log.debug("Template name #{template_name} already exists (cached)")
|
951
951
|
else
|
952
952
|
retry_operate(@max_retry_putting_template, @fail_on_putting_template_retry_exceed) do
|
953
953
|
if customize_template
|
954
|
-
template_custom_install(template_name, @template_file, @template_overwrite, customize_template, @enable_ilm, deflector_alias, ilm_policy_id, host)
|
954
|
+
template_custom_install(template_name, @template_file, @template_overwrite, customize_template, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index)
|
955
955
|
else
|
956
|
-
template_install(template_name, @template_file, @template_overwrite, @enable_ilm, deflector_alias, ilm_policy_id, host)
|
956
|
+
template_install(template_name, @template_file, @template_overwrite, @enable_ilm, deflector_alias, ilm_policy_id, host, target_index)
|
957
957
|
end
|
958
958
|
ilm_policy = @ilm_policies[ilm_policy_id] || {}
|
959
959
|
create_rollover_alias(target_index, @rollover_index, deflector_alias, application_name, @index_date_pattern, @index_separator, @enable_ilm, ilm_policy_id, ilm_policy, @ilm_policy_overwrite, host)
|
@@ -967,11 +967,11 @@ EOC
|
|
967
967
|
# send_bulk given a specific bulk request, the original tag,
|
968
968
|
# chunk, and bulk_message_count
|
969
969
|
def send_bulk(data, tag, chunk, bulk_message_count, extracted_values, info)
|
970
|
-
|
970
|
+
_logstash_prefix, _logstash_dateformat, index_name, _type_name, template_name, customize_template, deflector_alias, application_name, _pipeline, ilm_policy_id = extracted_values
|
971
971
|
if deflector_alias
|
972
972
|
template_installation(deflector_alias, template_name, customize_template, application_name, index_name, ilm_policy_id, info.host)
|
973
973
|
else
|
974
|
-
template_installation(info.ilm_index, template_name, customize_template, application_name, @logstash_format ?
|
974
|
+
template_installation(info.ilm_index, template_name, customize_template, application_name, @logstash_format ? info.ilm_alias : index_name, ilm_policy_id, info.host)
|
975
975
|
end
|
976
976
|
|
977
977
|
begin
|
@@ -1078,32 +1078,32 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1078
1078
|
with(basic_auth: ['john', 'doe']).
|
1079
1079
|
to_return(:status => 200, :body => "", :headers => {})
|
1080
1080
|
# check if template exists
|
1081
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/logstash
|
1081
|
+
stub_request(:get, "https://logs.google.com:777/es//_template/logstash-#{date_str}").
|
1082
1082
|
with(basic_auth: ['john', 'doe']).
|
1083
1083
|
to_return(:status => 404, :body => "", :headers => {})
|
1084
1084
|
# creation
|
1085
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/logstash
|
1085
|
+
stub_request(:put, "https://logs.google.com:777/es//_template/logstash-#{date_str}").
|
1086
1086
|
with(basic_auth: ['john', 'doe']).
|
1087
1087
|
to_return(:status => 200, :body => "", :headers => {})
|
1088
1088
|
# check if alias exists
|
1089
|
-
stub_request(:head, "https://logs.google.com:777/es//_alias/logstash
|
1089
|
+
stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-#{date_str}").
|
1090
1090
|
with(basic_auth: ['john', 'doe']).
|
1091
1091
|
to_return(:status => 404, :body => "", :headers => {})
|
1092
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/logstash
|
1092
|
+
stub_request(:get, "https://logs.google.com:777/es//_template/logstash-#{date_str}").
|
1093
1093
|
with(basic_auth: ['john', 'doe']).
|
1094
1094
|
to_return(status: 404, body: "", headers: {})
|
1095
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/logstash
|
1095
|
+
stub_request(:put, "https://logs.google.com:777/es//_template/logstash-#{date_str}").
|
1096
1096
|
with(basic_auth: ['john', 'doe'],
|
1097
1097
|
body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-log-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-log-#{date_str}-*\",\"order\":53}").
|
1098
1098
|
to_return(status: 200, body: "", headers: {})
|
1099
1099
|
# put the alias for the index
|
1100
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log
|
1100
|
+
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E").
|
1101
1101
|
with(basic_auth: ['john', 'doe']).
|
1102
1102
|
to_return(:status => 200, :body => "", :headers => {})
|
1103
1103
|
|
1104
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log
|
1104
|
+
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E/#{alias_endpoint}/logstash-#{date_str}").
|
1105
1105
|
with(basic_auth: ['john', 'doe'],
|
1106
|
-
body: "{\"aliases\":{\"logstash
|
1106
|
+
body: "{\"aliases\":{\"logstash-#{date_str}\":{\"is_write_index\":true}}}").
|
1107
1107
|
to_return(status: 200, body: "", headers: {})
|
1108
1108
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1109
1109
|
with(basic_auth: ['john', 'doe']).
|
@@ -1122,7 +1122,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1122
1122
|
driver.run(default_tag: 'test') do
|
1123
1123
|
driver.feed(sample_record)
|
1124
1124
|
end
|
1125
|
-
assert_requested(:put, "https://logs.google.com:777/es//_template/logstash
|
1125
|
+
assert_requested(:put, "https://logs.google.com:777/es//_template/logstash-#{date_str}", times: 1)
|
1126
1126
|
|
1127
1127
|
assert_requested(elastic_request)
|
1128
1128
|
end
|
@@ -1213,51 +1213,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1213
1213
|
enable_ilm true
|
1214
1214
|
}
|
1215
1215
|
|
1216
|
-
#
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
# check if template exists
|
1221
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
|
1222
|
-
with(basic_auth: ['john', 'doe']).
|
1223
|
-
to_return(:status => 404, :body => "", :headers => {})
|
1224
|
-
# creation
|
1225
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/logstash").
|
1226
|
-
with(basic_auth: ['john', 'doe']).
|
1227
|
-
to_return(:status => 200, :body => "", :headers => {})
|
1228
|
-
# check if alias exists
|
1229
|
-
stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
|
1230
|
-
with(basic_auth: ['john', 'doe']).
|
1231
|
-
to_return(:status => 404, :body => "", :headers => {})
|
1232
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/myapp_deflector").
|
1233
|
-
with(basic_auth: ['john', 'doe']).
|
1234
|
-
to_return(status: 404, body: "", headers: {})
|
1235
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/myapp_deflector").
|
1236
|
-
with(basic_auth: ['john', 'doe'],
|
1237
|
-
body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"myapp_deflector\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"myapp_deflector-*\",\"order\":51}").
|
1238
|
-
to_return(status: 200, body: "", headers: {})
|
1239
|
-
# put the alias for the index
|
1240
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
|
1241
|
-
with(basic_auth: ['john', 'doe']).
|
1242
|
-
to_return(:status => 200, :body => "", :headers => {})
|
1243
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
|
1244
|
-
with(basic_auth: ['john', 'doe'],
|
1245
|
-
:body => "{\"aliases\":{\"myapp_deflector\":{\"is_write_index\":true}}}").
|
1246
|
-
to_return(:status => 200, :body => "", :headers => {})
|
1247
|
-
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1248
|
-
with(basic_auth: ['john', 'doe']).
|
1249
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1250
|
-
stub_request(:get, "https://logs.google.com:777/es//_ilm/policy/logstash-policy").
|
1251
|
-
with(basic_auth: ['john', 'doe']).
|
1252
|
-
to_return(:status => 404, :body => "", :headers => {})
|
1253
|
-
stub_request(:put, "https://logs.google.com:777/es//_ilm/policy/logstash-policy").
|
1254
|
-
with(basic_auth: ['john', 'doe'],
|
1255
|
-
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1256
|
-
to_return(:status => 200, :body => "", :headers => {})
|
1257
|
-
|
1258
|
-
driver(config)
|
1259
|
-
|
1260
|
-
assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_deflector", times: 1)
|
1216
|
+
# Should raise error because multiple alias indices IllegalArgument Error on executing ILM feature
|
1217
|
+
assert_raise(Fluent::ConfigError) do
|
1218
|
+
driver(config)
|
1219
|
+
end
|
1261
1220
|
end
|
1262
1221
|
|
1263
1222
|
def test_template_create_with_rollover_index_and_default_ilm_with_empty_index_date_pattern
|
@@ -1996,6 +1955,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1996
1955
|
application_name myapp
|
1997
1956
|
}
|
1998
1957
|
|
1958
|
+
timestr = Time.now.strftime("%Y.%m.%d")
|
1999
1959
|
# connection start
|
2000
1960
|
stub_request(:head, "https://logs.google.com:777/es//").
|
2001
1961
|
with(basic_auth: ['john', 'doe']).
|
@@ -2009,17 +1969,17 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2009
1969
|
with(basic_auth: ['john', 'doe']).
|
2010
1970
|
to_return(:status => 200, :body => "", :headers => {})
|
2011
1971
|
# creation of index which can rollover
|
2012
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp
|
1972
|
+
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E").
|
2013
1973
|
with(basic_auth: ['john', 'doe']).
|
2014
1974
|
to_return(:status => 200, :body => "", :headers => {})
|
2015
1975
|
# check if alias exists
|
2016
|
-
|
2017
|
-
stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-myapp-#{timestr}").
|
1976
|
+
stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-#{timestr}").
|
2018
1977
|
with(basic_auth: ['john', 'doe']).
|
2019
1978
|
to_return(:status => 404, :body => "", :headers => {})
|
2020
1979
|
# put the alias for the index
|
2021
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp
|
2022
|
-
with(basic_auth: ['john', 'doe']
|
1980
|
+
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E/#{alias_endpoint}/mylogs-#{timestr}").
|
1981
|
+
with(basic_auth: ['john', 'doe'],
|
1982
|
+
body: "{\"aliases\":{\"mylogs-#{timestr}\":{\"is_write_index\":true}}}").
|
2023
1983
|
to_return(:status => 200, :body => "", :headers => {})
|
2024
1984
|
|
2025
1985
|
driver(config)
|
@@ -2202,52 +2162,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2202
2162
|
enable_ilm true
|
2203
2163
|
}
|
2204
2164
|
|
2205
|
-
#
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
# check if template exists
|
2210
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
|
2211
|
-
with(basic_auth: ['john', 'doe']).
|
2212
|
-
to_return(:status => 404, :body => "", :headers => {})
|
2213
|
-
# creation
|
2214
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
|
2215
|
-
with(basic_auth: ['john', 'doe']).
|
2216
|
-
to_return(:status => 200, :body => "", :headers => {})
|
2217
|
-
# creation of index which can rollover
|
2218
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
|
2219
|
-
with(basic_auth: ['john', 'doe']).
|
2220
|
-
to_return(:status => 200, :body => "", :headers => {})
|
2221
|
-
# check if alias exists
|
2222
|
-
stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
|
2223
|
-
with(basic_auth: ['john', 'doe']).
|
2224
|
-
to_return(:status => 404, :body => "", :headers => {})
|
2225
|
-
stub_request(:get, "https://logs.google.com:777/es//_template/myapp_deflector").
|
2226
|
-
with(basic_auth: ['john', 'doe']).
|
2227
|
-
to_return(status: 404, body: "", headers: {})
|
2228
|
-
stub_request(:put, "https://logs.google.com:777/es//_template/myapp_deflector").
|
2229
|
-
with(basic_auth: ['john', 'doe'],
|
2230
|
-
body: "{\"order\":6,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myapp_deflector\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"myapp_deflector-*\"}").
|
2231
|
-
to_return(status: 200, body: "", headers: {})
|
2232
|
-
# put the alias for the index
|
2233
|
-
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
|
2234
|
-
with(basic_auth: ['john', 'doe'],
|
2235
|
-
:body => "{\"aliases\":{\"myapp_deflector\":{\"is_write_index\":true}}}").
|
2236
|
-
to_return(:status => 200, :body => "", :headers => {})
|
2237
|
-
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2238
|
-
with(basic_auth: ['john', 'doe']).
|
2239
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2240
|
-
stub_request(:get, "https://logs.google.com:777/es//_ilm/policy/fluentd-policy").
|
2241
|
-
with(basic_auth: ['john', 'doe']).
|
2242
|
-
to_return(:status => 404, :body => "", :headers => {})
|
2243
|
-
stub_request(:put, "https://logs.google.com:777/es//_ilm/policy/fluentd-policy").
|
2244
|
-
with(basic_auth: ['john', 'doe'],
|
2245
|
-
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2246
|
-
to_return(:status => 200, :body => "", :headers => {})
|
2247
|
-
|
2248
|
-
driver(config)
|
2249
|
-
|
2250
|
-
assert_requested(:put, "https://logs.google.com:777/es//_template/myapp_deflector", times: 1)
|
2165
|
+
# Should raise error because multiple alias indices IllegalArgument Error on executing ILM feature
|
2166
|
+
assert_raise(Fluent::ConfigError) do
|
2167
|
+
driver(config)
|
2168
|
+
end
|
2251
2169
|
end
|
2252
2170
|
|
2253
2171
|
def test_custom_template_with_rollover_index_create_and_default_ilm_and_placeholders
|
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: 4.1.
|
4
|
+
version: 4.1.1
|
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: 2020-07-
|
13
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|