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 +4 -4
- data/Gemfile +2 -2
- data/LICENSE +13 -1
- data/README.md +27 -25
- data/lib/logstash/filters/exceptioncategory.rb +56 -49
- data/logstash-filter-exceptioncategory.gemspec +20 -19
- data/spec/filters/{example_spec.rb → exceptioncategory_spec.rb} +0 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc9c7edbf457edfbf86475a5069da09613afe25
|
4
|
+
data.tar.gz: 0bc32e1c5c4485a8120dd51068d5d2726b80c576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
5
|
-
If
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
3
|
-
require
|
4
|
-
require 'net/http'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
class LogStash::Filters::ExceptionCategory < LogStash::Filters::Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
File without changes
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Ragnar Adolf Árnason
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
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:
|
42
|
-
email:
|
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/
|
53
|
-
homepage: http://www.
|
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:
|
78
|
+
summary: Categorizes exceptions
|
79
79
|
test_files: []
|