logstash-output-elasticsearch 9.2.4-java → 9.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/docs/index.asciidoc +104 -2
  4. data/lib/logstash/outputs/elasticsearch.rb +4 -0
  5. data/lib/logstash/outputs/elasticsearch/common.rb +8 -5
  6. data/lib/logstash/outputs/elasticsearch/common_configs.rb +23 -1
  7. data/lib/logstash/outputs/elasticsearch/default-ilm-policy.json +14 -0
  8. data/lib/logstash/outputs/elasticsearch/http_client.rb +47 -2
  9. data/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb +3 -3
  10. data/lib/logstash/outputs/elasticsearch/ilm.rb +84 -0
  11. data/lib/logstash/outputs/elasticsearch/template_manager.rb +21 -1
  12. data/logstash-output-elasticsearch.gemspec +1 -1
  13. data/spec/es_spec_helper.rb +70 -0
  14. data/spec/fixtures/template-with-policy-es6x.json +48 -0
  15. data/spec/fixtures/template-with-policy-es7x.json +46 -0
  16. data/spec/integration/outputs/create_spec.rb +1 -1
  17. data/spec/integration/outputs/ilm_spec.rb +542 -0
  18. data/spec/integration/outputs/ingest_pipeline_spec.rb +2 -2
  19. data/spec/integration/outputs/no_es_on_startup_spec.rb +2 -2
  20. data/spec/integration/outputs/retry_spec.rb +3 -3
  21. data/spec/integration/outputs/templates_5x_spec.rb +7 -7
  22. data/spec/integration/outputs/templates_spec.rb +7 -7
  23. data/spec/support/elasticsearch/api/actions/delete_ilm_policy.rb +19 -0
  24. data/spec/support/elasticsearch/api/actions/get_alias.rb +18 -0
  25. data/spec/support/elasticsearch/api/actions/get_ilm_policy.rb +18 -0
  26. data/spec/support/elasticsearch/api/actions/put_alias.rb +24 -0
  27. data/spec/support/elasticsearch/api/actions/put_ilm_policy.rb +25 -0
  28. metadata +20 -2
@@ -54,13 +54,13 @@ if ESHelper.es_version_satisfies?(">= 5")
54
54
  #Wait or fail until everything's indexed.
55
55
  Stud::try(20.times) do
56
56
  r = @es.search
57
- expect(r["hits"]["total"]).to eq(1)
57
+ expect(r).to have_hits(1)
58
58
  end
59
59
  end
60
60
 
61
61
  it "indexes using the proper pipeline" do
62
62
  results = @es.search(:index => 'logstash-*', :q => "message:\"netcat\"")
63
- expect(results["hits"]["total"]).to eq(1)
63
+ expect(results).to have_hits(1)
64
64
  expect(results["hits"]["hits"][0]["_source"]["response"]).to eq("200")
65
65
  expect(results["hits"]["hits"][0]["_source"]["bytes"]).to eq("182")
66
66
  expect(results["hits"]["hits"][0]["_source"]["verb"]).to eq("GET")
@@ -39,7 +39,7 @@ describe "elasticsearch is down on startup", :integration => true do
39
39
  subject.multi_receive([event1, event2])
40
40
  @es.indices.refresh
41
41
  r = @es.search
42
- expect(r["hits"]["total"]).to eql(2)
42
+ expect(r).to have_hits(2)
43
43
  end
44
44
 
45
45
  it 'should ingest events when Elasticsearch recovers after documents are sent' do
@@ -52,7 +52,7 @@ describe "elasticsearch is down on startup", :integration => true do
52
52
  subject.multi_receive([event1, event2])
53
53
  @es.indices.refresh
54
54
  r = @es.search
55
- expect(r["hits"]["total"]).to eql(2)
55
+ expect(r).to have_hits(2)
56
56
  end
57
57
 
58
58
  end
@@ -143,7 +143,7 @@ describe "failures in bulk class expected behavior", :integration => true do
143
143
 
144
144
  @es.indices.refresh
145
145
  r = @es.search
146
- expect(r["hits"]["total"]).to eql(0)
146
+ expect(r).to have_hits(0)
147
147
  end
148
148
 
149
149
  it "successful requests should not be appended to retry queue" do
@@ -154,7 +154,7 @@ describe "failures in bulk class expected behavior", :integration => true do
154
154
  subject.close
155
155
  @es.indices.refresh
156
156
  r = @es.search
