logstash-input-mongodb 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +106 -0
- data/README.md +27 -86
- data/lib/logstash/inputs/mongodb.rb +30 -17
- data/logstash-input-mongodb.gemspec +4 -3
- data/test/flattener_test.rb +66 -0
- metadata +27 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82148f9ed66d81ea6da480e90ed78600c6a92e42
|
|
4
|
+
data.tar.gz: 328b9ec0aa5f3de550f70d37b84063dbbf85fb15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6d157dbd02e4c914a9c3e4caf02ae5bd281b92f233456c8fcb575b8fd01629235c606d4054cc357c060ff743773378f7f5b816da1943926430ee5a7c100c83d
|
|
7
|
+
data.tar.gz: 00510814687f7a723260e436b9c5396d9148730ba81f324aee5d6cf859d43846fb9893a38d4fb1bfb6034df8322dd889cca7c77c171d4d2668964587e1162825
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
logstash-input-mongodb (0.1.1)
|
|
5
|
+
jdbc-sqlite3 (= 3.8.10.1)
|
|
6
|
+
logstash-codec-plain (~> 0)
|
|
7
|
+
logstash-core (>= 1.4.0, < 2.0.0)
|
|
8
|
+
mongo (>= 1.12.2, < 2.0.0)
|
|
9
|
+
sequel (~> 0)
|
|
10
|
+
stud (~> 0)
|
|
11
|
+
|
|
12
|
+
GEM
|
|
13
|
+
remote: https://rubygems.org/
|
|
14
|
+
specs:
|
|
15
|
+
ParseTree (3.0.9)
|
|
16
|
+
RubyInline (~> 3.9.0)
|
|
17
|
+
sexp_processor (~> 3.2.0)
|
|
18
|
+
RubyInline (3.9.0)
|
|
19
|
+
ZenTest (~> 4.3)
|
|
20
|
+
ZenTest (4.11.0)
|
|
21
|
+
bson (1.12.3-java)
|
|
22
|
+
cabin (0.7.1)
|
|
23
|
+
clamp (0.6.5)
|
|
24
|
+
coderay (1.1.0)
|
|
25
|
+
diff-lcs (1.2.5)
|
|
26
|
+
ffi (1.9.10-java)
|
|
27
|
+
filesize (0.0.4)
|
|
28
|
+
gem_publisher (1.5.0)
|
|
29
|
+
gems (0.8.3)
|
|
30
|
+
i18n (0.6.9)
|
|
31
|
+
insist (1.0.0)
|
|
32
|
+
jdbc-sqlite3 (3.8.10.1)
|
|
33
|
+
jrjackson (0.2.9)
|
|
34
|
+
kramdown (1.8.0)
|
|
35
|
+
logstash-codec-plain (0.1.6)
|
|
36
|
+
logstash-core (>= 1.4.0, < 2.0.0)
|
|
37
|
+
logstash-core (1.5.3-java)
|
|
38
|
+
cabin (~> 0.7.0)
|
|
39
|
+
clamp (~> 0.6.5)
|
|
40
|
+
filesize (= 0.0.4)
|
|
41
|
+
gems (~> 0.8.3)
|
|
42
|
+
i18n (= 0.6.9)
|
|
43
|
+
jrjackson (~> 0.2.9)
|
|
44
|
+
minitar (~> 0.5.4)
|
|
45
|
+
pry (~> 0.10.1)
|
|
46
|
+
stud (~> 0.0.19)
|
|
47
|
+
thread_safe (~> 0.3.5)
|
|
48
|
+
treetop (< 1.5.0)
|
|
49
|
+
logstash-devutils (0.0.15-java)
|
|
50
|
+
gem_publisher
|
|
51
|
+
insist (= 1.0.0)
|
|
52
|
+
kramdown
|
|
53
|
+
minitar
|
|
54
|
+
rake
|
|
55
|
+
rspec (~> 3.1.0)
|
|
56
|
+
stud (>= 0.0.20)
|
|
57
|
+
metaid (1.0)
|
|
58
|
+
method_source (0.8.2)
|
|
59
|
+
minitar (0.5.4)
|
|
60
|
+
mongo (1.12.3)
|
|
61
|
+
bson (= 1.12.3)
|
|
62
|
+
polyglot (0.3.5)
|
|
63
|
+
pry (0.10.1-java)
|
|
64
|
+
coderay (~> 1.1.0)
|
|
65
|
+
method_source (~> 0.8.1)
|
|
66
|
+
slop (~> 3.4)
|
|
67
|
+
spoon (~> 0.0)
|
|
68
|
+
rake (10.4.2)
|
|
69
|
+
rspec (3.1.0)
|
|
70
|
+
rspec-core (~> 3.1.0)
|
|
71
|
+
rspec-expectations (~> 3.1.0)
|
|
72
|
+
rspec-mocks (~> 3.1.0)
|
|
73
|
+
rspec-core (3.1.7)
|
|
74
|
+
rspec-support (~> 3.1.0)
|
|
75
|
+
rspec-expectations (3.1.2)
|
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
+
rspec-support (~> 3.1.0)
|
|
78
|
+
rspec-mocks (3.1.3)
|
|
79
|
+
rspec-support (~> 3.1.0)
|
|
80
|
+
rspec-support (3.1.2)
|
|
81
|
+
ruby2ruby (1.3.1)
|
|
82
|
+
ruby_parser (~> 2.0)
|
|
83
|
+
sexp_processor (~> 3.0)
|
|
84
|
+
ruby_parser (2.3.1)
|
|
85
|
+
sexp_processor (~> 3.0)
|
|
86
|
+
sequel (0.5.0.2)
|
|
87
|
+
ParseTree (>= 2.1.1)
|
|
88
|
+
RubyInline (>= 3.6.6)
|
|
89
|
+
metaid
|
|
90
|
+
ruby2ruby
|
|
91
|
+
sexp_processor (3.2.0)
|
|
92
|
+
slop (3.6.0)
|
|
93
|
+
spoon (0.0.4)
|
|
94
|
+
ffi
|
|
95
|
+
stud (0.0.20)
|
|
96
|
+
thread_safe (0.3.5-java)
|
|
97
|
+
treetop (1.4.15)
|
|
98
|
+
polyglot
|
|
99
|
+
polyglot (>= 0.3.1)
|
|
100
|
+
|
|
101
|
+
PLATFORMS
|
|
102
|
+
java
|
|
103
|
+
|
|
104
|
+
DEPENDENCIES
|
|
105
|
+
logstash-devutils (~> 0)
|
|
106
|
+
logstash-input-mongodb!
|
data/README.md
CHANGED
|
@@ -6,90 +6,31 @@ It is fully free and fully open source. The license is Apache 2.0, meaning you a
|
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
### Configuration
|
|
10
|
+
|
|
11
|
+
Example
|
|
12
|
+
```
|
|
13
|
+
input {
|
|
14
|
+
mongodb {
|
|
15
|
+
uri => 'mongodb://10.0.0.30/my-logs?ssl=true'
|
|
16
|
+
path => '/opt/logstash-mongodb/logstash_sqlite.db'
|
|
17
|
+
collection => 'events_'
|
|
18
|
+
unpack_mongo_id => true
|
|
19
|
+
batch_size => 5000
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
filter {
|
|
24
|
+
date {
|
|
25
|
+
match => [ "logdate", "ISO8601" ]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
output {
|
|
30
|
+
redis {
|
|
31
|
+
host => "localhost"
|
|
32
|
+
data_type => "list"
|
|
33
|
+
key => "logstash-mylogs"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
30
36
|
```
|
|
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.
|
|
@@ -5,11 +5,9 @@ require "logstash/timestamp"
|
|
|
5
5
|
require "stud/interval"
|
|
6
6
|
require "socket" # for Socket.gethostname
|
|
7
7
|
require "json"
|
|
8
|
-
require "
|
|
8
|
+
require "mongo"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
# This plugin is intented only as an example.
|
|
10
|
+
include Mongo
|
|
13
11
|
|
|
14
12
|
class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
15
13
|
config_name "mongodb"
|
|
@@ -84,7 +82,7 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
84
82
|
@logger.debug("init placeholder for #{since_table}_#{mongo_collection_name}")
|
|
85
83
|
since = sqlitedb[SINCE_TABLE]
|
|
86
84
|
mongo_collection = mongodb.collection(mongo_collection_name)
|
|
87
|
-
first_entry = mongo_collection.find({}
|
|
85
|
+
first_entry = mongo_collection.find({}).sort('_id' => 1).limit(1).first
|
|
88
86
|
first_entry_id = first_entry['_id'].to_s
|
|
89
87
|
since.insert(:table => "#{since_table}_#{mongo_collection_name}", :place => first_entry_id)
|
|
90
88
|
return first_entry_id
|
|
@@ -152,24 +150,29 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
152
150
|
|
|
153
151
|
public
|
|
154
152
|
def register
|
|
155
|
-
require "mongo"
|
|
156
153
|
require "jdbc/sqlite3"
|
|
157
154
|
require "sequel"
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
mongo_uri = Mongo::URI.new(@uri)
|
|
156
|
+
hosts_array = mongo_uri.servers
|
|
157
|
+
db_name = mongo_uri.database
|
|
158
|
+
ssl_enabled = mongo_uri.options[:ssl]
|
|
159
|
+
conn = Mongo::Client.new(hosts_array, ssl: ssl_enabled, database: db_name)
|
|
160
|
+
|
|
161
|
+
if @db_auths
|
|
162
|
+
@db_auths.each do |auth|
|
|
162
163
|
if !auth['db_name'].nil?
|
|
163
164
|
conn.add_auth(auth['db_name'], auth['username'], auth['password'], nil)
|
|
164
165
|
end
|
|
165
166
|
end
|
|
166
167
|
conn.apply_saved_authentication()
|
|
167
168
|
end
|
|
169
|
+
|
|
168
170
|
@host = Socket.gethostname
|
|
169
171
|
@logger.info("Registering MongoDB input", :database => @path)
|
|
170
|
-
|
|
171
|
-
@mongodb = conn.
|
|
172
|
+
|
|
173
|
+
@mongodb = conn.database
|
|
172
174
|
@sqlitedb = Sequel.connect("jdbc:sqlite:#{@path}")
|
|
175
|
+
|
|
173
176
|
# Should check to see if there are new matching tables at a predefined interval or on some trigger
|
|
174
177
|
@collection_data = update_watched_collections(@mongodb, @collection, @sqlitedb)
|
|
175
178
|
end # def register
|
|
@@ -186,6 +189,7 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
186
189
|
|
|
187
190
|
def flatten(my_hash)
|
|
188
191
|
new_hash = {}
|
|
192
|
+
@logger.debug("Raw Hash: #{my_hash}")
|
|
189
193
|
if my_hash.respond_to? :each
|
|
190
194
|
my_hash.each do |k1,v1|
|
|
191
195
|
if v1.is_a?(Hash)
|
|
@@ -209,6 +213,7 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
209
213
|
else
|
|
210
214
|
@logger.debug("Flatten [ERROR]: hash did not respond to :each")
|
|
211
215
|
end
|
|
216
|
+
@logger.debug("Flattened Hash: #{new_hash}")
|
|
212
217
|
return new_hash
|
|
213
218
|
end
|
|
214
219
|
|
|
@@ -244,7 +249,8 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
244
249
|
#@logger.debug("EVENT looks like: "+event.to_s)
|
|
245
250
|
# Extract the HOST_ID and PID from the MongoDB BSON::ObjectID
|
|
246
251
|
if @unpack_mongo_id
|
|
247
|
-
|
|
252
|
+
doc_hex_bytes = doc['_id'].to_s.each_char.each_slice(2).map {|b| b.join.to_i(16) }
|
|
253
|
+
doc_obj_bin = doc_hex_bytes.pack("C*").unpack("a4 a3 a2 a3")
|
|
248
254
|
host_id = doc_obj_bin[1].unpack("S")
|
|
249
255
|
process_id = doc_obj_bin[2].unpack("S")
|
|
250
256
|
event['host_id'] = host_id.first.to_i
|
|
@@ -265,10 +271,17 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
|
265
271
|
|
|
266
272
|
flat_doc.each do |k,v|
|
|
267
273
|
# Check for an integer
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
@logger.debug("key: #{k.to_s} value: #{v.to_s}")
|
|
275
|
+
if v.is_a? Numeric
|
|
276
|
+
event[k.to_s] = v
|
|
277
|
+
elsif v.is_a? String
|
|
278
|
+
if v == "NaN"
|
|
279
|
+
event[k.to_s] = Float::NAN
|
|
280
|
+
elsif /\A[-+]?\d+[.][\d]+\z/ == v
|
|
281
|
+
event[k.to_s] = v.to_f
|
|
282
|
+
elsif (/\A[-+]?\d+\z/ === v) || (v.is_a? Integer)
|
|
283
|
+
event[k.to_s] = v.to_i
|
|
284
|
+
end
|
|
272
285
|
else
|
|
273
286
|
event[k.to_s] = v.to_s unless k.to_s == "_id" || k.to_s == "tags"
|
|
274
287
|
if (k.to_s == "tags") && (v.is_a? Array)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'logstash-input-mongodb'
|
|
3
|
-
s.version = '0.1.
|
|
3
|
+
s.version = '0.1.3'
|
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
|
5
5
|
s.summary = "This takes entries from mongodb as an input to logstash."
|
|
6
6
|
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"
|
|
@@ -18,10 +18,11 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
|
19
19
|
|
|
20
20
|
# Gem dependencies
|
|
21
|
-
s.add_runtime_dependency 'logstash'
|
|
21
|
+
s.add_runtime_dependency 'logstash-core'
|
|
22
22
|
s.add_runtime_dependency 'logstash-codec-plain'
|
|
23
23
|
s.add_runtime_dependency 'stud'
|
|
24
|
-
s.add_runtime_dependency 'jdbc
|
|
24
|
+
s.add_runtime_dependency 'jdbc-sqlite3', '3.8.10.1'
|
|
25
25
|
s.add_runtime_dependency 'sequel'
|
|
26
|
+
s.add_runtime_dependency 'mongo', '>= 2.0.0'
|
|
26
27
|
s.add_development_dependency 'logstash-devutils'
|
|
27
28
|
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'minitest/autorun'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'mongo'
|
|
4
|
+
require 'bson'
|
|
5
|
+
|
|
6
|
+
class TestThis < MiniTest::Test
|
|
7
|
+
def test_that_this_works
|
|
8
|
+
input = {"_id"=>BSON::ObjectId('558de77ec5ed007567574a58'), "tags"=>["http"], "info"=>{"method"=>"POST", "rtime"=>"127", "url"=>"apiginvoice", "data"=>{"a"=>291.35, "b"=>291.25, "c"=>291.16, "d"=>289.68, "e"=>261.73, "f"=>Float::NAN}, "host"=>"bitpay.com", "status"=>200, "referrer"=>nil, "raddr"=>"31.192.114.250", "ver"=>"1.1", "ua"=>nil, "rlen"=>nil, "rlocation"=>nil, "query"=>{}}}
|
|
9
|
+
expected = "your mom"
|
|
10
|
+
assert_equal flatten(input), expected
|
|
11
|
+
end
|
|
12
|
+
def test_the_flat_parser
|
|
13
|
+
input = {"_id"=>BSON::ObjectId('558de77ec5ed007567574a58'), "tags"=>["http"], "info"=>{"method"=>"POST", "rtime"=>"127", "url"=>"apiginvoice", "data"=>{"a"=>291.35, "b"=>291.25, "c"=>291.16, "d"=>289.68, "e"=>261.73, "f"=>Float::NAN}, "host"=>"bitpay.com", "status"=>200, "referrer"=>nil, "raddr"=>"31.192.114.250", "ver"=>"1.1", "ua"=>nil, "rlen"=>nil, "rlocation"=>nil, "query"=>{}}}
|
|
14
|
+
expected = "your mom"
|
|
15
|
+
assert_equal flat_doc(flatten(input)), expected
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def flatten(my_hash)
|
|
20
|
+
new_hash = {}
|
|
21
|
+
if my_hash.respond_to? :each
|
|
22
|
+
my_hash.each do |k1,v1|
|
|
23
|
+
if v1.is_a?(Hash)
|
|
24
|
+
v1.each do |k2,v2|
|
|
25
|
+
if v2.is_a?(Hash)
|
|
26
|
+
# puts "Found a nested hash"
|
|
27
|
+
result = flatten(v2)
|
|
28
|
+
result.each do |k3,v3|
|
|
29
|
+
new_hash[k1.to_s+"_"+k2.to_s+"_"+k3.to_s] = v3
|
|
30
|
+
end
|
|
31
|
+
# puts "result: "+result.to_s+" k2: "+k2.to_s+" v2: "+v2.to_s
|
|
32
|
+
else
|
|
33
|
+
new_hash[k1.to_s+"_"+k2.to_s] = v2
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
else
|
|
37
|
+
# puts "Key: "+k1.to_s+" is not a hash"
|
|
38
|
+
new_hash[k1.to_s] = v1
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
return new_hash
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def flat_doc(flat_doc)
|
|
46
|
+
event = {}
|
|
47
|
+
flat_doc.each do |k,v|
|
|
48
|
+
# Check for an integer
|
|
49
|
+
if v.is_a? Numeric
|
|
50
|
+
event[k.to_s] = v
|
|
51
|
+
elsif v.is_a? String
|
|
52
|
+
if v == "NaN"
|
|
53
|
+
event[k.to_s] = Float::NAN
|
|
54
|
+
elsif /\A[-+]?\d+[.][\d]+\z/ == v
|
|
55
|
+
event[k.to_s] = v.to_f
|
|
56
|
+
elsif (/\A[-+]?\d+\z/ === v) || (v.is_a? Integer)
|
|
57
|
+
event[k.to_s] = v.to_i
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
event[k.to_s] = v.to_s unless k.to_s == "_id" || k.to_s == "tags"
|
|
61
|
+
if (k.to_s == "tags") && (v.is_a? Array)
|
|
62
|
+
event['tags'] = v
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
metadata
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstash-input-mongodb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Hutchins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: logstash
|
|
14
|
+
name: logstash-core
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
20
|
-
- - "<"
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: 2.0.0
|
|
19
|
+
version: '0'
|
|
23
20
|
type: :runtime
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
23
|
requirements:
|
|
27
24
|
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
30
|
-
- - "<"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.0.0
|
|
26
|
+
version: '0'
|
|
33
27
|
- !ruby/object:Gem::Dependency
|
|
34
28
|
name: logstash-codec-plain
|
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,7 +53,21 @@ dependencies:
|
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
54
|
version: '0'
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: jdbc
|
|
56
|
+
name: jdbc-sqlite3
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - '='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 3.8.10.1
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 3.8.10.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: sequel
|
|
63
71
|
requirement: !ruby/object:Gem::Requirement
|
|
64
72
|
requirements:
|
|
65
73
|
- - ">="
|
|
@@ -73,19 +81,19 @@ dependencies:
|
|
|
73
81
|
- !ruby/object:Gem::Version
|
|
74
82
|
version: '0'
|
|
75
83
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
84
|
+
name: mongo
|
|
77
85
|
requirement: !ruby/object:Gem::Requirement
|
|
78
86
|
requirements:
|
|
79
87
|
- - ">="
|
|
80
88
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
89
|
+
version: 2.0.0
|
|
82
90
|
type: :runtime
|
|
83
91
|
prerelease: false
|
|
84
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
93
|
requirements:
|
|
86
94
|
- - ">="
|
|
87
95
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
96
|
+
version: 2.0.0
|
|
89
97
|
- !ruby/object:Gem::Dependency
|
|
90
98
|
name: logstash-devutils
|
|
91
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -110,12 +118,14 @@ extra_rdoc_files: []
|
|
|
110
118
|
files:
|
|
111
119
|
- DEVELOPER.md
|
|
112
120
|
- Gemfile
|
|
121
|
+
- Gemfile.lock
|
|
113
122
|
- LICENSE
|
|
114
123
|
- README.md
|
|
115
124
|
- Rakefile
|
|
116
125
|
- lib/logstash/inputs/mongodb.rb
|
|
117
126
|
- logstash-input-mongodb.gemspec
|
|
118
127
|
- spec/inputs/example_spec.rb
|
|
128
|
+
- test/flattener_test.rb
|
|
119
129
|
homepage: http://www.phutchins.com
|
|
120
130
|
licenses:
|
|
121
131
|
- Apache License (2.0)
|
|
@@ -138,9 +148,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
148
|
version: '0'
|
|
139
149
|
requirements: []
|
|
140
150
|
rubyforge_project:
|
|
141
|
-
rubygems_version: 2.4.
|
|
151
|
+
rubygems_version: 2.4.6
|
|
142
152
|
signing_key:
|
|
143
153
|
specification_version: 4
|
|
144
154
|
summary: This takes entries from mongodb as an input to logstash.
|
|
145
155
|
test_files:
|
|
146
156
|
- spec/inputs/example_spec.rb
|
|
157
|
+
- test/flattener_test.rb
|