logstash-filter-exceptioncategory 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44c582eaffab6d41275a7c51c4713697b4c5a1af
4
+ data.tar.gz: cd96bf43d7df17d0cc06c4aedc262382bf12409b
5
+ SHA512:
6
+ metadata.gz: 31f6f0d5593137d9587744e18cb043bac3e8e323dc7905be61b9ceacd5e7e73c2b8ae2478f0c4e166156e4cd8383c40274ca0bfa9393735eb2bc94f5c4024939
7
+ data.tar.gz: 56db0de1d54d4f00e333f48a4e5826d9aa2e4d7375a4e15ce3a228cbb5ae55254d452bd04def57782ad17faac6f9a303d7fd183789a4edf92206c5a101311d79
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Apache License 2.0
data/README.md ADDED
@@ -0,0 +1 @@
1
+ readme
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+ require 'net/http'
5
+ require 'json'
6
+
7
+ class LogStash::Filters::ExceptionCategory < LogStash::Filters::Base
8
+
9
+ config_name "exceptioncategory"
10
+
11
+ config :category_url, :validate => :string, :required => true
12
+
13
+ public
14
+ def register
15
+ uri = URI(@category_url)
16
+ response = Net::HTTP.get(uri)
17
+ begin
18
+ @exceptions = JSON.parse(response)
19
+ rescue JSON::ParserError => e
20
+ @logger.error("The URL does not respond with a valid JSON object", :exception => e)
21
+ raise e
22
+ end
23
+
24
+ checkJSON()
25
+
26
+ end # def register
27
+
28
+ public
29
+ def filter(event)
30
+ event_exception = event["@Exception"]
31
+
32
+ event_exception && category = @exceptions["Exceptions"][event_exception]
33
+ event["@Category"] = (category ? category : "None")
34
+
35
+ filter_matched(event)
36
+ end # def filter
37
+
38
+ def checkJSON()
39
+ unless @exceptions["Exceptions"]
40
+ @logger.error("JSON Object does not contain Exceptions field")
41
+ raise "Malformed JSON"
42
+ end
43
+
44
+ unless @exceptions["Exceptions"].respond_to?(:has_key?)
45
+ @logger.error("Malformed JSON Object, Exceptions should include a JSON object, not an array")
46
+ raise "Malformed JSON"
47
+ end
48
+ end #def checkJSON
49
+ end # class LogStash::Filters::Example
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-exceptioncategory'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "Example filter"
6
+ s.description = "This is an example filter"
7
+ s.authors = ['Raggi']
8
+ s.email = "info@elastic.co"
9
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+
15
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
16
+
17
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
18
+ s.add_development_dependency "logstash-devutils", '~> 0'
19
+ end
File without changes
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-exceptioncategory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Raggi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '1.0'
19
+ name: logstash-core-plugin-api
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: logstash-devutils
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This is an example filter
42
+ email: info@elastic.co
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - Gemfile
48
+ - LICENSE
49
+ - README.md
50
+ - lib/logstash/filters/exceptioncategory.rb
51
+ - logstash-filter-exceptioncategory.gemspec
52
+ - spec/filters/example_spec.rb
53
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
54
+ licenses:
55
+ - Apache License (2.0)
56
+ metadata:
57
+ logstash_plugin: 'true'
58
+ logstash_group: filter
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.4.8
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Example filter
79
+ test_files: []