logstash-input-redis 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/inputs/redis.rb +20 -18
- data/logstash-input-redis.gemspec +1 -1
- data/spec/inputs/redis_spec.rb +17 -17
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8c722cb3bcfc1d78632ea7a35e37a44e257848c
|
4
|
+
data.tar.gz: 08243c568315e73608f6ad82478a08877c5b3fcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 083e7c87a42cd7a899b53c81c79d13b19cea0cf78d54cb95a20a27e3ff088dee96c74d83b9eed341f58d2616c63310cae68b75d766746ac882511c8cca7fc6d4
|
7
|
+
data.tar.gz: eabba461cea36cd66b42074afe589e7ec95afa135dd4cae77986d8791e00d2ca7fab3b3771e548781da2ea384ff2937f512c3e376ca948f9ea7af15b653b2bd5
|
@@ -133,23 +133,23 @@ EOF
|
|
133
133
|
decorate(event)
|
134
134
|
output_queue << event
|
135
135
|
end
|
136
|
+
rescue LogStash::ShutdownSignal => e
|
137
|
+
# propagate up
|
138
|
+
raise(e)
|
136
139
|
rescue => e # parse or event creation error
|
137
|
-
@logger.error("Failed to create event", :message => msg, :exception => e,
|
138
|
-
:backtrace => e.backtrace);
|
140
|
+
@logger.error("Failed to create event", :message => msg, :exception => e, :backtrace => e.backtrace);
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
142
144
|
private
|
143
145
|
def list_listener(redis, output_queue)
|
144
146
|
|
147
|
+
item = redis.blpop(@key, 0, :timeout => 1)
|
148
|
+
return unless item # from timeout or other conditions
|
149
|
+
|
145
150
|
# blpop returns the 'key' read from as well as the item result
|
146
151
|
# we only care about the result (2nd item in the list).
|
147
|
-
item
|
148
|
-
|
149
|
-
# blpop failed or .. something?
|
150
|
-
# TODO(sissel): handle the error
|
151
|
-
return if item.nil?
|
152
|
-
queue_event(item, output_queue)
|
152
|
+
queue_event(item[1], output_queue)
|
153
153
|
|
154
154
|
# If @batch_count is 1, there's no need to continue.
|
155
155
|
return if @batch_count == 1
|
@@ -222,7 +222,7 @@ EOF
|
|
222
222
|
# loop.
|
223
223
|
private
|
224
224
|
def listener_loop(listener, output_queue)
|
225
|
-
while
|
225
|
+
while !@shutdown_requested
|
226
226
|
begin
|
227
227
|
@redis ||= connect
|
228
228
|
self.send listener, @redis, output_queue
|
@@ -232,7 +232,7 @@ EOF
|
|
232
232
|
@redis = nil
|
233
233
|
sleep 1
|
234
234
|
end
|
235
|
-
end
|
235
|
+
end
|
236
236
|
end # listener_loop
|
237
237
|
|
238
238
|
public
|
@@ -244,23 +244,25 @@ EOF
|
|
244
244
|
else
|
245
245
|
listener_loop :pattern_channel_listener, output_queue
|
246
246
|
end
|
247
|
+
rescue LogStash::ShutdownSignal
|
248
|
+
# ignore and quit
|
247
249
|
end # def run
|
248
250
|
|
249
251
|
public
|
250
252
|
def teardown
|
253
|
+
@shutdown_requested = true
|
254
|
+
|
251
255
|
if @redis
|
252
256
|
if @data_type == 'list'
|
253
|
-
@redis.quit
|
257
|
+
@redis.quit rescue nil
|
254
258
|
elsif @data_type == 'channel'
|
255
|
-
@redis.unsubscribe
|
256
|
-
@redis.
|
259
|
+
@redis.unsubscribe rescue nil
|
260
|
+
@redis.connection.disconnect
|
257
261
|
elsif @data_type == 'pattern_channel'
|
258
|
-
@redis.punsubscribe
|
259
|
-
@redis.
|
262
|
+
@redis.punsubscribe rescue nil
|
263
|
+
@redis.connection.disconnect
|
260
264
|
end
|
265
|
+
@redis = nil
|
261
266
|
end
|
262
|
-
rescue Redis::BaseError
|
263
|
-
ensure
|
264
|
-
@redis = nil
|
265
267
|
end
|
266
268
|
end # class LogStash::Inputs::Redis
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-redis'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.4'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This input will read events from a Redis instance"
|
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"
|
data/spec/inputs/redis_spec.rb
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
2
2
|
require "redis"
|
3
|
+
require "stud/try"
|
3
4
|
|
4
5
|
def populate(key, event_count)
|
5
6
|
require "logstash/event"
|
6
7
|
redis = Redis.new(:host => "localhost")
|
7
8
|
event_count.times do |value|
|
8
9
|
event = LogStash::Event.new("sequence" => value)
|
9
|
-
Stud
|
10
|
+
Stud.try(10.times) do
|
10
11
|
redis.rpush(key, event.to_json)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
def process(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def process(conf, event_count)
|
17
|
+
events = input(conf) do |pipeline, queue|
|
18
|
+
event_count.times.map{queue.pop}
|
19
|
+
end
|
20
|
+
|
21
|
+
events.each_with_index do |event, i|
|
20
22
|
insist { event["sequence"] } == i
|
21
23
|
end
|
22
|
-
pipeline.shutdown
|
23
24
|
end # process
|
24
25
|
|
25
26
|
describe "inputs/redis", :redis => true do
|
26
|
-
|
27
27
|
|
28
|
-
|
28
|
+
it "should read events from a list" do
|
29
29
|
key = 10.times.collect { rand(10).to_s }.join("")
|
30
30
|
event_count = 1000 + rand(50)
|
31
|
-
|
31
|
+
# event_count = 100
|
32
|
+
conf = <<-CONFIG
|
32
33
|
input {
|
33
34
|
redis {
|
34
35
|
type => "blah"
|
@@ -38,15 +39,14 @@ describe "inputs/redis", :redis => true do
|
|
38
39
|
}
|
39
40
|
CONFIG
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
input { |pipeline, queue| process(pipeline, queue, event_count) }
|
42
|
+
populate(key, event_count)
|
43
|
+
process(conf, event_count)
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "should read events from a list using batch_count" do
|
47
47
|
key = 10.times.collect { rand(10).to_s }.join("")
|
48
48
|
event_count = 1000 + rand(50)
|
49
|
-
|
49
|
+
conf = <<-CONFIG
|
50
50
|
input {
|
51
51
|
redis {
|
52
52
|
type => "blah"
|
@@ -57,7 +57,7 @@ describe "inputs/redis", :redis => true do
|
|
57
57
|
}
|
58
58
|
CONFIG
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
populate(key, event_count)
|
61
|
+
process(conf, event_count)
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - '>='
|
17
18
|
- !ruby/object:Gem::Version
|
@@ -19,10 +20,7 @@ dependencies:
|
|
19
20
|
- - <
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 2.0.0
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
type: :runtime
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
25
|
- - '>='
|
28
26
|
- !ruby/object:Gem::Version
|
@@ -30,48 +28,50 @@ dependencies:
|
|
30
28
|
- - <
|
31
29
|
- !ruby/object:Gem::Version
|
32
30
|
version: 2.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-codec-json
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
34
40
|
requirement: !ruby/object:Gem::Requirement
|
35
41
|
requirements:
|
36
42
|
- - '>='
|
37
43
|
- !ruby/object:Gem::Version
|
38
44
|
version: '0'
|
39
|
-
name: logstash-codec-json
|
40
45
|
prerelease: false
|
41
46
|
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: redis
|
42
49
|
version_requirements: !ruby/object:Gem::Requirement
|
43
50
|
requirements:
|
44
51
|
- - '>='
|
45
52
|
- !ruby/object:Gem::Version
|
46
53
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
54
|
requirement: !ruby/object:Gem::Requirement
|
49
55
|
requirements:
|
50
56
|
- - '>='
|
51
57
|
- !ruby/object:Gem::Version
|
52
58
|
version: '0'
|
53
|
-
name: redis
|
54
59
|
prerelease: false
|
55
60
|
type: :runtime
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: logstash-devutils
|
56
63
|
version_requirements: !ruby/object:Gem::Requirement
|
57
64
|
requirements:
|
58
65
|
- - '>='
|
59
66
|
- !ruby/object:Gem::Version
|
60
67
|
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
68
|
requirement: !ruby/object:Gem::Requirement
|
63
69
|
requirements:
|
64
70
|
- - '>='
|
65
71
|
- !ruby/object:Gem::Version
|
66
72
|
version: '0'
|
67
|
-
name: logstash-devutils
|
68
73
|
prerelease: false
|
69
74
|
type: :development
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - '>='
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
75
|
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
|
76
76
|
email: info@elasticsearch.com
|
77
77
|
executables: []
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.1.9
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: This input will read events from a Redis instance
|