logstash-output-elasticsearch 11.21.0-java → 11.22.1-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 +6 -0
- data/lib/logstash/outputs/elasticsearch.rb +29 -4
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/unit/outputs/elasticsearch_spec.rb +124 -0
- 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: 343fd4ddc3b4bef5b44a75dab05e92e88e745d4ed45c8bac1a1264c49ebea26c
|
4
|
+
data.tar.gz: 4db3cccc3c815d076ea5d060735934faedb903dd546fd812db9dfcb51b420815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106914085af2ec4e9eaab10d765eab7aca2f4967eb33bc76c11c87b6cbe77795a10966c3d314b612913c34fd91d9a7320f1c1f6990e2cc39f610ecd3dbefce0e
|
7
|
+
data.tar.gz: 507d0193320fdf5f5e48f3afc983f287bf69a8f122c3e1c05ee9854a203a90fc45ace2a337fd187b8744ac8693a4963e19da4fa11daafc1d0100d4346a29191f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 11.22.1
|
2
|
+
- Fix, avoid to populate `version` and `version_type` attributes when processing integration metadata and datastream is enabled. [#1161](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1161)
|
3
|
+
|
4
|
+
## 11.22.0
|
5
|
+
- Added support for propagating event processing metadata when this output is downstream of an Elastic Integration Filter and configured _without_ explicit `version`, `version_type`, or `routing` directives [#1158](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1158)
|
6
|
+
|
1
7
|
## 11.21.0
|
2
8
|
- Added support for propagating event processing metadata when this output is downstream of an Elastic Integration Filter and configured _without_ explicit `index`, `document_id`, or `pipeline` directives [#1155](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1155)
|
3
9
|
|
@@ -499,8 +499,15 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
499
499
|
params[retry_on_conflict_action_name] = @retry_on_conflict
|
500
500
|
end
|
501
501
|
|
502
|
-
|
503
|
-
|
502
|
+
event_control = event.get("[@metadata][_ingest_document]")
|
503
|
+
event_version, event_version_type = event_control&.values_at("version", "version_type") rescue nil
|
504
|
+
|
505
|
+
resolved_version = resolve_version(event, event_version)
|
506
|
+
resolved_version_type = resolve_version_type(event, event_version_type)
|
507
|
+
|
508
|
+
# avoid to add nil valued key-value pairs
|
509
|
+
params[:version] = resolved_version unless resolved_version.nil?
|
510
|
+
params[:version_type] = resolved_version_type unless resolved_version_type.nil?
|
504
511
|
|
505
512
|
EventActionTuple.new(action, params, event)
|
506
513
|
end
|
@@ -541,12 +548,12 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
541
548
|
# @private shared event params factory between index and data_stream mode
|
542
549
|
def common_event_params(event)
|
543
550
|
event_control = event.get("[@metadata][_ingest_document]")
|
544
|
-
event_id, event_pipeline, event_index = event_control&.values_at("id","pipeline","index") rescue nil
|
551
|
+
event_id, event_pipeline, event_index, event_routing = event_control&.values_at("id","pipeline","index", "routing") rescue nil
|
545
552
|
|
546
553
|
params = {
|
547
554
|
:_id => resolve_document_id(event, event_id),
|
548
555
|
:_index => resolve_index!(event, event_index),
|
549
|
-
routing_field_name =>
|
556
|
+
routing_field_name => resolve_routing(event, event_routing)
|
550
557
|
}
|
551
558
|
|
552
559
|
target_pipeline = resolve_pipeline(event, event_pipeline)
|
@@ -560,6 +567,24 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
560
567
|
params
|
561
568
|
end
|
562
569
|
|
570
|
+
def resolve_version(event, event_version)
|
571
|
+
return event_version if event_version && !@version
|
572
|
+
event.sprintf(@version) if @version
|
573
|
+
end
|
574
|
+
private :resolve_version
|
575
|
+
|
576
|
+
def resolve_version_type(event, event_version_type)
|
577
|
+
return event_version_type if event_version_type && !@version_type
|
578
|
+
event.sprintf(@version_type) if @version_type
|
579
|
+
end
|
580
|
+
private :resolve_version_type
|
581
|
+
|
582
|
+
def resolve_routing(event, event_routing)
|
583
|
+
return event_routing if event_routing && !@routing
|
584
|
+
@routing ? event.sprintf(@routing) : nil
|
585
|
+
end
|
586
|
+
private :resolve_routing
|
587
|
+
|
563
588
|
def resolve_document_id(event, event_id)
|
564
589
|
return event.sprintf(@document_id) if @document_id
|
565
590
|
return event_id || nil
|
@@ -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.22.1'
|
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"
|
@@ -275,6 +275,130 @@ describe LogStash::Outputs::ElasticSearch do
|
|
275
275
|
let(:event_fields) {{}}
|
276
276
|
let(:event) { LogStash::Event.new(event_fields)}
|
277
277
|
|
278
|
+
context "when plugin's version is specified" do
|
279
|
+
let(:options) { super().merge("version" => "123")}
|
280
|
+
|
281
|
+
context "when the event contains an integration metadata version" do
|
282
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) }
|
283
|
+
|
284
|
+
it "plugin's version is used" do
|
285
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "123")
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context "when the event DOESN'T contains an integration metadata version" do
|
290
|
+
it "plugin's version is used" do
|
291
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "123")
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "when plugin's version is NOT specified" do
|
297
|
+
context "when the event contains an integration metadata version" do
|
298
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) }
|
299
|
+
|
300
|
+
context "when datastream settings are NOT configured" do
|
301
|
+
it "event's metadata version is used" do
|
302
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "456")
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
context "when datastream settings are configured" do
|
307
|
+
# NOTE: we validate with datastream-specific `data_stream_event_action_tuple`
|
308
|
+
let(:event_fields) { super().merge({"data_stream" => {"type" => "logs", "dataset" => "generic", "namespace" => "default"}}) }
|
309
|
+
|
310
|
+
it "no version is used" do
|
311
|
+
expect(subject.send(:data_stream_event_action_tuple, event)[1]).to_not include(:version)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
context "when the event DOESN'T contain an integration metadata version" do
|
317
|
+
it "plugin's default id mechanism is used" do
|
318
|
+
expect(subject.send(:event_action_tuple, event)[1]).to_not include(:version)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
context "when plugin's version_type is specified" do
|
324
|
+
let(:options) { super().merge("version_type" => "internal")}
|
325
|
+
|
326
|
+
context "when the event contains an integration metadata version_type" do
|
327
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) }
|
328
|
+
|
329
|
+
context "when datastream settings are NOT configured" do
|
330
|
+
it "plugin's version_type is used" do
|
331
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal")
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context "when datastream settings are configured" do
|
336
|
+
# NOTE: we validate with datastream-specific `data_stream_event_action_tuple`
|
337
|
+
let(:event_fields) { super().merge({"data_stream" => {"type" => "logs", "dataset" => "generic", "namespace" => "default"}}) }
|
338
|
+
|
339
|
+
it "no version_type is used" do
|
340
|
+
expect(subject.send(:data_stream_event_action_tuple, event)[1]).to_not include(:version_type)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
context "when the event DOESN'T contains an integration metadata version_type" do
|
346
|
+
it "plugin's version_type is used" do
|
347
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal")
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
context "when plugin's version_type is NOT specified" do
|
353
|
+
context "when the event contains an integration metadata version_type" do
|
354
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) }
|
355
|
+
|
356
|
+
it "event's metadata version_type is used" do
|
357
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "external")
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
context "when the event DOESN'T contain an integration metadata version_type" do
|
362
|
+
it "plugin's default id mechanism is used" do
|
363
|
+
expect(subject.send(:event_action_tuple, event)[1]).to_not include(:version_type)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
context "when plugin's routing is specified" do
|
369
|
+
let(:options) { super().merge("routing" => "settings_routing")}
|
370
|
+
|
371
|
+
context "when the event contains an integration metadata routing" do
|
372
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) }
|
373
|
+
|
374
|
+
it "plugin's routing is used" do
|
375
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing")
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
context "when the event DOESN'T contains an integration metadata routing" do
|
380
|
+
it "plugin's routing is used" do
|
381
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing")
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
context "when plugin's routing is NOT specified" do
|
387
|
+
context "when the event contains an integration metadata routing" do
|
388
|
+
let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) }
|
389
|
+
|
390
|
+
it "event's metadata routing is used" do
|
391
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "meta-document-routing")
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
context "when the event DOESN'T contain an integration metadata routing" do
|
396
|
+
it "plugin's default id mechanism is used" do
|
397
|
+
expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => nil)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
278
402
|
context "when plugin's index is specified" do
|
279
403
|
let(:options) { super().merge("index" => "index_from_settings")}
|
280
404
|
|
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.22.1
|
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-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|