logstash-input-dead_letter_queue 1.1.12 → 2.0.0

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: 4822656326d51f27c599ae21d09ed972c06983270b747303bf3725a219e46ecc
4
- data.tar.gz: bd3eb2dba2a634b84011df4c6ae2a039752cab829fb41620e29d98329f32b7de
3
+ metadata.gz: 74a1df427003005bd0dd003bc442972a121506015a5af557cf4bd57abd50583f
4
+ data.tar.gz: 5b4b3938771f70157e5cf75e3a6bfafaf4a09de38870f406dfefc52384eb0908
5
5
  SHA512:
6
- metadata.gz: cbe712e8376bd07c7da38ab5524a8c81f3bb55df28524a88d652a312caa8c4f4d6a5487e72979541d3f201d0e4f5009625040a9f63a58ecf795c62136b8bb80c
7
- data.tar.gz: 316038e10f17e8e4175d61d31fd107c690d6ad083e4e2678016e347c91bcf96739f73e9614fd67075f54a7f6ec66d680ba0fa85f7e88ef4d26078810b962a985
6
+ metadata.gz: 726aebf62f60482362ee246e681be965b6f97c9721a66a514705687058e3223b89802d829e88e63e9a49c29920d705e40fcd4554757b442b4529290f241fb691
7
+ data.tar.gz: bada6c2af097fb986d684cdb5c5c8b336c131e4ec8fac09c53928430a3c28dbba91ab1efcf403c415f98529ecc907e841549b4c91b505dd86ee557d15fe7cc80
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.0.0
2
+ - Introduce the boolean `clean_consumed` setting to enable the automatic removal of completely consumed segments. Requires Logstash 8.4.0 or above [#43](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/43)
3
+ - Exposes metrics about segments and events cleaned by this plugin [#45](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/45)
4
+
1
5
  ## 1.1.12
2
6
  - Fix: Replace use of block with lambda to fix wrong number of arguments error on jruby-9.3.4.0 [#42](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/42)
3
7
  - Refactor: separated sinceDb management is its separate class [#40](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/40)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.12
1
+ 2.0.0
data/docs/index.asciidoc CHANGED
@@ -45,6 +45,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
45
45
  [cols="<,<,<",options="header",]
46
46
  |=======================================================================
47
47
  |Setting |Input type|Required
48
+ | <<plugins-{type}s-{plugin}-clean_consumed>> |<<boolean,boolean>>|No
48
49
  | <<plugins-{type}s-{plugin}-commit_offsets>> |<<boolean,boolean>>|No
49
50
  | <<plugins-{type}s-{plugin}-path>> |a valid filesystem path|Yes
50
51
  | <<plugins-{type}s-{plugin}-pipeline_id>> |<<string,string>>|No
@@ -57,6 +58,16 @@ input plugins.
57
58
 
58
59
  &nbsp;
59
60
 
61
+ [id="plugins-{type}s-{plugin}-clean_consumed"]
62
+ ===== `clean_consumed`
63
+
64
+ * Value type is <<boolean,boolean>>
65
+ * Default value is `false`
66
+
67
+ When set to `true`, this option deletes the DLQ segments that have been read.
68
+ This feature requires that `commit_offsets` is set to `true`. If not, you'll get a configuration error.
69
+ This feature is available in Logstash 8.4.0 and later. If this setting is `true` and and you are using a Logstash version older than 8.4.0, then you'll get a configuration error.
70
+
60
71
  [id="plugins-{type}s-{plugin}-commit_offsets"]
61
72
  ===== `commit_offsets`
62
73
 
@@ -21,6 +21,11 @@ class LogStash::Inputs::DeadLetterQueue < LogStash::Inputs::Base
21
21
 
22
22
  default :codec, 'plain'
23
23
 
24
+ # If true deletes the DLQ segments that has been processed.
25
+ # Supported only Logstash >= 8.4.0
26
+ # If this setting is `true` and Logstash version doesn't provides this feature then result in a configuration error.
27
+ # This feature implicitly requires that the `commit_offsets` option is set to `true`. Iif it's not then you'll get a configuration error.
28
+ config :clean_consumed, :validate => :boolean, :default => false
24
29
  # Path to the dead letter queue directory which was created by a Logstash instance.
25
30
  # This is the path from where "dead" events are read from and is typically configured
26
31
  # in the original Logstash instance with the setting path.dead_letter_queue.
@@ -53,10 +58,25 @@ class LogStash::Inputs::DeadLetterQueue < LogStash::Inputs::Base
53
58
  dlq_path = java.nio.file.Paths.get(File.join(@path, @pipeline_id))
54
59
  sincedb_path = @sincedb_path ? java.nio.file.Paths.get(@sincedb_path) : nil
55
60
  start_timestamp = @start_timestamp ? org.logstash.Timestamp.new(@start_timestamp) : nil
56
- @inner_plugin = org.logstash.input.DeadLetterQueueInputPlugin.new(dlq_path, @commit_offsets, sincedb_path, start_timestamp)
61
+ logstash_version = Gem::Version.new(LOGSTASH_CORE_VERSION)
62
+ if clean_consumed && !Gem::Requirement.new('>= 8.4.0').satisfied_by?(logstash_version)
63
+ raise LogStash::ConfigurationError.new("clean_consumed can be used only with Logstash version 8.4.0 and above")
64
+ end
65
+ if clean_consumed && !commit_offsets
66
+ # clean_consumed requires the commit of offset
67
+ raise LogStash::ConfigurationError.new("enabling clean_consumed requires commit_offsets to also be enabled")
68
+ end
69
+ @cleaned_metrics = metric.namespace(@pipeline_id)
70
+ @inner_plugin = org.logstash.input.DeadLetterQueueInputPlugin.new(dlq_path, @commit_offsets, sincedb_path, start_timestamp, clean_consumed,
71
+ lambda do |segments, events|
72
+ # gauges is used instead of metric type because the updates that comes from the
73
+ # DLQ reader are already absolute values and not deltas.
74
+ @cleaned_metrics.gauge(:cleaned_segments, segments)
75
+ @cleaned_metrics.gauge(:cleaned_events, events)
76
+ end)
57
77
  @inner_plugin.register
58
78
 
59
- if Gem::Requirement.new('< 7.0').satisfied_by?(Gem::Version.new(LOGSTASH_CORE_VERSION))
79
+ if Gem::Requirement.new('< 7.0').satisfied_by?(logstash_version)
60
80
  @event_creator = Proc.new do |entry|
61
81
  clone = entry.event.clone
62
82
  # LS 6 LogStash::Event.new accept Map not Event
@@ -1,4 +1,4 @@
1
1
  # AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
2
2
 
3
3
  require 'jar_dependencies'
4
- require_jar('co.elastic.logstash.input', 'logstash-input-dead_letter_queue', '1.1.12')
4
+ require_jar('co.elastic.logstash.input', 'logstash-input-dead_letter_queue', '2.0.0')
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.metadata = { 'logstash_plugin' => 'true', 'group' => 'input'}
22
22
 
23
23
  # Gem dependencies
24
+ s.add_runtime_dependency 'logstash-core', '>= 8.4.0'
24
25
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
25
26
  s.add_runtime_dependency 'logstash-codec-plain'
26
27
 
@@ -7,9 +7,12 @@ describe LogStash::Inputs::DeadLetterQueue do
7
7
  let(:pipeline_id) { SecureRandom.hex(8)}
8
8
  let(:path) { Dir.tmpdir }
9
9
  let(:directory) { File.join(path, pipeline_id)}
10
+ let(:config) do
11
+ { "path" => path,
12
+ "pipeline_id" => pipeline_id}
13
+ end
10
14
 
11
- subject { LogStash::Inputs::DeadLetterQueue.new({ "path" => path,
12
- "pipeline_id" => pipeline_id}) }
15
+ subject { LogStash::Inputs::DeadLetterQueue.new(config) }
13
16
 
14
17
  before(:each) do
15
18
  Dir.mkdir(directory)
@@ -23,6 +26,21 @@ describe LogStash::Inputs::DeadLetterQueue do
23
26
  FileUtils.remove_entry_secure directory
24
27
  end
25
28
 
29
+ context "when clean_consumed is enabled" do
30
+ let(:config) { super().merge!("clean_consumed" => true) }
31
+
32
+ it "registers successfully" do
33
+ expect {subject.register}.to_not raise_error
34
+ end
35
+
36
+ context "and commit_offsets is not" do
37
+ let(:config) { super().merge!("commit_offsets" => false) }
38
+ it "raises a configuration error during register" do
39
+ expect {subject.register}.to raise_error(LogStash::ConfigurationError)
40
+ end
41
+ end
42
+ end
43
+
26
44
  context 'test with real DLQ file' do
27
45
  let(:dlq_dir) { Stud::Temporary.directory }
28
46
  let(:fixture_dir) { File.expand_path(File.join(File.dirname(__FILE__),"fixtures", "main")) }
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-dead_letter_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.12
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.4.0
19
+ name: logstash-core
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 8.4.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  requirement: !ruby/object:Gem::Requirement
15
29
  requirements:
@@ -80,7 +94,7 @@ files:
80
94
  - logstash-input-dead_letter_queue.gemspec
81
95
  - spec/unit/inputs/dead_letter_queue_spec.rb
82
96
  - spec/unit/inputs/fixtures/main/1.log
83
- - vendor/jar-dependencies/co/elastic/logstash/input/logstash-input-dead_letter_queue/1.1.12/logstash-input-dead_letter_queue-1.1.12.jar
97
+ - vendor/jar-dependencies/co/elastic/logstash/input/logstash-input-dead_letter_queue/2.0.0/logstash-input-dead_letter_queue-2.0.0.jar
84
98
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
85
99
  licenses:
86
100
  - Apache License (2.0)