logstash-input-dead_letter_queue 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +15 -0
- data/DEVELOPER.md +20 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/NOTICE.TXT +5 -0
- data/README.md +100 -0
- data/lib/logstash/inputs/dead_letter_queue.rb +74 -0
- data/logstash-input-dead_letter_queue.gemspec +27 -0
- data/spec/unit/inputs/dead_letter_queue_spec.rb +12 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9a9d666fbc7ae336aa2c0559581120cd101a7bc7
|
4
|
+
data.tar.gz: d5dfb0bcdecd94f14c6b94a2213125ecad415aeb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58dc4f906ebac0e344b8804aac88a498a14e51f584704714d6853fb3c9dc94a42011804ef2678735291ca618ddf9152146439adc121b96e423482256dbc80bed
|
7
|
+
data.tar.gz: a8118fd932a4e1cf06b454eda92754af425e109d0469c8af43c02abe83291579059943242886e011a3a2a3ac739163005a85f0bfb895fae9064d26c95bddf4a5
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Joseph Lawson (joekiller)
|
6
|
+
* Pere Urbón (purbon)
|
7
|
+
* Pier-Hugues Pellerin (ph)
|
8
|
+
* Richard Pijnenburg (electrical)
|
9
|
+
* Suyog Rao (suyograo)
|
10
|
+
* Tal Levy (talevy)
|
11
|
+
|
12
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
13
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
14
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
15
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
logstash-input-dead_letter_queue
|
2
|
+
====================
|
3
|
+
|
4
|
+
Logstash Dead Letter Queue Input Plugin, This plugin enables reading from Logstash's dead-letter-queue.
|
5
|
+
|
6
|
+
Logstash Configuration
|
7
|
+
====================
|
8
|
+
|
9
|
+
input {
|
10
|
+
dead_letter_queue {
|
11
|
+
path => ... # string (required) Path to dead letter queue directory containing segment files
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
This plugin uses its own decoding logic and ignores the `codec` options.
|
16
|
+
|
17
|
+
Dependencies
|
18
|
+
====================
|
19
|
+
|
20
|
+
* Logstash >= 5.4
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/NOTICE.TXT
ADDED
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-input-dead_letter_queue.svg)](https://travis-ci.org/logstash-plugins/logstash-input-dead_letter_queue)
|
4
|
+
|
5
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
|
+
|
7
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
8
|
+
|
9
|
+
## Documentation
|
10
|
+
|
11
|
+
https://www.elastic.co/guide/en/logstash/current/plugins-inputs-dead_letter_queue.html
|
12
|
+
|
13
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
14
|
+
|
15
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
16
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
17
|
+
|
18
|
+
## Need Help?
|
19
|
+
|
20
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
21
|
+
|
22
|
+
## Developing
|
23
|
+
|
24
|
+
### 1. Plugin Developement and Testing
|
25
|
+
|
26
|
+
#### Code
|
27
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
28
|
+
|
29
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
30
|
+
|
31
|
+
- Install dependencies
|
32
|
+
```sh
|
33
|
+
bundle install
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Test
|
37
|
+
|
38
|
+
- Update your dependencies
|
39
|
+
|
40
|
+
```sh
|
41
|
+
bundle install
|
42
|
+
```
|
43
|
+
|
44
|
+
- Run tests
|
45
|
+
|
46
|
+
```sh
|
47
|
+
bundle exec rspec
|
48
|
+
```
|
49
|
+
|
50
|
+
### 2. Running your unpublished Plugin in Logstash
|
51
|
+
|
52
|
+
#### 2.1 Run in a local Logstash clone
|
53
|
+
|
54
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
55
|
+
```ruby
|
56
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
57
|
+
```
|
58
|
+
- Install plugin
|
59
|
+
```sh
|
60
|
+
# Logstash 2.3 and higher
|
61
|
+
bin/logstash-plugin install --no-verify
|
62
|
+
|
63
|
+
# Prior to Logstash 2.3
|
64
|
+
bin/plugin install --no-verify
|
65
|
+
|
66
|
+
```
|
67
|
+
- Run Logstash with your plugin
|
68
|
+
```sh
|
69
|
+
bin/logstash -e 'filter {awesome {}}'
|
70
|
+
```
|
71
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
72
|
+
|
73
|
+
#### 2.2 Run in an installed Logstash
|
74
|
+
|
75
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
76
|
+
|
77
|
+
- Build your plugin gem
|
78
|
+
```sh
|
79
|
+
gem build logstash-filter-awesome.gemspec
|
80
|
+
```
|
81
|
+
- Install the plugin from the Logstash home
|
82
|
+
```sh
|
83
|
+
# Logstash 2.3 and higher
|
84
|
+
bin/logstash-plugin install --no-verify
|
85
|
+
|
86
|
+
# Prior to Logstash 2.3
|
87
|
+
bin/plugin install --no-verify
|
88
|
+
|
89
|
+
```
|
90
|
+
- Start Logstash and proceed to test the plugin
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
95
|
+
|
96
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
97
|
+
|
98
|
+
It is more important to the community that you are able to contribute.
|
99
|
+
|
100
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'logstash/namespace'
|
2
|
+
require 'logstash/inputs/base'
|
3
|
+
require 'logstash-input-dead_letter_queue.jar'
|
4
|
+
|
5
|
+
# Logstash input to read events from Logstash's dead letter queue
|
6
|
+
#
|
7
|
+
# [source, sh]
|
8
|
+
# -----------------------------------------
|
9
|
+
# input {
|
10
|
+
# dead_letter_queue {
|
11
|
+
# path => "/var/logstash/data/dead_letter_queue"
|
12
|
+
# timestamp => "2017-04-04T23:40:37"
|
13
|
+
# }
|
14
|
+
# }
|
15
|
+
# -----------------------------------------
|
16
|
+
#
|
17
|
+
class LogStash::Inputs::DeadLetterQueue < LogStash::Inputs::Base
|
18
|
+
config_name 'dead_letter_queue'
|
19
|
+
|
20
|
+
default :codec, 'plain'
|
21
|
+
|
22
|
+
# Path to the dead letter queue directory which was created by a Logstash instance.
|
23
|
+
# This is the path from where "dead" events are read from and is typically configured
|
24
|
+
# in the original Logstash instance with the setting path.dead_letter_queue.
|
25
|
+
config :path, :validate => :path, :required => true
|
26
|
+
# ID of the pipeline whose events you want to read from.
|
27
|
+
config :pipeline_id, :validate => :string, :default => "main"
|
28
|
+
# Path of the sincedb database file (keeps track of the current position of dead letter queue) that
|
29
|
+
# will be written to disk. The default will write sincedb files to `<path.data>/plugins/inputs/dead_letter_queue`
|
30
|
+
# NOTE: it must be a file path and not a directory path
|
31
|
+
config :sincedb_path, :validate => :string, :required => false
|
32
|
+
# Should this input commit offsets as it processes the events. `false` value is typically
|
33
|
+
# used when you want to iterate multiple times over the events in the dead letter queue, but don't want to
|
34
|
+
# save state. This is when you are exploring the events in the dead letter queue.
|
35
|
+
config :commit_offsets, :validate => :boolean, :default => true
|
36
|
+
# Timestamp in ISO8601 format from when you want to start processing the events from.
|
37
|
+
# For example, 2017-04-04T23:40:37
|
38
|
+
config :start_timestamp, :validate => :string, :required => false
|
39
|
+
|
40
|
+
public
|
41
|
+
def register
|
42
|
+
if @sincedb_path.nil?
|
43
|
+
datapath = File.join(LogStash::SETTINGS.get_value("path.data"), "plugins", "inputs", "dead_letter_queue", @pipeline_id)
|
44
|
+
# Ensure that the filepath exists before writing, since it's deeply nested.
|
45
|
+
FileUtils::mkdir_p datapath
|
46
|
+
@sincedb_path = File.join(datapath, ".sincedb_" + Digest::MD5.hexdigest(@path))
|
47
|
+
elsif File.directory?(@sincedb_path)
|
48
|
+
raise ArgumentError.new("The \"sincedb_path\" argument must point to a file, received a directory: \"#{@sincedb_path}\"")
|
49
|
+
end
|
50
|
+
|
51
|
+
dlq_path = java.nio.file.Paths.get(File.join(@path, @pipeline_id))
|
52
|
+
sincedb_path = @sincedb_path ? java.nio.file.Paths.get(@sincedb_path) : nil
|
53
|
+
start_timestamp = @start_timestamp ? org.logstash.Timestamp.new(@start_timestamp) : nil
|
54
|
+
@inner_plugin = org.logstash.input.DeadLetterQueueInputPlugin.new(dlq_path, @commit_offsets, sincedb_path, start_timestamp)
|
55
|
+
@inner_plugin.register
|
56
|
+
end # def register
|
57
|
+
|
58
|
+
public
|
59
|
+
def run(logstash_queue)
|
60
|
+
@inner_plugin.run do |entry|
|
61
|
+
event = LogStash::Event.new(entry.event.toMap())
|
62
|
+
event.set("[@metadata][dead_letter_queue][plugin_type]", entry.plugin_type)
|
63
|
+
event.set("[@metadata][dead_letter_queue][plugin_id]", entry.plugin_id)
|
64
|
+
event.set("[@metadata][dead_letter_queue][reason]", entry.reason)
|
65
|
+
event.set("[@metadata][dead_letter_queue][entry_time]", entry.entry_time)
|
66
|
+
logstash_queue << event
|
67
|
+
end
|
68
|
+
end # def run
|
69
|
+
|
70
|
+
public
|
71
|
+
def stop
|
72
|
+
@inner_plugin.close
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-dead_letter_queue'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = 'Logstash input to read dead lettered events'
|
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"
|
7
|
+
s.authors = ['Elastic']
|
8
|
+
s.email = 'info@elastic.co'
|
9
|
+
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*.rb','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
|
+
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { 'logstash_plugin' => 'true', 'group' => 'input'}
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
23
|
+
s.add_runtime_dependency 'logstash-codec-plain'
|
24
|
+
|
25
|
+
s.add_development_dependency 'logstash-devutils'
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/inputs/dead_letter_queue"
|
4
|
+
require "concurrent"
|
5
|
+
|
6
|
+
describe LogStash::Inputs::DeadLetterQueue do
|
7
|
+
subject { LogStash::Inputs::DeadLetterQueue.new(config) }
|
8
|
+
|
9
|
+
it "should register" do
|
10
|
+
expect {subject.register}.to_not raise_error
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-dead_letter_queue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elastic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.60'
|
19
|
+
- - "<="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.99'
|
22
|
+
name: logstash-core-plugin-api
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.60'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.99'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
name: logstash-codec-plain
|
40
|
+
prerelease: false
|
41
|
+
type: :runtime
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
name: logstash-devutils
|
54
|
+
prerelease: false
|
55
|
+
type: :development
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
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
|
62
|
+
email: info@elastic.co
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- CHANGELOG.md
|
68
|
+
- CONTRIBUTORS
|
69
|
+
- DEVELOPER.md
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- NOTICE.TXT
|
73
|
+
- README.md
|
74
|
+
- lib/logstash/inputs/dead_letter_queue.rb
|
75
|
+
- logstash-input-dead_letter_queue.gemspec
|
76
|
+
- spec/unit/inputs/dead_letter_queue_spec.rb
|
77
|
+
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
78
|
+
licenses:
|
79
|
+
- Apache License (2.0)
|
80
|
+
metadata:
|
81
|
+
logstash_plugin: 'true'
|
82
|
+
group: input
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.8
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Logstash input to read dead lettered events
|
103
|
+
test_files:
|
104
|
+
- spec/unit/inputs/dead_letter_queue_spec.rb
|