157
- expect(r["hits"]["total"]).to eql(1)
157
+ expect(r).to have_hits(1)
158
158
  end
159
159
 
160
160
  it "should only index proper events" do
@@ -164,6 +164,6 @@ describe "failures in bulk class expected behavior", :integration => true do
164
164
 
165
165
  @es.indices.refresh
166
166
  r = @es.search
167
- expect(r["hits"]["total"]).to eql(1)
167
+ expect(r).to have_hits(1)
168
168
  end
169
169
  end
@@ -41,19 +41,19 @@ if ESHelper.es_version_satisfies?(">= 5")
41
41
  # Wait or fail until everything's indexed.
42
42
  Stud::try(20.times) do
43
43
  r = @es.search
44
- expect(r["hits"]["total"]).to eq(8)
44
+ expect(r).to have_hits(8)
45
45
  end
46
46
  end
47
47
 
48
48
  it "permits phrase searching on string fields" do
49
49
  results = @es.search(:q => "message:\"sample message\"")
50
- expect(results["hits"]["total"]).to eq(1)
50
+ expect(results).to have_hits(1)
51
51
  expect(results["hits"]["hits"][0]["_source"]["message"]).to eq("sample message here")
52
52
  end
53
53
 
54
54
  it "numbers dynamically map to a numeric type and permit range queries" do
55
55
  results = @es.search(:q => "somevalue:[5 TO 105]")
56
- expect(results["hits"]["total"]).to eq(2)
56
+ expect(results).to have_hits(2)
57
57
 
58
58
  values = results["hits"]["hits"].collect { |r| r["_source"]["somevalue"] }
59
59
  expect(values).to include(10)
@@ -63,22 +63,22 @@ if ESHelper.es_version_satisfies?(">= 5")
63
63
 
64
64
  it "does not create .keyword field for top-level message field" do
65
65
  results = @es.search(:q => "message.keyword:\"sample message here\"")
66
- expect(results["hits"]["total"]).to eq(0)
66
+ expect(results).to have_hits(0)
67
67
  end
68
68
 
69
69
  it "creates .keyword field for nested message fields" do
70
70
  results = @es.search(:q => "somemessage.message.keyword:\"sample nested message here\"")
71
- expect(results["hits"]["total"]).to eq(1)
71
+ expect(results).to have_hits(1)
72
72
  end
73
73
 
74
74
  it "creates .keyword field from any string field which is not_analyzed" do
75
75
  results = @es.search(:q => "country.keyword:\"us\"")
76
- expect(results["hits"]["total"]).to eq(1)
76
+ expect(results).to have_hits(1)
77
77
  expect(results["hits"]["hits"][0]["_source"]["country"]).to eq("us")
78
78
 
79
79
  # partial or terms should not work.
80
80
  results = @es.search(:q => "country.keyword:\"u\"")
81
- expect(results["hits"]["total"]).to eq(0)
81
+ expect(results).to have_hits(0)
82
82
  end
83
83
 
84
84
  it "make [geoip][location] a geo_point" do
@@ -41,19 +41,19 @@ if ESHelper.es_version_satisfies?("< 5")
41
41
  # Wait or fail until everything's indexed.
42
42
  Stud::try(20.times) do
43
43
  r = @es.search
44
- expect(r["hits"]["total"]).to eq(8)
44
+ expect(r).to have_hits(8)
45
45
  end
46
46
  end
47
47
 
48
48
  it "permits phrase searching on string fields" do
49
49
  results = @es.search(:q => "message:\"sample message\"")
50
- expect(results["hits"]["total"]).to eq(1)
50
+ expect(results).to have_hits(1)
51
51
  expect(results["hits"]["hits"][0]["_source"]["message"]).to eq("sample message here")
52
52
  end
53
53
 
54
54
  it "numbers dynamically map to a numeric type and permit range queries" do
55
55
  results = @es.search(:q => "somevalue:[5 TO 105]")
56
- expect(results["hits"]["total"]).to eq(2)
56
+ expect(results).to have_hits(2)
57
57
 
58
58
  values = results["hits"]["hits"].collect { |r| r["_source"]["somevalue"] }
59
59
  expect(values).to include(10)
@@ -63,22 +63,22 @@ if ESHelper.es_version_satisfies?("< 5")
63
63
 
64
64
  it "does not create .raw field for the message field" do
65
65
  results = @es.search(:q => "message.raw:\"sample message here\"")
66
- expect(results["hits"]["total"]).to eq(0)
66
+ expect(results).to have_hits(0)
67
67
  end
