logstash-output-jms 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/NOTICE.TXT +5 -0
- data/README.md +95 -0
- data/lib/logstash/outputs/jms.rb +126 -0
- data/logstash-input-jms.gemspec +29 -0
- data/spec/outputs/jms.yml +18 -0
- data/spec/outputs/jms_spec.rb +35 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d86a4edf2e5572ad3d27982f750018be1dd9bb8
|
4
|
+
data.tar.gz: e3aea5a3055bc9217339df42de36d93e782c1f92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1567060b1bbcf72d8e217827af12ef53e47d74d52f99c57fd97b3d9ea46f28405adcfc9a7f67c0be61cb133ca50dc9d79076378064250a576b899552f76f4cd3
|
7
|
+
data.tar.gz: 5315b0a25c649ed3ff90128bfb53e35207ee991bfdc1139a3ce24cd0a8460d31862176762dbfbf143e66222021c11001e327384b5a7582b7b841fdfba1ba2dcb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
|
+
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
4
|
+
- Dependency on logstash-core update to 2.0
|
5
|
+
|
data/Gemfile
ADDED
data/NOTICE.TXT
ADDED
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
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/).
|
10
|
+
|
11
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
```sh
|
35
|
+
bundle exec rspec
|
36
|
+
```
|
37
|
+
|
38
|
+
The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
|
39
|
+
```ruby
|
40
|
+
gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
|
41
|
+
```
|
42
|
+
To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
|
43
|
+
```ruby
|
44
|
+
gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
|
45
|
+
```
|
46
|
+
```ruby
|
47
|
+
gem "logstash", :path => "/your/local/logstash"
|
48
|
+
```
|
49
|
+
|
50
|
+
Then update your dependencies and run your tests:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
bundle install
|
54
|
+
bundle exec rspec
|
55
|
+
```
|
56
|
+
|
57
|
+
### 2. Running your unpublished Plugin in Logstash
|
58
|
+
|
59
|
+
#### 2.1 Run in a local Logstash clone
|
60
|
+
|
61
|
+
- Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
|
62
|
+
```ruby
|
63
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
64
|
+
```
|
65
|
+
- Update Logstash dependencies
|
66
|
+
```sh
|
67
|
+
rake vendor:gems
|
68
|
+
```
|
69
|
+
- Run Logstash with your plugin
|
70
|
+
```sh
|
71
|
+
bin/logstash -e 'filter {awesome {}}'
|
72
|
+
```
|
73
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
74
|
+
|
75
|
+
#### 2.2 Run in an installed Logstash
|
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
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
84
|
+
```
|
85
|
+
- Start Logstash and proceed to test the plugin
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
90
|
+
|
91
|
+
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.
|
92
|
+
|
93
|
+
It is more important to me that you are able to contribute.
|
94
|
+
|
95
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/outputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
# Write events to a Jms Broker. Supports both Jms Queues and Topics.
|
6
|
+
#
|
7
|
+
# For more information about Jms, see <http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html>
|
8
|
+
# For more information about the Ruby Gem used, see <http://github.com/reidmorrison/jruby-jms>
|
9
|
+
# Here is a config example :
|
10
|
+
# jms {
|
11
|
+
# include_header => false
|
12
|
+
# include_properties => false
|
13
|
+
# include_body => true
|
14
|
+
# use_jms_timestamp => false
|
15
|
+
# queue_name => "myqueue"
|
16
|
+
# yaml_file => "~/jms.yml"
|
17
|
+
# yaml_section => "mybroker"
|
18
|
+
# }
|
19
|
+
#
|
20
|
+
#
|
21
|
+
class LogStash::Outputs::Jms < LogStash::Outputs::Base
|
22
|
+
config_name "jms"
|
23
|
+
|
24
|
+
# Name of delivery mode to use
|
25
|
+
# Options are "persistent" and "non_persistent" if not defined nothing will be passed.
|
26
|
+
config :delivery_mode, :validate => :string, :default => nil
|
27
|
+
|
28
|
+
# If pub-sub (topic) style should be used or not.
|
29
|
+
# Mandatory
|
30
|
+
config :pub_sub, :validate => :boolean, :default => false
|
31
|
+
# Name of the destination queue or topic to use.
|
32
|
+
# Mandatory
|
33
|
+
config :destination, :validate => :string
|
34
|
+
|
35
|
+
# Yaml config file
|
36
|
+
config :yaml_file, :validate => :string
|
37
|
+
# Yaml config file section name
|
38
|
+
# For some known examples, see: [Example jms.yml](https://github.com/reidmorrison/jruby-jms/blob/master/examples/jms.yml)
|
39
|
+
config :yaml_section, :validate => :string
|
40
|
+
|
41
|
+
# If you do not use an yaml configuration use either the factory or jndi_name.
|
42
|
+
|
43
|
+
# An optional array of Jar file names to load for the specified
|
44
|
+
# JMS provider. By using this option it is not necessary
|
45
|
+
# to put all the JMS Provider specific jar files into the
|
46
|
+
# java CLASSPATH prior to starting Logstash.
|
47
|
+
config :require_jars, :validate => :array
|
48
|
+
|
49
|
+
# Name of JMS Provider Factory class
|
50
|
+
config :factory, :validate => :string
|
51
|
+
# Username to connect to JMS provider with
|
52
|
+
config :username, :validate => :string
|
53
|
+
# Password to use when connecting to the JMS provider
|
54
|
+
config :password, :validate => :string
|
55
|
+
# Url to use when connecting to the JMS provider
|
56
|
+
config :broker_url, :validate => :string
|
57
|
+
|
58
|
+
# Name of JNDI entry at which the Factory can be found
|
59
|
+
config :jndi_name, :validate => :string
|
60
|
+
# Mandatory if jndi lookup is being used,
|
61
|
+
# contains details on how to connect to JNDI server
|
62
|
+
config :jndi_context, :validate => :hash
|
63
|
+
|
64
|
+
# :yaml_file, :factory and :jndi_name are mutually exclusive, both cannot be supplied at the
|
65
|
+
# same time. The priority order is :yaml_file, then :jndi_name, then :factory
|
66
|
+
#
|
67
|
+
# JMS Provider specific properties can be set if the JMS Factory itself
|
68
|
+
# has setters for those properties.
|
69
|
+
#
|
70
|
+
# For some known examples, see: [Example jms.yml](https://github.com/reidmorrison/jruby-jms/blob/master/examples/jms.yml)
|
71
|
+
|
72
|
+
public
|
73
|
+
def register
|
74
|
+
require "jms"
|
75
|
+
@connection = nil
|
76
|
+
|
77
|
+
if @yaml_file
|
78
|
+
@jms_config = YAML.load_file(@yaml_file)[@yaml_section]
|
79
|
+
|
80
|
+
elsif @jndi_name
|
81
|
+
@jms_config = {
|
82
|
+
:require_jars => @require_jars,
|
83
|
+
:jndi_name => @jndi_name,
|
84
|
+
:jndi_context => @jndi_context}
|
85
|
+
|
86
|
+
elsif @factory
|
87
|
+
@jms_config = {
|
88
|
+
:require_jars => @require_jars,
|
89
|
+
:factory => @factory,
|
90
|
+
:username => @username,
|
91
|
+
:password => @password,
|
92
|
+
:broker_url => @broker_url,
|
93
|
+
:url => @broker_url # "broker_url" is named "url" with Oracle AQ
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
@logger.debug("JMS Config being used", :context => @jms_config)
|
98
|
+
@connection = JMS::Connection.new(@jms_config)
|
99
|
+
@session = @connection.create_session()
|
100
|
+
|
101
|
+
# Cache the producer since we should keep reusing this one.
|
102
|
+
destination_key = @pub_sub ? :topic_name : :queue_name
|
103
|
+
@producer = @session.create_producer(@session.create_destination(destination_key => @destination))
|
104
|
+
|
105
|
+
if !@delivery_mode.nil?
|
106
|
+
@producer.delivery_mode_sym = @deliver_mode
|
107
|
+
end
|
108
|
+
end # def register
|
109
|
+
|
110
|
+
def receive(event)
|
111
|
+
|
112
|
+
|
113
|
+
begin
|
114
|
+
@producer.send(@session.message(event.to_json))
|
115
|
+
rescue => e
|
116
|
+
@logger.warn("Failed to send event to JMS", :event => event, :exception => e,
|
117
|
+
:backtrace => e.backtrace)
|
118
|
+
end
|
119
|
+
end # def receive
|
120
|
+
|
121
|
+
def close
|
122
|
+
@producer.close()
|
123
|
+
@session.close()
|
124
|
+
@connection.close()
|
125
|
+
end
|
126
|
+
end # class LogStash::Output::Jms
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-output-jms'
|
4
|
+
s.version = '2.0.1'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "Push events to a JMS topic or queue."
|
7
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
8
|
+
s.authors = ["Elasticsearch"]
|
9
|
+
s.email = 'info@elasticsearch.com'
|
10
|
+
s.homepage = "http://www.elasticsearch.org/guide/en/logstash/current/index.html"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
21
|
+
|
22
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
|
23
|
+
|
24
|
+
s.add_runtime_dependency 'logstash-codec-plain'
|
25
|
+
s.add_runtime_dependency 'logstash-codec-json'
|
26
|
+
|
27
|
+
s.add_runtime_dependency "jruby-jms" #(Apache 2.0 license)
|
28
|
+
s.add_development_dependency 'logstash-devutils'
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
# HornetQ Broker
|
3
|
+
hornetq:
|
4
|
+
# Connect to a local HornetQ Broker using JNDI
|
5
|
+
:jndi_name: /ConnectionFactory
|
6
|
+
:jndi_context:
|
7
|
+
java.naming.factory.initial: org.jnp.interfaces.NamingContextFactory
|
8
|
+
java.naming.provider.url: jnp://localhost:1099
|
9
|
+
java.naming.factory.url.pkgs: org.jboss.naming:org.jnp.interfaces
|
10
|
+
java.naming.security.principal: guest
|
11
|
+
java.naming.security.credentials: guest
|
12
|
+
:require_jars:
|
13
|
+
- /Applications/hornetq-2.4.0.Final/lib/hornetq-commons.jar
|
14
|
+
- /Applications/hornetq-2.4.0.Final/lib/hornetq-core-client.jar
|
15
|
+
- /Applications/hornetq-2.4.0.Final/lib/hornetq-jms-client.jar
|
16
|
+
- /Applications/hornetq-2.4.0.Final/lib/jboss-jms-api.jar
|
17
|
+
- /Applications/hornetq-2.4.0.Final/lib/jnp-client.jar
|
18
|
+
- /Applications/hornetq-2.4.0.Final/lib/netty.jar
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require 'logstash/outputs/jms'
|
3
|
+
require 'jms'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
def getYamlPath()
|
7
|
+
return File.join(File.dirname(__FILE__),"jms.yml")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "outputs/jms" do
|
11
|
+
let (:jms_config) {{'yaml_file' => getYamlPath(), 'yaml_section' => 'hornetq', 'destination' => 'ExampleQueue'}}
|
12
|
+
let (:event) { LogStash::Event.new({'message' => 'hello',
|
13
|
+
'@timestamp' => LogStash::Timestamp.now}) }
|
14
|
+
|
15
|
+
context 'when initializing' do
|
16
|
+
it "should register" do
|
17
|
+
output = LogStash::Plugin.lookup("output", "jms").new(jms_config)
|
18
|
+
expect {output.register}.to_not raise_error
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should populate jms config with default values' do
|
22
|
+
jms = LogStash::Outputs::Jms.new(jms_config)
|
23
|
+
expect(jms.pub_sub).to eq(false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when outputting messages' do
|
28
|
+
it 'should send logstash event to jms queue' do
|
29
|
+
jms = LogStash::Outputs::Jms.new(jms_config)
|
30
|
+
jms.register
|
31
|
+
jms.receive(event)
|
32
|
+
# Add code to check the message is correct on the queue.
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-jms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elasticsearch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-08 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: 2.0.0.snapshot
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0.snapshot
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
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-codec-json
|
54
|
+
prerelease: false
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
name: jruby-jms
|
68
|
+
prerelease: false
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
name: logstash-devutils
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
90
|
+
email: info@elasticsearch.com
|
91
|
+
executables: []
|
92
|
+
extensions: []
|
93
|
+
extra_rdoc_files: []
|
94
|
+
files:
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- NOTICE.TXT
|
98
|
+
- README.md
|
99
|
+
- lib/logstash/outputs/jms.rb
|
100
|
+
- logstash-input-jms.gemspec
|
101
|
+
- spec/outputs/jms.yml
|
102
|
+
- spec/outputs/jms_spec.rb
|
103
|
+
homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
|
104
|
+
licenses:
|
105
|
+
- Apache License (2.0)
|
106
|
+
metadata:
|
107
|
+
logstash_plugin: 'true'
|
108
|
+
logstash_group: output
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.8
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Push events to a JMS topic or queue.
|
129
|
+
test_files:
|
130
|
+
- spec/outputs/jms.yml
|
131
|
+
- spec/outputs/jms_spec.rb
|