logstash-filter-zeromq 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: e3dcdef0b8b0bcd244c53f52988a55af838825ef
4
- data.tar.gz: 0d5bf5f6fa3781c2a0a9d7a82dd312d882e4cf59
3
+ metadata.gz: 3336ef335289b2e7206f8ba04432bf589503e9f5
4
+ data.tar.gz: bcc8a759d9c2b371e073420b02046d6b157730be
5
5
  SHA512:
6
- metadata.gz: 936eff3ec8d09106d1186e69a5efc0f689b221961eebb18dc2b4f2d8b03e595da41314ca4c9c7cc19d2384b97400426e702528c5ab6bf009e9f54f158f03c7d9
7
- data.tar.gz: d53c4b023a10ac06d8726d0a6f9171a503de0fe74a538550f8543374eeddc3fec2397eb324752a58290a956e1ba617d3b317238287b163b4c82cc0953022cafa
6
+ metadata.gz: 63a39e68ce51e635d9c3cfd1401c2c29e5f2d2b0d12e8b46bcebf11b3cca6f283448b908bb04ba5876cb89e5a15ad90cfdbee88bcda52a64ed8cf9cd87df0efd
7
+ data.tar.gz: c1513c4c39cd5700a55e2670299bb1a092b608bb362a50bb404c7dcdcc717e6f6a936274cae5820a57f41a9e605f4942edaf0eabc0b449aa655a5084e5ef666d
data/CONTRIBUTORS ADDED
@@ -0,0 +1,17 @@
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
+ * Aaron Mildenstein (untergeek)
6
+ * Colin Surprenant (colinsurprenant)
7
+ * John E. Vincent (lusis)
8
+ * Jordan Sissel (jordansissel)
9
+ * Pete Fritchman (fetep)
10
+ * Pier-Hugues Pellerin (ph)
11
+ * Richard Pijnenburg (electrical)
12
+ * Tom Howe (turtlebender)
13
+
14
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
15
+ Logstash, and you aren't on the list above and want to be, please let us know
16
+ and we'll make sure you're here. Contributions from folks like you are what make
17
+ open source awesome.
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
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/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/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.elasticsearch.org/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/elasticsearch/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/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/filters/base"
3
3
  require "logstash/namespace"
4
+ require "logstash/json"
4
5
 
5
6
  # ZeroMQ filter. This is the best way to send an event externally for filtering
6
7
  # It works much like an exec filter would by sending the event "offsite"
@@ -13,11 +14,10 @@ require "logstash/namespace"
13
14
  #
14
15
  # Note that this is a limited subset of the zeromq functionality in
15
16
  # inputs and outputs. The only topology that makes sense here is:
16
- # REQ/REP.
17
+ # REQ/REP. bunde
17
18
  class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
18
19
 
19
20
  config_name "zeromq"
20
- milestone 1
21
21
 
22
22
  # 0mq socket address to connect or bind
23
23
  # Please note that inproc:// will not work with logstash
@@ -38,10 +38,10 @@ class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
38
38
 
39
39
  # timeout in milliseconds on which to wait for a reply.
40
40
  config :timeout, :validate => :number, :default => 500
41
-
41
+
42
42
  # number of retries, used for both sending and receiving messages.
43
43
  # for sending, retries should return instantly.
44
- # for receiving, the total blocking time is up to retries X timeout,
44
+ # for receiving, the total blocking time is up to retries X timeout,
45
45
  # which by default is 3 X 500 = 1500ms
46
46
  config :retries, :validate => :number, :default => 3
47
47
 
@@ -118,13 +118,13 @@ class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
118
118
  #will return a boolean for success, and a string containing one of several things:
119
119
  # - empty string: response from server
120
120
  # - updated string: response from server
121
- # - original message: could not send request or get response from server in time
121
+ # - original message: could not send request or get response from server in time
122
122
  private
123
123
  def send_recv(message)
124
124
  success = false
125
125
  @retries.times do
126
126
  @logger.debug("0mq: sending", :request => message)
127
- rc = @zsocket.send_string(message)
127
+ rc = @zsocket.send_string(message)
128
128
  if ZMQ::Util.resultcode_ok?(rc)
129
129
  success = true
130
130
  break
@@ -137,13 +137,13 @@ class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
137
137
  #if we did not succeed log it and fail here.
138
138
  if not success
139
139
  @logger.warn("0mq: error sending message (zmq_errno = #{ZMQ::Util.errno}, zmq_error_string = '#{ZMQ::Util.error_string}'")
140
- return success, message
140
+ return success, message
141
141
  end
142
142
 
143
143
  #now get reply
144
144
  reply = ''
145
145
  success = false
146
- @retries.times do
146
+ @retries.times do
147
147
  @logger.debug("0mq: polling for reply for #{@timeout}ms.")
148
148
  #poll the socket. If > 0, something to read. If < 0, error. If zero, loop
149
149
  num_readable = @poller.poll(@timeout)
@@ -160,12 +160,12 @@ class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
160
160
  connect
161
161
  end
162
162
  end # @retries.times
163
-
163
+
164
164
  #if we maxed out on number of retries, then set reply to message so that
165
165
  #the event isn't cancelled. we want to carry on if the server is down.
166
- if not success
166
+ if not success
167
167
  @logger.warn("0mq: did not receive reply (zmq_errno = #{ZMQ::Util.errno}, zmq_error_string = '#{ZMQ::Util.error_string}'")
