logstash-output-elasticsearch 11.18.0-java → 11.19.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +4 -2
- data/lib/logstash/outputs/elasticsearch/http_client.rb +1 -0
- data/lib/logstash/outputs/elasticsearch/http_client_builder.rb +13 -2
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/integration/outputs/index_spec.rb +79 -6
- data/spec/unit/http_client_builder_spec.rb +40 -25
- 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: '0490f311461b39c49e3edaf045af9a7172dbd97da8bc456bf044a031c18e5afb'
|
4
|
+
data.tar.gz: fbf05190ed352c12f0948aecfa6ed08e760b03985b83aa2e6830167a00c431bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b50084b6fb4fd31e7592be7e35e23963dce4cf284763baa4c1c042d1f159f20cebe09c1013ace38a986dbf4c8ee3cc9ae4eda7f38042956bd10dbdfc0ad20114
|
7
|
+
data.tar.gz: 91643fa15c48a29a02659967c75e0b879f98af2a6e7f1582c83b141f67826337ccaa3d0513b1372266dd068cbccfcdbbe59a5fcf36ceff81318126dd1bdf64cc
|
data/CHANGELOG.md
CHANGED
data/docs/index.asciidoc
CHANGED
@@ -423,10 +423,12 @@ Elasticsearch {ref}/security-api-create-api-key.html[Create API key API].
|
|
423
423
|
===== `bulk_path`
|
424
424
|
|
425
425
|
* Value type is <<string,string>>
|
426
|
-
*
|
426
|
+
* The default value for this settings is `/_bulk?filter_path=errors,items.*.error,items.*.status`
|
427
427
|
|
428
428
|
HTTP Path to perform the _bulk requests to
|
429
|
-
|
429
|
+
* This default bulk path is the concatenation of the value of `path` parameter and `/_bulk?filter_path=errors,items.*.error,items.*.status`
|
430
|
+
* The `filter_path` query parameter is appended to the bulk path to reduce the payload between logstash and elasticsearch. However, if a custom `filter_path` query parameter is included in the `bulk_path` setting, then that value will be used.
|
431
|
+
|
430
432
|
|
431
433
|
[id="plugins-{type}s-{plugin}-ca_trusted_fingerprint"]
|
432
434
|
===== `ca_trusted_fingerprint`
|
@@ -177,6 +177,7 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
177
177
|
|
178
178
|
def bulk_send(body_stream, batch_actions)
|
179
179
|
params = compression_level? ? {:headers => {"Content-Encoding" => "gzip"}} : {}
|
180
|
+
|
180
181
|
response = @pool.post(@bulk_path, params, body_stream.string)
|
181
182
|
|
182
183
|
@bulk_response_metrics.increment(response.code.to_s)
|
@@ -33,9 +33,9 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
33
33
|
end
|
34
34
|
|
35
35
|
common_options[:bulk_path] = if params["bulk_path"]
|
36
|
-
|
36
|
+
resolve_filter_path(dedup_slashes("/#{params["bulk_path"]}"))
|
37
37
|
else
|
38
|
-
|
38
|
+
resolve_filter_path(dedup_slashes("/#{params["path"]}/_bulk"))
|
39
39
|
end
|
40
40
|
|
41
41
|
common_options[:sniffing_path] = if params["sniffing_path"]
|
@@ -197,5 +197,16 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
197
197
|
def self.dedup_slashes(url)
|
198
198
|
url.gsub(/\/+/, "/")
|
199
199
|
end
|
200
|
+
|
201
|
+
# Set a `filter_path` query parameter if it is not already set to be
|
202
|
+
# `filter_path=errors,items.*.error,items.*.status` to reduce the payload between Logstash and Elasticsearch
|
203
|
+
def self.resolve_filter_path(url)
|
204
|
+
return url if url.match?(/(?:[&|?])filter_path=/)
|
205
|
+
("#{url}#{query_param_separator(url)}filter_path=errors,items.*.error,items.*.status")
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.query_param_separator(url)
|
209
|
+
url.match?(/\?[^\s#]+/) ? '&' : '?'
|
210
|
+
end
|
200
211
|
end
|
201
212
|
end; end; end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-elasticsearch'
|
3
|
-
s.version = '11.
|
3
|
+
s.version = '11.19.0'
|
4
4
|
s.licenses = ['apache-2.0']
|
5
5
|
s.summary = "Stores logs in Elasticsearch"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -156,7 +156,7 @@ describe "indexing" do
|
|
156
156
|
let(:config) { "not implemented" }
|
157
157
|
let(:events) { event_count.times.map { event }.to_a }
|
158
158
|
subject { LogStash::Outputs::ElasticSearch.new(config) }
|
159
|
-
|
159
|
+
let(:filter_path) { "filter_path=errors,items.*.error,items.*.status"}
|
160
160
|
let(:es_url) { "http://#{get_host_port}" }
|
161
161
|
let(:index_url) { "#{es_url}/#{index}" }
|
162
162
|
|
@@ -178,7 +178,7 @@ describe "indexing" do
|
|
178
178
|
subject.do_close
|
179
179
|
end
|
180
180
|
|
181
|
-
shared_examples "an indexer" do |secure|
|
181
|
+
shared_examples "an indexer" do |secure, expected_path|
|
182
182
|
before(:each) do
|
183
183
|
host_unreachable_error_class = LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError
|
184
184
|
allow(host_unreachable_error_class).to receive(:new).with(any_args).and_wrap_original do |m, original, url|
|
@@ -212,13 +212,13 @@ describe "indexing" do
|
|
212
212
|
expect(doc["_index"]).to eq(index)
|
213
213
|
end
|
214
214
|
end
|
215
|
-
|
215
|
+
|
216
216
|
it "sets the correct content-type header" do
|
217
217
|
expected_manticore_opts = {:headers => {"Content-Type" => "application/json"}, :body => anything}
|
218
218
|
if secure
|
219
219
|
expected_manticore_opts = {
|
220
|
-
:headers => {"Content-Type" => "application/json"},
|
221
|
-
:body => anything,
|
220
|
+
:headers => {"Content-Type" => "application/json"},
|
221
|
+
:body => anything,
|
222
222
|
:auth => {
|
223
223
|
:user => user,
|
224
224
|
:password => password,
|
@@ -230,6 +230,20 @@ describe "indexing" do
|
|
230
230
|
and_call_original
|
231
231
|
subject.multi_receive(events)
|
232
232
|
end
|
233
|
+
|
234
|
+
it "sets the bulk path URL and filter path parameter correctly" do
|
235
|
+
expect(subject.client.pool.adapter.client).to receive(:send).
|
236
|
+
with(anything, expected_path != nil ? expected_path : anything, anything).at_least(:once).and_call_original
|
237
|
+
subject.multi_receive(events)
|
238
|
+
end
|
239
|
+
|
240
|
+
it "receives a filtered response" do
|
241
|
+
expect(subject.client).to receive(:join_bulk_responses).
|
242
|
+
with([{"errors"=>false, "items"=>[{"index"=>{"status"=>201}}]}]).
|
243
|
+
and_call_original
|
244
|
+
subject.multi_receive([event])
|
245
|
+
end
|
246
|
+
|
233
247
|
end
|
234
248
|
|
235
249
|
shared_examples "PKIX path failure" do
|
@@ -269,6 +283,65 @@ describe "indexing" do
|
|
269
283
|
it_behaves_like("an indexer")
|
270
284
|
end
|
271
285
|
|
286
|
+
describe "an indexer with custom bulk path", :integration => true do
|
287
|
+
let(:bulk_path) { "/_bulk?routing=true"}
|
288
|
+
let(:config) {
|
289
|
+
{
|
290
|
+
"hosts" => get_host_port,
|
291
|
+
"index" => index,
|
292
|
+
"http_compression" => false,
|
293
|
+
"bulk_path" => bulk_path
|
294
|
+
}
|
295
|
+
}
|
296
|
+
it_behaves_like("an indexer", false) do
|
297
|
+
let (:expected_path) { "#{es_url}#{bulk_path}&#{filter_path}" }
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe "an indexer with filter path as second parameter", :integration => true do
|
302
|
+
let(:bulk_path) { "/_bulk?routing=true&#{filter_path}"}
|
303
|
+
let(:config) {
|
304
|
+
{
|
305
|
+
"hosts" => get_host_port,
|
306
|
+
"index" => index,
|
307
|
+
"http_compression" => false,
|
308
|
+
"bulk_path" => bulk_path
|
309
|
+
}
|
310
|
+
}
|
311
|
+
it_behaves_like("an indexer", false) do
|
312
|
+
let (:expected_path) { "#{es_url}/#{bulk_path}" }
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
describe "an indexer with filter path as first parameter", :integration => true do
|
317
|
+
let(:bulk_path) { "/_bulk?#{filter_path}&routing=true"}
|
318
|
+
let(:config) {
|
319
|
+
{
|
320
|
+
"hosts" => get_host_port,
|
321
|
+
"index" => index,
|
322
|
+
"http_compression" => false,
|
323
|
+
"bulk_path" => bulk_path
|
324
|
+
}
|
325
|
+
}
|
326
|
+
it_behaves_like("an indexer", false) do
|
327
|
+
let (:expected_path) { "#{es_url}/#{bulk_path}" }
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe "an indexer with the standard bulk path", :integration => true do
|
332
|
+
let(:config) {
|
333
|
+
{
|
334
|
+
"hosts" => get_host_port,
|
335
|
+
"index" => index,
|
336
|
+
"http_compression" => false
|
337
|
+
}
|
338
|
+
}
|
339
|
+
it_behaves_like("an indexer", false) do
|
340
|
+
let (:expected_path) { "#{es_url}/_bulk?#{filter_path}" }
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
272
345
|
describe "an indexer with no type value set (default to doc)", :integration => true do
|
273
346
|
let(:type) { ESHelper.es_version_satisfies?("< 7") ? "doc" : "_doc" }
|
274
347
|
let(:config) {
|
@@ -296,7 +369,7 @@ describe "indexing" do
|
|
296
369
|
"index" => index,
|
297
370
|
"http_compression" => false
|
298
371
|
}
|
299
|
-
end
|
372
|
+
end
|
300
373
|
|
301
374
|
let(:curl_opts) { "-u #{user}:#{password}" }
|
302
375
|
|
@@ -36,7 +36,17 @@ describe LogStash::Outputs::ElasticSearch::HttpClientBuilder do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe "
|
39
|
+
describe "bulk_path" do
|
40
|
+
let (:filter_path) {"filter_path=errors,items.*.error,items.*.status"}
|
41
|
+
|
42
|
+
shared_examples("filter_path added to bulk path appropriately") do
|
43
|
+
it "sets the bulk_path option to the expected bulk path" do
|
44
|
+
expect(described_class).to receive(:create_http_client) do |options|
|
45
|
+
expect(options[:bulk_path]).to eq(expected_bulk_path)
|
46
|
+
end
|
47
|
+
described_class.build(logger, hosts, options)
|
48
|
+
end
|
49
|
+
end
|
40
50
|
|
41
51
|
context "when setting bulk_path" do
|
42
52
|
let(:bulk_path) { "/meh" }
|
@@ -44,21 +54,31 @@ describe LogStash::Outputs::ElasticSearch::HttpClientBuilder do
|
|
44
54
|
|
45
55
|
context "when using path" do
|
46
56
|
let(:options) { super().merge("path" => "/path") }
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
let(:expected_bulk_path) { "#{bulk_path}?#{filter_path}" }
|
58
|
+
|
59
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when setting a filter path as first parameter" do
|
63
|
+
let (:filter_path) {"filter_path=error"}
|
64
|
+
let(:bulk_path) { "/meh?#{filter_path}&routing=true" }
|
65
|
+
let(:expected_bulk_path) { bulk_path }
|
66
|
+
|
67
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when setting a filter path as second parameter" do
|
71
|
+
let (:filter_path) {"filter_path=error"}
|
72
|
+
let(:bulk_path) { "/meh?routing=true&#{filter_path}" }
|
73
|
+
let(:expected_bulk_path) { bulk_path }
|
74
|
+
|
75
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
53
76
|
end
|
77
|
+
|
54
78
|
context "when not using path" do
|
79
|
+
let(:expected_bulk_path) { "#{bulk_path}?#{filter_path}"}
|
55
80
|
|
56
|
-
|
57
|
-
expect(described_class).to receive(:create_http_client) do |options|
|
58
|
-
expect(options[:bulk_path]).to eq(bulk_path)
|
59
|
-
end
|
60
|
-
described_class.build(logger, hosts, options)
|
61
|
-
end
|
81
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
62
82
|
end
|
63
83
|
end
|
64
84
|
|
@@ -66,25 +86,20 @@ describe LogStash::Outputs::ElasticSearch::HttpClientBuilder do
|
|
66
86
|
|
67
87
|
context "when using path" do
|
68
88
|
let(:path) { "/meh" }
|
89
|
+
let(:expected_bulk_path) { "#{path}/_bulk?#{filter_path}"}
|
69
90
|
let(:options) { super().merge("path" => path) }
|
70
|
-
|
71
|
-
|
72
|
-
expect(options[:bulk_path]).to eq("#{path}/_bulk")
|
73
|
-
end
|
74
|
-
described_class.build(logger, hosts, options)
|
75
|
-
end
|
91
|
+
|
92
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
76
93
|
end
|
77
94
|
|
78
95
|
context "when not using path" do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
described_class.build(logger, hosts, options)
|
84
|
-
end
|
96
|
+
let(:expected_bulk_path) { "/_bulk?#{filter_path}"}
|
97
|
+
|
98
|
+
it_behaves_like "filter_path added to bulk path appropriately"
|
85
99
|
end
|
86
100
|
end
|
87
101
|
end
|
102
|
+
|
88
103
|
describe "healthcheck_path" do
|
89
104
|
context "when setting healthcheck_path" do
|
90
105
|
let(:healthcheck_path) { "/meh" }
|
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: 11.
|
4
|
+
version: 11.19.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|