logstash-filter-metaevent 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fe9ccea158891a8bae7ad9be96b173ec19a5386
4
+ data.tar.gz: ff4c762016fcc44d69875649dffca1252b5e10d2
5
+ SHA512:
6
+ metadata.gz: 4b068b5adcb8377b294cdbb08b43280a880f96e8923869f5e84902598c320350ed8ecac8c1461401588555a6f2f14da0e4ffbaa607992a9dadafc0e9d980337b
7
+ data.tar.gz: 439274eb2a3b86d6d4693478209b84f0ccc985e5ceb536ae61fa6c4c0655c67a4396891f9ea91a677a7159bbe9e769cef07cf70815516192a9b86321079ad561
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+ vendor
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+
6
+ class LogStash::Filters::Metaevent < LogStash::Filters::Base
7
+ config_name "metaevent"
8
+ milestone 1
9
+
10
+ # syntax: `followed_by_tags => [ "tag", "tag" ]`
11
+ config :followed_by_tags, :validate => :array, :required => true
12
+
13
+ # syntax: `period => 60`
14
+ config :period, :validate => :number, :default => 5
15
+
16
+ def register
17
+ @logger.debug("registering")
18
+ @metaevents = []
19
+ end
20
+
21
+ def filter(event)
22
+ if filter?(event)
23
+ start_period(event)
24
+ elsif within_period(event)
25
+ if followed_by_tags_match(event)
26
+ trigger(event)
27
+ else
28
+ @logger.debug(["metaevent", @add_tag, "ignoring (tags don't match)", event])
29
+ end
30
+ else
31
+ @logger.debug(["metaevent", @add_tag, "ignoring (not in period)", event])
32
+ end
33
+ end
34
+
35
+ def flush
36
+ return if @metaevents.empty?
37
+
38
+ new_events = @metaevents
39
+ @metaevents = []
40
+ new_events
41
+ end
42
+
43
+ private
44
+
45
+ def start_period(event)
46
+ @logger.debug(["metaevent", @add_tag, "start_period", event])
47
+ @start_event = event
48
+ end
49
+
50
+ def trigger(event)
51
+ @logger.debug(["metaevent", @add_tag, "trigger", event])
52
+
53
+ event = LogStash::Event.new
54
+ event["source"] = Socket.gethostname
55
+ event["tags"] = [@add_tag]
56
+
57
+ @metaevents << event
58
+ @start_event = nil
59
+ end
60
+
61
+ def followed_by_tags_match(event)
62
+ (event["tags"] & @followed_by_tags).size == @followed_by_tags.size
63
+ end
64
+
65
+ def within_period(event)
66
+ time_delta = event["@timestamp"] - @start_event["@timestamp"]
67
+ time_delta >= 0 && time_delta <= @period
68
+ end
69
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-filter-metaevent'
4
+ s.version = '0.1.2'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Metaevent plugin from contrib"
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"
8
+ s.authors = ["Elasticsearch"]
9
+ s.email = 'info@elasticsearch.com'
10
+ s.homepage = "http://www.elasticsearch.org/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_development_dependency 'logstash-devutils'
26
+ end
27
+
@@ -0,0 +1,8 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require 'logstash/filters/metaevent'
3
+
4
+ describe LogStash::Filters::Metaevent do
5
+ it 'tries to register the plugin' do
6
+ expect(LogStash::Filters::Metaevent.new({ "followed_by_tags" => "abc" }).register).to eq([])
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-metaevent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Elasticsearch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.0
28
+ - - <
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: logstash-devutils
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ prerelease: false
46
+ type: :development
47
+ 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
48
+ email: info@elasticsearch.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE
56
+ - Rakefile
57
+ - lib/logstash/filters/metaevent.rb
58
+ - logstash-filter-metaevent.gemspec
59
+ - spec/filters/metaevent_spec.rb
60
+ homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
61
+ licenses:
62
+ - Apache License (2.0)
63
+ metadata:
64
+ logstash_plugin: 'true'
65
+ logstash_group: filter
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.4
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Metaevent plugin from contrib
86
+ test_files:
87
+ - spec/filters/metaevent_spec.rb