68
68
 
69
69
  it "creates .raw field for nested message fields" do
70
70
  results = @es.search(:q => "somemessage.message.raw:\"sample nested message here\"")
71
- expect(results["hits"]["total"]).to eq(1)
71
+ expect(results).to have_hits(1)
72
72
  end
73
73
 
74
74
  it "creates .raw field from any string field which is not_analyzed" do
75
75
  results = @es.search(:q => "country.raw:\"us\"")
76
- expect(results["hits"]["total"]).to eq(1)
76
+ expect(results).to have_hits(1)
77
77
  expect(results["hits"]["hits"][0]["_source"]["country"]).to eq("us")
78
78
 
79
79
  # partial or terms should not work.
80
80
  results = @es.search(:q => "country.raw:\"u\"")
81
- expect(results["hits"]["total"]).to eq(0)
81
+ expect(results).to have_hits(0)
82
82
  end
83
83
 
84
84
  it "make [geoip][location] a geo_point" do
@@ -0,0 +1,19 @@
1
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2
+ # or more contributor license agreements. Licensed under the Elastic License;
3
+ # you may not use this file except in compliance with the Elastic License.
4
+
5
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+
9
+ # Update the password of the specified user
10
+ def delete_ilm_policy(arguments={})
11
+ method = HTTP_DELETE
12
+ path = Utils.__pathify '_ilm/policy/',
13
+ Utils.__escape(arguments[:name])
14
+ params = {}
15
+ perform_request(method, path, params, nil).body
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2
+ # or more contributor license agreements. Licensed under the Elastic License;
3
+ # you may not use this file except in compliance with the Elastic License.
4
+
5
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+
9
+ # Retrieve the list of index lifecycle management policies
10
+ def get_alias(arguments={})
11
+ method = HTTP_GET
12
+ path = Utils.__pathify '_alias', Utils.__escape(arguments[:name])
13
+ params = {}
14
+ perform_request(method, path, params, nil).body
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2
+ # or more contributor license agreements. Licensed under the Elastic License;
3
+ # you may not use this file except in compliance with the Elastic License.
4
+
5
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+
9
+ # Retrieve the list of index lifecycle management policies
10
+ def get_ilm_policy(arguments={})
11
+ method = HTTP_GET
12
+ path = Utils.__pathify '_ilm/policy', Utils.__escape(arguments[:name])
13
+ params = {}
14
+ perform_request(method, path, params, nil).body
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2
+ # or more contributor license agreements. Licensed under the Elastic License;
3
+ # you may not use this file except in compliance with the Elastic License.
4
+
5
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+
9
+ # @option arguments [String] :name The name of the alias (*Required*)
10
+ # @option arguments [Hash] :The alias definition(*Required*)
11
+
12
+ def put_alias(arguments={})
13
+ raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
14
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
15
+ method = HTTP_PUT
16
+ path = Utils.__pathify Utils.__escape(arguments[:name])
17
+
18
+ params = Utils.__validate_and_extract_params arguments
19
+ body = arguments[:body]
20
+ perform_request(method, path, params, body.to_json).body
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2
+ # or more contributor license agreements. Licensed under the Elastic License;
3
+ # you may not use this file except in compliance with the Elastic License.
4
+
5
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+
9
+ # @option arguments [String] :name The name of the policy (*Required*)
10
+ # @option arguments [Hash] :body The policy definition (*Required*)
11
+
12
+ def put_ilm_policy(arguments={})
13
+ raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
14
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
15
+ method = HTTP_PUT
16
+ path = Utils.__pathify '_ilm/policy/', Utils.__escape(arguments[:name])
17
+
18
+ params = Utils.__validate_and_extract_params arguments
19
+
20
+ body = arguments[:body]
21
+ perform_request(method, path, params, body.to_json).body
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.4
4
+ version: 9.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2018-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +158,7 @@ files:
158
158
  - lib/logstash/outputs/elasticsearch.rb
159
159
  - lib/logstash/outputs/elasticsearch/common.rb
160
160
  - lib/logstash/outputs/elasticsearch/common_configs.rb
161
+ - lib/logstash/outputs/elasticsearch/default-ilm-policy.json
161
162
  - lib/logstash/outputs/elasticsearch/elasticsearch-template-es2x.json
162
163
  - lib/logstash/outputs/elasticsearch/elasticsearch-template-es5x.json
163
164
  - lib/logstash/outputs/elasticsearch/elasticsearch-template-es6x.json