168
- return success, message
168
+ return success, message
169
169
  end
170
170
 
171
171
  return success, reply
@@ -193,7 +193,7 @@ class LogStash::Filters::ZeroMQ < LogStash::Filters::Base
193
193
  event[@field] = event.sprintf(reply)
194
194
  filter_matched(event)
195
195
  else
196
- reply = JSON.parse(reply)
196
+ reply = LogStash::Json.load(reply)
197
197
  event.overwrite(reply)
198
198
  end
199
199
  filter_matched(event)
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require 'ffi-rzmq'
3
+ require "logstash/namespace"
4
+
5
+ module LogStash::Util::ZeroMQ
6
+ CONTEXT = ZMQ::Context.new
7
+ # LOGSTASH-400
8
+ # see https://github.com/chuckremes/ffi-rzmq/blob/master/lib/ffi-rzmq/socket.rb#L93-117
9
+ STRING_OPTS = %w{IDENTITY SUBSCRIBE UNSUBSCRIBE}
10
+
11
+ def context
12
+ CONTEXT
13
+ end
14
+
15
+ def setup(socket, address)
16
+ if server?
17
+ error_check(socket.bind(address), "binding to #{address}")
18
+ else
19
+ error_check(socket.connect(address), "connecting to #{address}")
20
+ end
21
+ @logger.info("0mq: #{server? ? 'connected' : 'bound'}", :address => address)
22
+ end
23
+
24
+ def error_check(rc, doing)
25
+ unless ZMQ::Util.resultcode_ok?(rc)
26
+ @logger.error("ZeroMQ error while #{doing}", { :error_code => rc })
27
+ raise "ZeroMQ Error while #{doing}"
28
+ end
29
+ end # def error_check
30
+
31
+ def setopts(socket, options)
32
+ options.each do |opt,value|
33
+ sockopt = opt.split('::')[1]
34
+ option = ZMQ.const_defined?(sockopt) ? ZMQ.const_get(sockopt) : ZMQ.const_missing(sockopt)
35
+ unless STRING_OPTS.include?(sockopt)
36
+ begin
37
+ Float(value)
38
+ value = value.to_i
39
+ rescue ArgumentError
40
+ raise "#{sockopt} requires a numeric value. #{value} is not numeric"
41
+ end
42
+ end # end unless
43
+ error_check(socket.setsockopt(option, value),
44
+ "while setting #{opt} == #{value}")
45
+ end # end each
46
+ end # end setopts
47
+ end # module LogStash::Util::ZeroMQ
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-zeromq'
4
- s.version = '0.1.2'
4
+ s.version = '0.1.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "ZeroMQ filter. This is a way to send an event externally for filtering"
7
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"
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-zeromq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: logstash
15
- version_requirements: !ruby/object:Gem::Requirement
14
+ requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - '>='
18
17
  - !ruby/object:Gem::Version
@@ -20,7 +19,10 @@ dependencies:
20
19
  - - <
21
20
  - !ruby/object:Gem::Version
22
21
  version: 2.0.0
23
- requirement: !ruby/object:Gem::Requirement
22
+ name: logstash
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
24
26
  requirements:
25
27
  - - '>='
26
28
  - !ruby/object:Gem::Version
@@ -28,36 +30,34 @@ dependencies:
28
30
  - - <
29
31
  - !ruby/object:Gem::Version
30
32
  version: 2.0.0
31
- prerelease: false
32
- type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
- name: ffi-rzmq
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - '='
38
- - !ruby/object:Gem::Version
39
- version: 1.0.0
40
34
  requirement: !ruby/object:Gem::Requirement
41
35
  requirements:
42
36
  - - '='
43
37
  - !ruby/object:Gem::Version
44
38
  version: 1.0.0
39
+ name: ffi-rzmq
45
40
  prerelease: false
46
41
  type: :runtime
47
- - !ruby/object:Gem::Dependency
48
- name: logstash-devutils
49
42
  version_requirements: !ruby/object:Gem::Requirement
50
43
  requirements:
51
- - - '>='
44
+ - - '='
52
45
  - !ruby/object:Gem::Version
53
- version: '0'
46
+ version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
54
48
  requirement: !ruby/object:Gem::Requirement
55
49
  requirements:
56
50
  - - '>='
57
51
  - !ruby/object:Gem::Version
58
52
  version: '0'
53
+ name: logstash-devutils
59
54
  prerelease: false
60
55
  type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
61
  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
62
62
  email: info@elasticsearch.com
63
63
  executables: []
@@ -65,9 +65,13 @@ extensions: []
65
65
  extra_rdoc_files: []
66
66
  files:
67
67
  - .gitignore
68
+ - CONTRIBUTORS
68
69
  - Gemfile
70
+ - LICENSE
71
+ - README.md
69
72
  - Rakefile
70
73
  - lib/logstash/filters/zeromq.rb
74
+ - lib/logstash/util/zeromq.rb
71
75
  - logstash-filter-zeromq.gemspec
72
76
  - spec/filters/zeromq_spec.rb
73
77
  homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
@@ -92,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
96
  version: '0'
93
97
  requirements: []
94
98
  rubyforge_project:
95
- rubygems_version: 2.4.4
99
+ rubygems_version: 2.1.9
96
100
  signing_key:
97
101
  specification_version: 4
98
102
  summary: ZeroMQ filter. This is a way to send an event externally for filtering