logstash-filter-exceptioncategory 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15665749908c8facf793c3d8ba86bb7f29ad64a9
4
- data.tar.gz: b4f6c2ba582343f96bdeba2f966b24d7f699d5dd
3
+ metadata.gz: 1fc9c7edbf457edfbf86475a5069da09613afe25
4
+ data.tar.gz: 0bc32e1c5c4485a8120dd51068d5d2726b80c576
5
5
  SHA512:
6
- metadata.gz: 9fc6094f6c818d416c90749eb83ff87d3390bc04a36f14632d0b1363d97c3075db9699405e40f5ab47552b26daad46c048d52761bdc21e7c9a3db0d48eff3ff2
7
- data.tar.gz: 193f95d7c6a6c8b46d2b77e58e71694788e4713dd8a4b79ea5a08d7dc430bf2b594d16fd5155379f60c152a16fa731b345af0040490e858b3fdade34640ea93a
6
+ metadata.gz: e53b5a33d28b22e4f0b075eb13bacadcfe839f0216da0a38d1acb664ed2d27ba40e9e7656f5e9d3027aa82904b2f35c2c8a43eab0981ca4d50936484d6097c70
7
+ data.tar.gz: c40aa5e7f9c5f9453975715368d443161b7cb71db1ac8b94962c5e72a24792166a01fc82e3939b547f98ff2126b238105d5dd01c3839c47d55a1d294705a8783
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source 'https://rubygems.org'
2
- gemspec
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE CHANGED
@@ -1 +1,13 @@
1
- Apache License 2.0
1
+ Copyright [yyyy] [author]
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.
data/README.md CHANGED
@@ -1,25 +1,27 @@
1
- # ExceptionsCategory
2
-
3
- This Logstash filter sends an html request for a json document.
4
- It then looks up the @Exception attached to the event in that json document.
5
- If that exception is present in the json document and has an attached category, it then attaches the category as @Category.
6
-
7
- Usage:
8
- ```
9
- filter {
10
- exceptionscategory {
11
- category_url => "url/to/json"
12
- }
13
- }
14
- ```
15
- Where _category_url_ is a required parameter, pointing to the url of the json document.
16
-
17
- The json document must be structured as follows:
18
- ```json
19
- {
20
- "Exceptions": {
21
- "BadException": "Severe",
22
- "GoodException": "Warning"
23
- }
24
- }
25
- ```
1
+ # ExceptionsCategory
2
+
3
+ This Logstash filter sends an html request for a json document.
4
+ It then looks up the @Exception attached to the event and tries to match that to a category from the json document.
5
+ If it fails to do so, it looks up the Title attached to the event and tries the same thing with the Title.
6
+
7
+ If neither of those attributes are attached to the event, or if neither of them are present in the json document, it attached a _None_ category to the event.
8
+
9
+ Usage:
10
+ ```
11
+ filter {
12
+ exceptionscategory {
13
+ category_url => "url/to/json"
14
+ }
15
+ }
16
+ ```
17
+ Where _category_url_ is a required parameter, pointing to the url of the json document.
18
+
19
+ The json document must be structured as follows:
20
+ ```json
21
+ {
22
+ "Exceptions": {
23
+ "BadException": "Severe",
24
+ "GoodException": "Warning"
25
+ }
26
+ }
27
+ ```
@@ -1,49 +1,56 @@
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
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
+ end # def register
26
+
27
+ public
28
+ def filter(event)
29
+
30
+ event["Title"] = "System.Security.SecurityException"
31
+
32
+ categories = @Exceptions["Exceptions"]
33
+ event_exception = event["@Exception"]
34
+
35
+ unless categories.key?(event_exception)
36
+ event_exception = event["Title"]
37
+ end
38
+
39
+ event_exception && category = categories[event_exception]
40
+ event["@Category"] = (category ? category : "None")
41
+
42
+ filter_matched(event)
43
+ end #def filter
44
+
45
+ def checkJSON()
46
+ unless @Exceptions["Exceptions"]
47
+ @logger.error("JSON Object does not contain Exceptions field")
48
+ raise "Malformed JSON"
49
+ end
50
+
51
+ unless @Exceptions["Exceptions"].respond_to?(:has_key?)
52
+ @logger.error("Malformed JSON Object, Exceptions should include a JSON object, not an array")
53
+ raise "Malformed JSON"
54
+ end
55
+ end #def checkJSON
56
+ end # LogStash::Filters::Example
@@ -1,19 +1,20 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'logstash-filter-exceptioncategory'
3
- s.version = '0.1.1'
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
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'logstash-filter-exceptioncategory'
5
+ s.version = '0.1.2'
6
+ s.licenses = ['Apache License (2.0)']
7
+ s.summary = "Categorizes exceptions"
8
+ s.description = "Fetches a remote json file which includes categorization of exceptions. Uses that categorization to attach a category to an event depending on which exception the event has."
9
+ s.authors = ['Ragnar Adolf Árnason']
10
+ s.email = "ragnara@tmsoftware.is"
11
+ s.homepage = "http://www.tmsoftware.is"
12
+ s.require_paths = ["lib"]
13
+
14
+ s.files = Dir['lib/**/*', 'spec/**/*', '*.gemspec', '*.md', 'Gemfile', 'LICENSE']
15
+
16
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
17
+
18
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
19
+ s.add_development_dependency "logstash-devutils", "~> 0"
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-exceptioncategory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - Raggi
7
+ - Ragnar Adolf Árnason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: This is an example filter
42
- email: info@elastic.co
41
+ description: Fetches a remote json file which includes categorization of exceptions. Uses that categorization to attach a category to an event depending on which exception the event has.
42
+ email: ragnara@tmsoftware.is
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
@@ -49,8 +49,8 @@ files:
49
49
  - README.md
50
50
  - lib/logstash/filters/exceptioncategory.rb
51
51
  - logstash-filter-exceptioncategory.gemspec
52
- - spec/filters/example_spec.rb
53
- homepage: http://www.elastic.co/guide/en/logstash/current/index.html
52
+ - spec/filters/exceptioncategory_spec.rb
53
+ homepage: http://www.tmsoftware.is
54
54
  licenses:
55
55
  - Apache License (2.0)
56
56
  metadata:
@@ -75,5 +75,5 @@ rubyforge_project:
75
75
  rubygems_version: 2.4.8
76
76
  signing_key:
77
77
  specification_version: 4
78
- summary: Example filter
78
+ summary: Categorizes exceptions
79
79
  test_files: []