@@ -166,6 +167,7 @@ files:
166
167
  - lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb
167
168
  - lib/logstash/outputs/elasticsearch/http_client/pool.rb
168
169
  - lib/logstash/outputs/elasticsearch/http_client_builder.rb
170
+ - lib/logstash/outputs/elasticsearch/ilm.rb
169
171
  - lib/logstash/outputs/elasticsearch/template_manager.rb
170
172
  - logstash-output-elasticsearch.gemspec
171
173
  - spec/es_spec_helper.rb
@@ -179,6 +181,8 @@ files:
179
181
  - spec/fixtures/scripts/painless/scripted_update.painless
180
182
  - spec/fixtures/scripts/painless/scripted_update_nested.painless
181
183
  - spec/fixtures/scripts/painless/scripted_upsert.painless
184
+ - spec/fixtures/template-with-policy-es6x.json
185
+ - spec/fixtures/template-with-policy-es7x.json
182
186
  - spec/fixtures/test_certs/ca/ca.crt
183
187
  - spec/fixtures/test_certs/ca/ca.key
184
188
  - spec/fixtures/test_certs/test.crt
@@ -187,6 +191,7 @@ files:
187
191
  - spec/integration/outputs/create_spec.rb
188
192
  - spec/integration/outputs/delete_spec.rb
189
193
  - spec/integration/outputs/groovy_update_spec.rb
194
+ - spec/integration/outputs/ilm_spec.rb
190
195
  - spec/integration/outputs/index_spec.rb
191
196
  - spec/integration/outputs/index_version_spec.rb
192
197
  - spec/integration/outputs/ingest_pipeline_spec.rb
@@ -200,6 +205,11 @@ files:
200
205
  - spec/integration/outputs/templates_5x_spec.rb
201
206
  - spec/integration/outputs/templates_spec.rb
202
207
  - spec/integration/outputs/update_spec.rb
208
+ - spec/support/elasticsearch/api/actions/delete_ilm_policy.rb
209
+ - spec/support/elasticsearch/api/actions/get_alias.rb
210
+ - spec/support/elasticsearch/api/actions/get_ilm_policy.rb
211
+ - spec/support/elasticsearch/api/actions/put_alias.rb
212
+ - spec/support/elasticsearch/api/actions/put_ilm_policy.rb
203
213
  - spec/unit/http_client_builder_spec.rb
204
214
  - spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb
205
215
  - spec/unit/outputs/elasticsearch/http_client/pool_spec.rb
@@ -247,6 +257,8 @@ test_files:
247
257
  - spec/fixtures/scripts/painless/scripted_update.painless
248
258
  - spec/fixtures/scripts/painless/scripted_update_nested.painless
249
259
  - spec/fixtures/scripts/painless/scripted_upsert.painless
260
+ - spec/fixtures/template-with-policy-es6x.json
261
+ - spec/fixtures/template-with-policy-es7x.json
250
262
  - spec/fixtures/test_certs/ca/ca.crt
251
263
  - spec/fixtures/test_certs/ca/ca.key
252
264
  - spec/fixtures/test_certs/test.crt
@@ -255,6 +267,7 @@ test_files:
255
267
  - spec/integration/outputs/create_spec.rb
256
268
  - spec/integration/outputs/delete_spec.rb
257
269
  - spec/integration/outputs/groovy_update_spec.rb
270
+ - spec/integration/outputs/ilm_spec.rb
258
271
  - spec/integration/outputs/index_spec.rb
259
272
  - spec/integration/outputs/index_version_spec.rb
260
273
  - spec/integration/outputs/ingest_pipeline_spec.rb
@@ -268,6 +281,11 @@ test_files:
268
281
  - spec/integration/outputs/templates_5x_spec.rb
269
282
  - spec/integration/outputs/templates_spec.rb
270
283
  - spec/integration/outputs/update_spec.rb
284
+ - spec/support/elasticsearch/api/actions/delete_ilm_policy.rb
285
+ - spec/support/elasticsearch/api/actions/get_alias.rb
286
+ - spec/support/elasticsearch/api/actions/get_ilm_policy.rb
287
+ - spec/support/elasticsearch/api/actions/put_alias.rb
288
+ - spec/support/elasticsearch/api/actions/put_ilm_policy.rb
271
289
  - spec/unit/http_client_builder_spec.rb
272
290
  - spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb
273
291
  - spec/unit/outputs/elasticsearch/http_client/pool_spec.rb