logstash-input-couchdb_changes 1.0.0 → 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/Gemfile +1 -1
- data/README.md +4 -4
- data/lib/logstash/inputs/couchdb_changes.rb +37 -28
- data/logstash-input-couchdb_changes.gemspec +4 -3
- data/spec/inputs/couchdb_changes_spec.rb +26 -11
- metadata +36 -30
- data/.gitignore +0 -5
- data/Rakefile +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a8131807cfa1a761f229f26f633b511625bc4c8
|
4
|
+
data.tar.gz: 17fdd30e692b7a3401bf1905bba8a7b663a55a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa001b4b0f2a235af1d709fde14fdaa3801452a47631ed4724f9abf17773f8250e2a0e46ae3a8343b7f74c0ccfde719d6f4d2eaf185b8d110822ff95dd6f6f11
|
7
|
+
data.tar.gz: 3363128bf9b5cb18c4768c19ad90f6ca03f88c9498da671efd68eaf37f4991f34c77466859495493043c0b90f98d8f343a431ce494be8c56e25752d666de0e93
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gemspec
|
2
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
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
6
|
|
7
7
|
## Documentation
|
8
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.
|
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
10
|
|
11
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/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -138,38 +138,47 @@ class LogStash::Inputs::CouchDBChanges < LogStash::Inputs::Base
|
|
138
138
|
buffer = FileWatch::BufferedTokenizer.new
|
139
139
|
@logger.info("Connecting to CouchDB _changes stream at:", :host => @host.to_s, :port => @port.to_s, :db => @db)
|
140
140
|
uri = build_uri
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
141
|
+
until stop?
|
142
|
+
begin
|
143
|
+
Net::HTTP.start(@host, @port, :use_ssl => (@secure == true), :ca_file => @ca_file) do |http|
|
144
|
+
|
145
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
146
|
+
request.basic_auth(@username, @password.value) if @username && @password
|
147
|
+
http.request request do |response|
|
148
|
+
raise ArgumentError, "Database not found!" if response.code == "404"
|
149
|
+
response.read_body do |chunk|
|
150
|
+
buffer.extract(chunk).each do |changes|
|
151
|
+
# Put a "stop" check here. If we stop here, anything we've read, but
|
152
|
+
# not written, will be read again since the @sequence change won't
|
153
|
+
# have been written to the file, ensuring that it will pick up where
|
154
|
+
# it left off.
|
155
|
+
break if stop?
|
156
|
+
# If no changes come since the last heartbeat period, a blank line is
|
157
|
+
# sent as a sort of keep-alive. We should ignore those.
|
158
|
+
next if changes.chomp.empty?
|
159
|
+
if event = build_event(changes)
|
160
|
+
@logger.debug("event", :event => event.to_hash_with_metadata) if @logger.debug?
|
161
|
+
decorate(event)
|
162
|
+
queue << event
|
163
|
+
@sequence = event['@metadata']['seq']
|
164
|
+
@sequencedb.write(@sequence.to_s)
|
165
|
+
end
|
166
|
+
end
|
158
167
|
end
|
159
168
|
end
|
160
169
|
end
|
170
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
171
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
172
|
+
@logger.error("Connection problem encountered: Retrying connection in 10 seconds...", :error => e.to_s)
|
173
|
+
retry if reconnect?
|
174
|
+
rescue Errno::EBADF => e
|
175
|
+
@logger.error("Unable to connect: Bad file descriptor: ", :error => e.to_s)
|
176
|
+
retry if reconnect?
|
177
|
+
rescue ArgumentError => e
|
178
|
+
@logger.error("Unable to connect to database", :db => @db, :error => e.to_s)
|
179
|
+
retry if reconnect?
|
161
180
|
end
|
162
181
|
end
|
163
|
-
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
164
|
-
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
165
|
-
@logger.error("Connection problem encountered: Retrying connection in 10 seconds...", :error => e.to_s)
|
166
|
-
retry if reconnect?
|
167
|
-
rescue Errno::EBADF => e
|
168
|
-
@logger.error("Unable to connect: Bad file descriptor: ", :error => e.to_s)
|
169
|
-
retry if reconnect?
|
170
|
-
rescue ArgumentError => e
|
171
|
-
@logger.error("Unable to connect to database", :db => @db, :error => e.to_s)
|
172
|
-
retry if reconnect?
|
173
182
|
end
|
174
183
|
|
175
184
|
private
|
@@ -181,7 +190,7 @@ class LogStash::Inputs::CouchDBChanges < LogStash::Inputs::Base
|
|
181
190
|
|
182
191
|
private
|
183
192
|
def reconnect?
|
184
|
-
|
193
|
+
Stud.stoppable_sleep(@connect_retry_interval) if @always_reconnect
|
185
194
|
@always_reconnect
|
186
195
|
end
|
187
196
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-couchdb_changes'
|
4
|
-
s.version = '
|
4
|
+
s.version = '2.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This input captures the _changes stream from a CouchDB 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"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
14
|
-
s.files =
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
15
|
|
16
16
|
# Tests
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core",
|
23
|
+
s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
|
24
|
+
s.add_runtime_dependency "stud", '>= 0.0.22'
|
24
25
|
s.add_runtime_dependency 'logstash-codec-plain'
|
25
26
|
s.add_runtime_dependency 'json'
|
26
27
|
|
@@ -94,13 +94,13 @@ module Helpers
|
|
94
94
|
def buildup
|
95
95
|
# BEGIN: The following calls are a safety net in case of an aborted test
|
96
96
|
deleteuser
|
97
|
-
|
97
|
+
close
|
98
98
|
# END
|
99
99
|
createdb
|
100
100
|
populatedb
|
101
101
|
end
|
102
102
|
|
103
|
-
def
|
103
|
+
def close
|
104
104
|
deletedb
|
105
105
|
deleteindex
|
106
106
|
sequence = "/tmp/.couchdb_seq"
|
@@ -109,6 +109,24 @@ module Helpers
|
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
112
|
+
describe LogStash::Inputs::CouchDBChanges do
|
113
|
+
include Helpers
|
114
|
+
sequence = "/tmp/.couchdb_seq"
|
115
|
+
|
116
|
+
before do
|
117
|
+
buildup
|
118
|
+
end
|
119
|
+
|
120
|
+
it_behaves_like "an interruptible input plugin" do
|
121
|
+
let(:config) {
|
122
|
+
{
|
123
|
+
"db" => "db", "timeout" => 1000, "always_reconnect" => true,
|
124
|
+
"sequence_path" => "#{sequence}", "host" => "127.0.0.1"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
112
130
|
describe "Load couchdb documents", :elasticsearch => true, :couchdb => true do
|
113
131
|
include Helpers
|
114
132
|
sequence = "/tmp/.couchdb_seq"
|
@@ -172,7 +190,7 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
172
190
|
end
|
173
191
|
end
|
174
192
|
after do
|
175
|
-
|
193
|
+
close
|
176
194
|
end
|
177
195
|
end
|
178
196
|
|
@@ -237,7 +255,7 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
237
255
|
end
|
238
256
|
|
239
257
|
after do
|
240
|
-
|
258
|
+
close
|
241
259
|
end
|
242
260
|
|
243
261
|
end
|
@@ -312,7 +330,7 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
312
330
|
end
|
313
331
|
|
314
332
|
after do
|
315
|
-
|
333
|
+
close
|
316
334
|
end
|
317
335
|
|
318
336
|
end
|
@@ -369,7 +387,7 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
369
387
|
end
|
370
388
|
|
371
389
|
after do
|
372
|
-
|
390
|
+
close
|
373
391
|
end
|
374
392
|
|
375
393
|
end
|
@@ -435,7 +453,7 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
435
453
|
|
436
454
|
after do
|
437
455
|
deleteuser
|
438
|
-
|
456
|
+
close
|
439
457
|
end
|
440
458
|
end
|
441
459
|
|
@@ -498,11 +516,8 @@ describe "inputs/couchdb_changes", :elasticsearch => true, :couchdb => true do
|
|
498
516
|
end
|
499
517
|
|
500
518
|
after do
|
501
|
-
|
519
|
+
close
|
502
520
|
end
|
503
521
|
end
|
504
522
|
|
505
523
|
end
|
506
|
-
|
507
|
-
|
508
|
-
|
metadata
CHANGED
@@ -1,112 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-couchdb_changes
|
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: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
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
|
14
19
|
name: logstash-core
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
15
22
|
version_requirements: !ruby/object:Gem::Requirement
|
16
23
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
24
|
+
- - ~>
|
21
25
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.0
|
26
|
+
version: 2.0.0.snapshot
|
27
|
+
- !ruby/object:Gem::Dependency
|
23
28
|
requirement: !ruby/object:Gem::Requirement
|
24
29
|
requirements:
|
25
30
|
- - '>='
|
26
31
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 2.0.0
|
32
|
+
version: 0.0.22
|
33
|
+
name: stud
|
31
34
|
prerelease: false
|
32
35
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-plain
|
35
36
|
version_requirements: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
38
|
- - '>='
|
38
39
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
+
version: 0.0.22
|
41
|
+
- !ruby/object:Gem::Dependency
|
40
42
|
requirement: !ruby/object:Gem::Requirement
|
41
43
|
requirements:
|
42
44
|
- - '>='
|
43
45
|
- !ruby/object:Gem::Version
|
44
46
|
version: '0'
|
47
|
+
name: logstash-codec-plain
|
45
48
|
prerelease: false
|
46
49
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: json
|
49
50
|
version_requirements: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
52
|
- - '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
54
56
|
requirement: !ruby/object:Gem::Requirement
|
55
57
|
requirements:
|
56
58
|
- - '>='
|
57
59
|
- !ruby/object:Gem::Version
|
58
60
|
version: '0'
|
61
|
+
name: json
|
59
62
|
prerelease: false
|
60
63
|
type: :runtime
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: ftw
|
63
64
|
version_requirements: !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
|
-
- -
|
66
|
+
- - '>='
|
66
67
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
68
70
|
requirement: !ruby/object:Gem::Requirement
|
69
71
|
requirements:
|
70
72
|
- - ~>
|
71
73
|
- !ruby/object:Gem::Version
|
72
74
|
version: 0.0.42
|
75
|
+
name: ftw
|
73
76
|
prerelease: false
|
74
77
|
type: :development
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: logstash-devutils
|
77
78
|
version_requirements: !ruby/object:Gem::Requirement
|
78
79
|
requirements:
|
79
|
-
- -
|
80
|
+
- - ~>
|
80
81
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.0.
|
82
|
+
version: 0.0.42
|
83
|
+
- !ruby/object:Gem::Dependency
|
82
84
|
requirement: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
86
|
- - '>='
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: 0.0.6
|
89
|
+
name: logstash-devutils
|
87
90
|
prerelease: false
|
88
91
|
type: :development
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: logstash-output-elasticsearch
|
91
92
|
version_requirements: !ruby/object:Gem::Requirement
|
92
93
|
requirements:
|
93
94
|
- - '>='
|
94
95
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
96
|
+
version: 0.0.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
96
98
|
requirement: !ruby/object:Gem::Requirement
|
97
99
|
requirements:
|
98
100
|
- - '>='
|
99
101
|
- !ruby/object:Gem::Version
|
100
102
|
version: '0'
|
103
|
+
name: logstash-output-elasticsearch
|
101
104
|
prerelease: false
|
102
105
|
type: :development
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
103
111
|
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
|
104
112
|
email: info@elastic.co
|
105
113
|
executables: []
|
106
114
|
extensions: []
|
107
115
|
extra_rdoc_files: []
|
108
116
|
files:
|
109
|
-
- .gitignore
|
110
117
|
- CHANGELOG.md
|
111
118
|
- CONTRIBUTORS
|
112
119
|
- DEVELOPER.md
|
@@ -114,7 +121,6 @@ files:
|
|
114
121
|
- LICENSE
|
115
122
|
- NOTICE.TXT
|
116
123
|
- README.md
|
117
|
-
- Rakefile
|
118
124
|
- lib/logstash/inputs/couchdb_changes.rb
|
119
125
|
- logstash-input-couchdb_changes.gemspec
|
120
126
|
- spec/inputs/ca_cert.pem
|
@@ -143,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
149
|
version: '0'
|
144
150
|
requirements: []
|
145
151
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.4.8
|
147
153
|
signing_key:
|
148
154
|
specification_version: 4
|
149
155
|
summary: This input captures the _changes stream from a CouchDB instance
|
data/.gitignore
DELETED
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "logstash/devutils/rake"
|