logstash-input-mongoprofile 0.1.14 → 0.1.15
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/mongoprofile.rb +11 -5
- data/logstash-input-mongoprofile.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4b22c8ef7d441e7d6d7130e51f18990fe34f272
|
4
|
+
data.tar.gz: 3534f85ef64368f518f18ac27cb259a64c862a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e4941008a948ab16952549645d78b6a4194d566024aba8bb1b38b66c2c9d83643228d141e42a76e2399acf9927917ab632adb20499608ca0aba456ddb847b6
|
7
|
+
data.tar.gz: f560de9428f0d222f5810218cc1782efe77bd74f9143d257621b7a2191f48d7b4b3db9e41c8ae54f39f5d963bb652364b5b8c88c683f74aa025d9c8e1b5e5307
|
@@ -20,11 +20,12 @@ class LogStash::Inputs::Mongoprofile < LogStash::Inputs::Base
|
|
20
20
|
config :url, :validate => :string, :required => true
|
21
21
|
config :path, :validate => :string, :required => true
|
22
22
|
config :client_host, :validate => :string, :default => '127.0.0.1'
|
23
|
+
config :generate_id, :validate => :boolean, :default => false
|
23
24
|
|
24
25
|
public
|
25
26
|
def register
|
26
27
|
@host = Socket.gethostname
|
27
|
-
@controller = Controller.new(@host, @url, 'system.profile', 1000, @path, @client_host, @logger)
|
28
|
+
@controller = Controller.new(@host, @url, 'system.profile', 1000, @path, @client_host, @logger, @generate_id)
|
28
29
|
end
|
29
30
|
|
30
31
|
# def register
|
@@ -83,7 +84,8 @@ class MongoAccessor
|
|
83
84
|
end
|
84
85
|
|
85
86
|
class ProfileCollection
|
86
|
-
def initialize(documents, parser)
|
87
|
+
def initialize(documents, parser, generate_id)
|
88
|
+
@generate_id = generate_id
|
87
89
|
@documents = []
|
88
90
|
|
89
91
|
documents.each do |document|
|
@@ -95,7 +97,10 @@ class ProfileCollection
|
|
95
97
|
|
96
98
|
def each
|
97
99
|
@documents.each do |document|
|
98
|
-
|
100
|
+
if @generate_id
|
101
|
+
document['_id'] = generate_id.to_s
|
102
|
+
end
|
103
|
+
|
99
104
|
yield @parser.parse(document)
|
100
105
|
end
|
101
106
|
end
|
@@ -154,10 +159,11 @@ class LastValueStore
|
|
154
159
|
end
|
155
160
|
|
156
161
|
class Controller
|
157
|
-
def initialize(event, url, collection, limit, path, client_host, logger)
|
162
|
+
def initialize(event, url, collection, limit, path, client_host, logger, generate_id)
|
158
163
|
@mongo_accessor = MongoAccessor.new(url, collection, client_host)
|
159
164
|
@last_value_store = LastValueStore.new(path, collection)
|
160
165
|
@document_parser = DocumentParser.new(event, logger)
|
166
|
+
@generate_id = generate_id
|
161
167
|
@limit = limit
|
162
168
|
@logger = logger
|
163
169
|
end
|
@@ -173,7 +179,7 @@ class Controller
|
|
173
179
|
documents = @mongo_accessor.get_documents_by_ts(last_date_value, @limit)
|
174
180
|
end
|
175
181
|
|
176
|
-
profile_collection = ProfileCollection.new(documents, @document_parser)
|
182
|
+
profile_collection = ProfileCollection.new(documents, @document_parser, @generate_id)
|
177
183
|
|
178
184
|
if profile_collection.get_last_document_date != nil
|
179
185
|
@last_value_store.save_last_value(profile_collection.get_last_document_date)
|