logstash-input-dead_letter_queue 1.1.10 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/VERSION +1 -1
- data/docs/index.asciidoc +11 -0
- data/lib/logstash/inputs/dead_letter_queue.rb +39 -13
- data/lib/logstash-input-dead_letter_queue_jars.rb +1 -1
- data/logstash-input-dead_letter_queue.gemspec +1 -0
- data/spec/unit/inputs/dead_letter_queue_spec.rb +20 -2
- data/vendor/jar-dependencies/co/elastic/logstash/input/logstash-input-dead_letter_queue/2.0.0/logstash-input-dead_letter_queue-2.0.0.jar +0 -0
- metadata +17 -3
- data/vendor/jar-dependencies/co/elastic/logstash/input/logstash-input-dead_letter_queue/1.1.10/logstash-input-dead_letter_queue-1.1.10.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74a1df427003005bd0dd003bc442972a121506015a5af557cf4bd57abd50583f
|
4
|
+
data.tar.gz: 5b4b3938771f70157e5cf75e3a6bfafaf4a09de38870f406dfefc52384eb0908
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 726aebf62f60482362ee246e681be965b6f97c9721a66a514705687058e3223b89802d829e88e63e9a49c29920d705e40fcd4554757b442b4529290f241fb691
|
7
|
+
data.tar.gz: bada6c2af097fb986d684cdb5c5c8b336c131e4ec8fac09c53928430a3c28dbba91ab1efcf403c415f98529ecc907e841549b4c91b505dd86ee557d15fe7cc80
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
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
|
+
|
5
|
+
## 1.1.12
|
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)
|
7
|
+
- Refactor: separated sinceDb management is its separate class [#40](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/40)
|
8
|
+
- Build: cleanup/review (unused) dependencies [#36](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/36)
|
9
|
+
- Build: refactor tasks (runnable on windows) [#37](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/37)
|
10
|
+
|
11
|
+
## 1.1.11
|
12
|
+
- Fix: pre-flight checks before creating DLQ reader [#35](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/35)
|
13
|
+
|
1
14
|
## 1.1.10
|
2
15
|
- Fix, avoid Logstash crash on shutdown if DLQ files weren't created [#33](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/33)
|
16
|
+
|
3
17
|
## 1.1.9
|
4
18
|
- Fix `@metadata` get overwritten by reestablishing metadata that stored in DLQ [#34](https://github.com/logstash-plugins/logstash-input-dead_letter_queue/pull/34)
|
5
19
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
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
|
|
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
|
|
@@ -2,6 +2,8 @@ require 'logstash/namespace'
|
|
2
2
|
require 'logstash/inputs/base'
|
3
3
|
require 'logstash-input-dead_letter_queue_jars'
|
4
4
|
|
5
|
+
require 'fileutils'
|
6
|
+
|
5
7
|
# Logstash input to read events from Logstash's dead letter queue
|
6
8
|
#
|
7
9
|
# [source, sh]
|
@@ -19,6 +21,11 @@ class LogStash::Inputs::DeadLetterQueue < LogStash::Inputs::Base
|
|
19
21
|
|
20
22
|
default :codec, 'plain'
|
21
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
|
22
29
|
# Path to the dead letter queue directory which was created by a Logstash instance.
|
23
30
|
# This is the path from where "dead" events are read from and is typically configured
|
24
31
|
# in the original Logstash instance with the setting path.dead_letter_queue.
|
@@ -45,35 +52,54 @@ class LogStash::Inputs::DeadLetterQueue < LogStash::Inputs::Base
|
|
45
52
|
FileUtils::mkdir_p datapath
|
46
53
|
@sincedb_path = File.join(datapath, ".sincedb_" + Digest::MD5.hexdigest(@path))
|
47
54
|
elsif File.directory?(@sincedb_path)
|
48
|
-
|
55
|
+
raise ArgumentError.new("The \"sincedb_path\" argument must point to a file, received a directory: \"#{@sincedb_path}\"")
|
49
56
|
end
|
50
57
|
|
51
58
|
dlq_path = java.nio.file.Paths.get(File.join(@path, @pipeline_id))
|
52
59
|
sincedb_path = @sincedb_path ? java.nio.file.Paths.get(@sincedb_path) : nil
|
53
60
|
start_timestamp = @start_timestamp ? org.logstash.Timestamp.new(@start_timestamp) : nil
|
54
|
-
|
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)
|
55
77
|
@inner_plugin.register
|
78
|
+
|
79
|
+
if Gem::Requirement.new('< 7.0').satisfied_by?(logstash_version)
|
80
|
+
@event_creator = Proc.new do |entry|
|
81
|
+
clone = entry.event.clone
|
82
|
+
# LS 6 LogStash::Event.new accept Map not Event
|
83
|
+
event = LogStash::Event.new(clone.getData())
|
84
|
+
event.set("[@metadata]", clone.getMetadata())
|
85
|
+
event
|
86
|
+
end
|
87
|
+
else
|
88
|
+
@event_creator = -> (entry) { LogStash::Event.new(entry.event.clone) }
|
89
|
+
end
|
56
90
|
end # def register
|
57
91
|
|
58
92
|
public
|
59
93
|
def run(logstash_queue)
|
60
|
-
@inner_plugin.run do |entry|
|
61
|
-
|
62
|
-
event = if Gem::Requirement.new('< 7.0').satisfied_by?(Gem::Version.new(LOGSTASH_CORE_VERSION))
|
63
|
-
# LS 6 LogStash::Event.new accept Map not Event
|
64
|
-
event = LogStash::Event.new(clone.getData())
|
65
|
-
event.set("[@metadata]", clone.getMetadata())
|
66
|
-
event
|
67
|
-
else
|
68
|
-
LogStash::Event.new(clone)
|
69
|
-
end
|
94
|
+
@inner_plugin.run(lambda do |entry|
|
95
|
+
event = @event_creator.(entry)
|
70
96
|
event.set("[@metadata][dead_letter_queue][plugin_type]", entry.plugin_type)
|
71
97
|
event.set("[@metadata][dead_letter_queue][plugin_id]", entry.plugin_id)
|
72
98
|
event.set("[@metadata][dead_letter_queue][reason]", entry.reason)
|
73
99
|
event.set("[@metadata][dead_letter_queue][entry_time]", entry.entry_time)
|
74
100
|
decorate(event)
|
75
101
|
logstash_queue << event
|
76
|
-
end
|
102
|
+
end)
|
77
103
|
end # def run
|
78
104
|
|
79
105
|
public
|
@@ -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(
|
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")) }
|
Binary file
|
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:
|
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-02
|
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/
|
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)
|