logstash-output-elasticsearch 11.21.0-java → 11.22.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 670f82b7bbfea1744a5daaf77a069c8872f87e1b15226131a786f826a931cd9c
4
- data.tar.gz: 9aa78b93f19d995562192466ad7b816870706383da69b5050613079a76cd1e92
3
+ metadata.gz: 717e2454d150e9f3ae5c7ad9a7cd6d7e4e4451f538e276c1fa1e42a0b6c37f71
4
+ data.tar.gz: 714e7b7df621a80edd1a0e3eb0978b7a5b8a3789b2652e76c3336fcf8b7a6dfe
5
5
  SHA512:
6
- metadata.gz: 71d5c1b1558c4ba2c0bb29ab761980dfaad7005410a5bda436ac7f1d6a637b523aa058176e14eed491e8ffb99503f963c2eb5a9c3423e3d7ebd550f74902913e
7
- data.tar.gz: aa32f8838b2526ae3fbcd3288ef6f848c90d926b0206416c5f2c348855e98494e36721ad9992cfbc238290a7c3e5baa90a518208c4b5cdc6187a80918f7b8716
6
+ metadata.gz: 4d84c7f34a39b0566770881161f50c41f1270ab94131d6d70a35f4264a8e32631ac2da4e607dc61acc565b8e2ab87ca539949046233bce135ffc52c2caf6870e
7
+ data.tar.gz: b544f8e2e0f577970464e1bf72adda1e10254c361e3c749c0bfd84ca0184e59736d53dc5e6891f8e8369d2cc101a87af661aec90cc3038aaf2261893cf25eba2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 11.22.0
2
+ - 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)
3
+
1
4
  ## 11.21.0
2
5
  - 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
6
 
@@ -499,9 +499,6 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
499
499
  params[retry_on_conflict_action_name] = @retry_on_conflict
500
500
  end
501
501
 
502
- params[:version] = event.sprintf(@version) if @version
503
- params[:version_type] = event.sprintf(@version_type) if @version_type
504
-
505
502
  EventActionTuple.new(action, params, event)
506
503
  end
507
504
 
@@ -541,12 +538,12 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
541
538
  # @private shared event params factory between index and data_stream mode
542
539
  def common_event_params(event)
543
540
  event_control = event.get("[@metadata][_ingest_document]")
544
- event_id, event_pipeline, event_index = event_control&.values_at("id","pipeline","index") rescue nil
541
+ event_id, event_pipeline, event_index, event_routing, event_version, event_version_type = event_control&.values_at("id","pipeline","index", "routing", "version", "version_type") rescue nil
545
542
 
546
543
  params = {
547
544
  :_id => resolve_document_id(event, event_id),
548
545
  :_index => resolve_index!(event, event_index),
549
- routing_field_name => @routing ? event.sprintf(@routing) : nil
546
+ routing_field_name => resolve_routing(event, event_routing)
550
547
  }
551
548
 
552
549
  target_pipeline = resolve_pipeline(event, event_pipeline)
@@ -557,9 +554,33 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
557
554
  # }
558
555
  params[:pipeline] = target_pipeline unless (target_pipeline.nil? || target_pipeline.empty?)
559
556
 
557
+ resolved_version = resolve_version(event, event_version)
558
+ resolved_version_type = resolve_version_type(event, event_version_type)
559
+ # avoid to add nil valued key-value pairs
560
+ params[:version] = resolved_version unless resolved_version.nil?
561
+ params[:version_type] = resolved_version_type unless resolved_version_type.nil?
562
+
560
563
  params
561
564
  end
562
565
 
566
+ def resolve_version(event, event_version)
567
+ return event_version if event_version && !@version
568
+ event.sprintf(@version) if @version
569
+ end
570
+ private :resolve_version
571
+
572
+ def resolve_version_type(event, event_version_type)
573
+ return event_version_type if event_version_type && !@version_type
574
+ event.sprintf(@version_type) if @version_type
575
+ end
576
+ private :resolve_version_type
577
+
578
+ def resolve_routing(event, event_routing)
579
+ return event_routing if event_routing && !@routing
580
+ @routing ? event.sprintf(@routing) : nil
581
+ end
582
+ private :resolve_routing
583
+
563
584
  def resolve_document_id(event, event_id)
564
585
  return event.sprintf(@document_id) if @document_id
565
586
  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.21.0'
3
+ s.version = '11.22.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"
@@ -275,6 +275,108 @@ 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
+ it "event's metadata version is used" do
301
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "456")
302
+ end
303
+ end
304
+
305
+ context "when the event DOESN'T contain an integration metadata version" do
306
+ it "plugin's default id mechanism is used" do
307
+ expect(subject.send(:event_action_tuple, event)[1]).to_not include(:version)
308
+ end
309
+ end
310
+ end
311
+
312
+ context "when plugin's version_type is specified" do
313
+ let(:options) { super().merge("version_type" => "internal")}
314
+
315
+ context "when the event contains an integration metadata version_type" do
316
+ let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) }
317
+
318
+ it "plugin's version_type is used" do
319
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal")
320
+ end
321
+ end
322
+
323
+ context "when the event DOESN'T contains an integration metadata version_type" do
324
+ it "plugin's version_type is used" do
325
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal")
326
+ end
327
+ end
328
+ end
329
+
330
+ context "when plugin's version_type is NOT specified" do
331
+ context "when the event contains an integration metadata version_type" do
332
+ let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) }
333
+
334
+ it "event's metadata version_type is used" do
335
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "external")
336
+ end
337
+ end
338
+
339
+ context "when the event DOESN'T contain an integration metadata version_type" do
340
+ it "plugin's default id mechanism is used" do
341
+ expect(subject.send(:event_action_tuple, event)[1]).to_not include(:version_type)
342
+ end
343
+ end
344
+ end
345
+
346
+ context "when plugin's routing is specified" do
347
+ let(:options) { super().merge("routing" => "settings_routing")}
348
+
349
+ context "when the event contains an integration metadata routing" do
350
+ let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) }
351
+
352
+ it "plugin's routing is used" do
353
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing")
354
+ end
355
+ end
356
+
357
+ context "when the event DOESN'T contains an integration metadata routing" do
358
+ it "plugin's routing is used" do
359
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing")
360
+ end
361
+ end
362
+ end
363
+
364
+ context "when plugin's routing is NOT specified" do
365
+ context "when the event contains an integration metadata routing" do
366
+ let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) }
367
+
368
+ it "event's metadata routing is used" do
369
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "meta-document-routing")
370
+ end
371
+ end
372
+
373
+ context "when the event DOESN'T contain an integration metadata routing" do
374
+ it "plugin's default id mechanism is used" do
375
+ expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => nil)
376
+ end
377
+ end
378
+ end
379
+
278
380
  context "when plugin's index is specified" do
279
381
  let(:options) { super().merge("index" => "index_from_settings")}
280
382
 
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.21.0
4
+ version: 11.22.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-10 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement