logstash-input-mongoprofile 0.0.4 → 0.1.0
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/CHANGELOG.md +2 -9
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +1 -1
- data/Gemfile +1 -0
- data/LICENSE +0 -2
- data/README.md +2 -14
- data/lib/logstash/inputs/mongoprofile.rb +16 -21
- data/logstash-input-mongoprofile.gemspec +15 -17
- metadata +17 -46
- data/NOTICE.TXT +0 -5
- data/lib/mongo/mongo.rb +0 -117
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b3cd711a6ed934de468e847d9cf8332d297e8b7
|
4
|
+
data.tar.gz: 90a64c5755513607ddf40ec43069541cdc1bda65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45477101f490427149e3c484dd57ee71e36f96e09002b2a1536f03f6550f940e1699513345cb1fd336d170504d9228c94615288acc7a3d25bf7723679e5dff08
|
7
|
+
data.tar.gz: 09c5fd423b4279cfcee47dcbf241b88e2ea5fc9104a2dcc4f591b531f92bef817577c89dbe191ef3c1463cac09205419d035020fbfff599584b3e5500981fdfc
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,2 @@
|
|
1
|
-
##
|
2
|
-
|
3
|
-
## 2.0.1
|
4
|
-
- Simplify the shutdown implementation a bit for easier understanding
|
5
|
-
## 2.0.0
|
6
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
7
|
-
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
8
|
-
- Dependency on logstash-core update to 2.0
|
9
|
-
|
1
|
+
## 0.1.0
|
2
|
+
- Plugin created with the logstash plugin generator
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,10 @@
|
|
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
|
+
* Artem Antonov - aantonov.develop@gmail.com
|
6
|
+
|
7
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
9
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
10
|
+
open source awesome.
|
data/DEVELOPER.md
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
# logstash-input-
|
1
|
+
# logstash-input-mongoprofile
|
2
2
|
Example input plugin. This should help bootstrap your effort to write your own input plugin!
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[](https://travis-ci.org/logstash-plugins/logstash-input-example)
|
4
|
-
|
5
3
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
4
|
|
7
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.
|
@@ -55,12 +53,7 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
55
53
|
```
|
56
54
|
- Install plugin
|
57
55
|
```sh
|
58
|
-
# Logstash 2.3 and higher
|
59
56
|
bin/logstash-plugin install --no-verify
|
60
|
-
|
61
|
-
# Prior to Logstash 2.3
|
62
|
-
bin/plugin install --no-verify
|
63
|
-
|
64
57
|
```
|
65
58
|
- Run Logstash with your plugin
|
66
59
|
```sh
|
@@ -78,12 +71,7 @@ gem build logstash-filter-awesome.gemspec
|
|
78
71
|
```
|
79
72
|
- Install the plugin from the Logstash home
|
80
73
|
```sh
|
81
|
-
|
82
|
-
bin/logstash-plugin install --no-verify
|
83
|
-
|
84
|
-
# Prior to Logstash 2.3
|
85
|
-
bin/plugin install --no-verify
|
86
|
-
|
74
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
87
75
|
```
|
88
76
|
- Start Logstash and proceed to test the plugin
|
89
77
|
|
@@ -95,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
95
83
|
|
96
84
|
It is more important to the community that you are able to contribute.
|
97
85
|
|
98
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -1,48 +1,43 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require '../../../lib/mongo/mongo'
|
2
|
+
require "logstash/inputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "stud/interval"
|
5
|
+
require "socket" # for Socket.gethostname
|
7
6
|
|
8
7
|
# Generate a repeating message.
|
9
8
|
#
|
10
9
|
# This plugin is intented only as an example.
|
11
10
|
|
12
11
|
class LogStash::Inputs::Mongoprofile < LogStash::Inputs::Base
|
13
|
-
config_name
|
12
|
+
config_name "mongoprofile"
|
13
|
+
|
14
|
+
# If undefined, Logstash will complain, even if codec is unused.
|
15
|
+
default :codec, "plain"
|
16
|
+
|
17
|
+
# The message string to use in the event.
|
18
|
+
config :message, :validate => :string, :default => "Hello World!"
|
14
19
|
|
15
|
-
default :codec, 'plain'
|
16
20
|
# Set how frequently messages should be sent.
|
17
21
|
#
|
18
22
|
# The default, `1`, means send a message every second.
|
19
23
|
config :interval, :validate => :number, :default => 1
|
20
|
-
config :url, :validate => :string, :required => true
|
21
|
-
config :path, :validate => :string, :required => true
|
22
|
-
config :client_host, :validate => :string, :default => '127.0.0.1'
|
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)
|
28
28
|
end # def register
|
29
29
|
|
30
30
|
def run(queue)
|
31
31
|
# we can abort the loop if stop? becomes true
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@logger.info("Send event #{event}")
|
37
|
-
|
38
|
-
decorate(event)
|
39
|
-
queue << event
|
40
|
-
end
|
32
|
+
while !stop?
|
33
|
+
event = LogStash::Event.new("message" => @message, "host" => @host)
|
34
|
+
decorate(event)
|
35
|
+
queue << event
|
41
36
|
# because the sleep interval can be big, when shutdown happens
|
42
37
|
# we want to be able to abort the sleep
|
43
38
|
# Stud.stoppable_sleep will frequently evaluate the given block
|
44
39
|
# and abort the sleep(@interval) if the return value is true
|
45
|
-
Stud.stoppable_sleep(@interval) {stop?}
|
40
|
+
Stud.stoppable_sleep(@interval) { stop? }
|
46
41
|
end # loop
|
47
42
|
end # def run
|
48
43
|
|
@@ -1,27 +1,25 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name
|
3
|
-
s.version
|
4
|
-
s.licenses
|
5
|
-
s.summary
|
6
|
-
s.description
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.require_paths = [
|
2
|
+
s.name = 'logstash-input-mongoprofile'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = 'MongoDB system.profile input plugin'
|
6
|
+
s.description = 'MongoDB system.profile input plugin'
|
7
|
+
s.homepage = 'https://github.com/aantonovdevelop/logstash-input-mongoprofile'
|
8
|
+
s.authors = ['Artem Antonov']
|
9
|
+
s.email = 'aantonov.develop@gmail.com'
|
10
|
+
s.require_paths = ['lib']
|
11
11
|
|
12
12
|
# Files
|
13
|
-
s.files = Dir['lib/**/*',
|
14
|
-
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
|
+
# Tests
|
15
15
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
16
|
|
17
17
|
# Special flag to let us know this is actually a logstash plugin
|
18
|
-
s.metadata = {"logstash_plugin" => "true", "logstash_group" => "input"}
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
19
19
|
|
20
20
|
# Gem dependencies
|
21
|
-
s.add_runtime_dependency
|
21
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
22
22
|
s.add_runtime_dependency 'logstash-codec-plain'
|
23
|
-
s.add_runtime_dependency 'stud'
|
24
|
-
s.
|
25
|
-
s.add_runtime_dependency 'mongo', '>= 2.0.0'
|
26
|
-
s.add_development_dependency 'logstash-devutils'
|
23
|
+
s.add_runtime_dependency 'stud', '>= 0.0.22'
|
24
|
+
s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
|
27
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-mongoprofile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Artem Antonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
19
|
-
name: logstash-core
|
18
|
+
version: '2.0'
|
19
|
+
name: logstash-core-plugin-api
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 0.0.22
|
47
47
|
name: stud
|
48
48
|
prerelease: false
|
49
49
|
type: :runtime
|
@@ -51,41 +51,13 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
|
-
name: sequel
|
62
|
-
prerelease: false
|
63
|
-
type: :runtime
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
54
|
+
version: 0.0.22
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
requirement: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
58
|
- - ">="
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
75
|
-
name: mongo
|
76
|
-
prerelease: false
|
77
|
-
type: :runtime
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.0.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
60
|
+
version: 0.0.16
|
89
61
|
name: logstash-devutils
|
90
62
|
prerelease: false
|
91
63
|
type: :development
|
@@ -93,24 +65,23 @@ dependencies:
|
|
93
65
|
requirements:
|
94
66
|
- - ">="
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
description:
|
98
|
-
email:
|
68
|
+
version: 0.0.16
|
69
|
+
description: MongoDB system.profile input plugin
|
70
|
+
email: aantonov.develop@gmail.com
|
99
71
|
executables: []
|
100
72
|
extensions: []
|
101
73
|
extra_rdoc_files: []
|
102
74
|
files:
|
103
75
|
- CHANGELOG.md
|
76
|
+
- CONTRIBUTORS
|
104
77
|
- DEVELOPER.md
|
105
78
|
- Gemfile
|
106
79
|
- LICENSE
|
107
|
-
- NOTICE.TXT
|
108
80
|
- README.md
|
109
81
|
- lib/logstash/inputs/mongoprofile.rb
|
110
|
-
- lib/mongo/mongo.rb
|
111
82
|
- logstash-input-mongoprofile.gemspec
|
112
83
|
- spec/inputs/mongoprofile_spec.rb
|
113
|
-
homepage:
|
84
|
+
homepage: https://github.com/aantonovdevelop/logstash-input-mongoprofile
|
114
85
|
licenses:
|
115
86
|
- Apache License (2.0)
|
116
87
|
metadata:
|
@@ -135,6 +106,6 @@ rubyforge_project:
|
|
135
106
|
rubygems_version: 2.4.8
|
136
107
|
signing_key:
|
137
108
|
specification_version: 4
|
138
|
-
summary:
|
109
|
+
summary: MongoDB system.profile input plugin
|
139
110
|
test_files:
|
140
111
|
- spec/inputs/mongoprofile_spec.rb
|
data/NOTICE.TXT
DELETED
data/lib/mongo/mongo.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'mongo'
|
2
|
-
require 'logstash/inputs/base'
|
3
|
-
|
4
|
-
class MongoAccessor
|
5
|
-
def initialize(url, collection, client_host)
|
6
|
-
connection = Mongo::Client.new(url)
|
7
|
-
|
8
|
-
@mongodb = connection.database
|
9
|
-
@collection = @mongodb.collection(collection)
|
10
|
-
@client_host = client_host
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_documents_by_ts(date, limit)
|
14
|
-
@collection.find({:ts => {:$gt => date}, :client => {:$ne => @client_host}}).limit(limit)
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_documents(limit)
|
18
|
-
@collection.find({:client => {:$ne => @client_host}}).limit(limit)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class ProfileCollection
|
23
|
-
def initialize(documents, parser)
|
24
|
-
@documents = documents
|
25
|
-
@parser = parser
|
26
|
-
end
|
27
|
-
|
28
|
-
def each
|
29
|
-
@documents.each do |document|
|
30
|
-
document['_id'] = generate_id
|
31
|
-
yield @parser.parse(document)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_last_document_date
|
36
|
-
@documents[-1]['ts']
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def generate_id
|
41
|
-
# noinspection RubyArgCount
|
42
|
-
BSON::ObjectId.new
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class DocumentParser
|
47
|
-
def initialize(host)
|
48
|
-
@host = host
|
49
|
-
end
|
50
|
-
|
51
|
-
def parse(document)
|
52
|
-
event = LogStash::Event.new('host' => @host)
|
53
|
-
|
54
|
-
document.each do |key, value|
|
55
|
-
event.set(key, value)
|
56
|
-
end
|
57
|
-
|
58
|
-
event
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class LastValueStore
|
63
|
-
def initialize(path, name)
|
64
|
-
@file_full_name = "#{path}/#{name}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def save_last_value(value)
|
68
|
-
file = File.open(@file_full_name, 'a+')
|
69
|
-
|
70
|
-
file.truncate(0)
|
71
|
-
file.puts(value)
|
72
|
-
|
73
|
-
file.close
|
74
|
-
end
|
75
|
-
|
76
|
-
def get_last_value
|
77
|
-
File.read(@file_full_name)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class Controller
|
82
|
-
def initialize(event, url, collection, limit, path, client_host)
|
83
|
-
@mongo_accessor = MongoAccessor.new(url, collection, client_host)
|
84
|
-
@last_value_store = LastValueStore.new(path, collection)
|
85
|
-
@document_parser = DocumentParser.new(event)
|
86
|
-
@limit = limit
|
87
|
-
end
|
88
|
-
|
89
|
-
def get_next_events
|
90
|
-
last_date_value = @last_value_store.get_last_value
|
91
|
-
|
92
|
-
if last_date_value == ''
|
93
|
-
documents = @mongo_accessor.get_documents(@limit)
|
94
|
-
else
|
95
|
-
documents = @mongo_accessor.get_documents_by_ts(last_date_value, @limit)
|
96
|
-
end
|
97
|
-
|
98
|
-
profile_collection = ProfileCollection.new(documents, @document_parser)
|
99
|
-
|
100
|
-
@last_value_store.save_last_value(profile_collection.get_last_document_date)
|
101
|
-
|
102
|
-
profile_collection
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
lv = LastValueStore.new('/home/artem', 'mex.txt')
|
107
|
-
|
108
|
-
lv.save_last_value("blasaldkfj")
|
109
|
-
puts lv.get_last_value
|
110
|
-
|
111
|
-
#mongo = MongoAccessor.new('mongodb://192.168.1.37/eleet-v2-dev', 'system.profile')
|
112
|
-
|
113
|
-
#ProfileCollection.new(mongo.get_documents(10)).each do |document|
|
114
|
-
#puts document['_id']
|
115
|
-
#end
|
116
|
-
|
117
|
-
|