logstash-filter-java_stack_digest 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +11 -0
- data/README.md +86 -0
- data/lib/logstash/filters/java_stack_digest.rb +129 -0
- data/logstash-filter-java_stack_digest.gemspec +23 -0
- data/spec/filters/java_stack_digest_spec.rb +165 -0
- data/spec/spec_helper.rb +2 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a0dd81d1918a7eb930634c65283b9716c753c3721f87659aff1ff471ed40f6db
|
4
|
+
data.tar.gz: 174b1436664b23d69003d2ad96423e9162b60e62e16ede20173ae2f996c98732
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d95b2391c05acea7d7da3fad911930d9ef2d69cb95f61d6d643685b15c7a1b946c8c89ef4a509efc291d954d3f9e16dcc018a6840e151dd8c6967b2df7bd884
|
7
|
+
data.tar.gz: 412c45a60b44075a197c714bcbe3ec2b18ae91569ec98393d1e44a4afc467fee7ea81d3e2068bb208290fc4eb714f07e453705738adffaecbfd3e4e2ac122747
|
data/CHANGELOG.md
ADDED
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
|
+
* Pierre Smeyers - pismy
|
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
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
|
+
|
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.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
10
|
+
|
11
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
- Update your dependencies
|
35
|
+
|
36
|
+
```sh
|
37
|
+
bundle install
|
38
|
+
```
|
39
|
+
|
40
|
+
- Run tests
|
41
|
+
|
42
|
+
```sh
|
43
|
+
bundle exec rspec
|
44
|
+
```
|
45
|
+
|
46
|
+
### 2. Running your unpublished Plugin in Logstash
|
47
|
+
|
48
|
+
#### 2.1 Run in a local Logstash clone
|
49
|
+
|
50
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
51
|
+
```ruby
|
52
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
53
|
+
```
|
54
|
+
- Install plugin
|
55
|
+
```sh
|
56
|
+
bin/logstash-plugin install --no-verify
|
57
|
+
```
|
58
|
+
- Run Logstash with your plugin
|
59
|
+
```sh
|
60
|
+
bin/logstash -e 'filter {awesome {}}'
|
61
|
+
```
|
62
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
63
|
+
|
64
|
+
#### 2.2 Run in an installed Logstash
|
65
|
+
|
66
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
67
|
+
|
68
|
+
- Build your plugin gem
|
69
|
+
```sh
|
70
|
+
gem build logstash-filter-awesome.gemspec
|
71
|
+
```
|
72
|
+
- Install the plugin from the Logstash home
|
73
|
+
```sh
|
74
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
75
|
+
```
|
76
|
+
- Start Logstash and proceed to test the plugin
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
81
|
+
|
82
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
83
|
+
|
84
|
+
It is more important to the community that you are able to contribute.
|
85
|
+
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/filters/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
# If the input event contains a Java stack trace, this filter computes a stable digest of it and adds it
|
6
|
+
# in a field of the output event
|
7
|
+
class LogStash::Filters::JavaStackDigest < LogStash::Filters::Base
|
8
|
+
|
9
|
+
# Setting the config_name here is required. This is how you
|
10
|
+
# configure this filter from your Logstash config.
|
11
|
+
#
|
12
|
+
# java_stack_digest {
|
13
|
+
# {
|
14
|
+
# source => "stack_trace"
|
15
|
+
# }
|
16
|
+
# }
|
17
|
+
#
|
18
|
+
config_name "java_stack_digest"
|
19
|
+
|
20
|
+
# activates debug traces
|
21
|
+
config :debug, :validate => :boolean, :default => false
|
22
|
+
|
23
|
+
# The name of the input field supposed to contain the Java stack trace (default 'stack_trace').
|
24
|
+
config :source, :validate => :string, :default => "stack_trace"
|
25
|
+
|
26
|
+
# The name of the output field to assign the computed stack trace digest (default 'stack_digest').
|
27
|
+
config :target, :validate => :string, :default => "stack_digest"
|
28
|
+
|
29
|
+
# Determines whether stack trace elements without source info (no filename or line number) should be excluded from the digest (default 'true')
|
30
|
+
config :exclude_no_source, :validate => :boolean, :default => true
|
31
|
+
|
32
|
+
# Array of regular expressions to exclude stack trace elements
|
33
|
+
# defaults to standard dynamic classes and method invocations
|
34
|
+
# config :excludes, :validate => :array, :default => %w["\\$\\$FastClassByCGLIB\\$\\$", "\\$\\$EnhancerBySpringCGLIB\\$\\$", "^sun\\.reflect\\..*\\.invoke", "^com\\.sun\\.", "^sun\\.net\\.", "^java\\.lang\\.reflect\\.Method\\.invoke", "^net\\.sf\\.cglib\\.proxy\\.MethodProxy\\.invoke", "^java\\.util\\.concurrent\\.ThreadPoolExecutor\\.runWorker","^java\\.lang\\.Thread\\.run$" ]
|
35
|
+
config :excludes, :validate => :array, :default => [/\$\$FastClassByCGLIB\$\$/, /\$\$EnhancerBySpringCGLIB\$\$/, /^sun\.reflect\..*\.invoke/, /^com\.sun\./, /^sun\.net\./, /^java\.lang\.reflect\.Method\.invoke/, /^net\.sf\.cglib\.proxy\.MethodProxy\.invoke/, /^java\.util\.concurrent\.ThreadPoolExecutor\.runWorker/, /^java\.lang\.Thread\.run$/ ]
|
36
|
+
|
37
|
+
public
|
38
|
+
def register
|
39
|
+
# Add instance variables
|
40
|
+
|
41
|
+
# Regexp to capture the Error classname from the first stack trace line
|
42
|
+
# group 1: error classname
|
43
|
+
@error_pattern = /((?:[\w$]+\.){2,}[\w$]+):/
|
44
|
+
|
45
|
+
# Regexp to extract stack trace elements information
|
46
|
+
# group 1: classname+method
|
47
|
+
# group 2: filename (optional)
|
48
|
+
# group 3: line number (optional)
|
49
|
+
@stack_element_pattern = /^\s+at\s+((?:[\w$]+\.){2,}[\w$]+)\((?:([^:]+)(?::(\d+))?)?\)/
|
50
|
+
|
51
|
+
# coerce excludes to an array of Regexp
|
52
|
+
@excludes = @excludes.collect {|pattern| Regexp::new(pattern)}
|
53
|
+
end # def register
|
54
|
+
|
55
|
+
public
|
56
|
+
def filter(event)
|
57
|
+
|
58
|
+
stack_trace = event.get(@source)
|
59
|
+
|
60
|
+
return if stack_trace.nil? || stack_trace.empty?
|
61
|
+
|
62
|
+
event.set(@target, compute_digest(stack_trace.split("\n"), 0))
|
63
|
+
|
64
|
+
# filter_matched should go in the last line of our successful code
|
65
|
+
filter_matched(event)
|
66
|
+
end # def filter
|
67
|
+
|
68
|
+
# computes a Java stack trace digest
|
69
|
+
def compute_digest(stack_trace, level)
|
70
|
+
|
71
|
+
# 1: extract error class from first line
|
72
|
+
error_class = @error_pattern.match(stack_trace.shift)
|
73
|
+
puts "Error (#{level}) #{error_class}:" if @debug
|
74
|
+
md5 = Digest::MD5.new
|
75
|
+
# digest: error classname
|
76
|
+
md5.update error_class[1]
|
77
|
+
|
78
|
+
# 2: read all stack trace elements until stack trace is empty or we hit the next error
|
79
|
+
ste_count = 0
|
80
|
+
while not stack_trace.empty?
|
81
|
+
if stack_trace.first.start_with?(' ') or stack_trace.first.start_with?("\t")
|
82
|
+
# current line starts with a whitespace: is it a stack trace element ?
|
83
|
+
stack_element = @stack_element_pattern.match(stack_trace.first)
|
84
|
+
if stack_element
|
85
|
+
# current line is a stack trace element
|
86
|
+
ste_count+=1
|
87
|
+
if is_excluded?(stack_element)
|
88
|
+
puts " (-) at #{stack_element[1]}(#{stack_element[2]}:#{stack_element[3]})" if @debug
|
89
|
+
else
|
90
|
+
puts " (+) at #{stack_element[1]}(#{stack_element[2]}:#{stack_element[3]})" if @debug
|
91
|
+
# digest: STE classname and method
|
92
|
+
md5.update stack_element[1]
|
93
|
+
# digest: line number (if present)
|
94
|
+
if not (stack_element[3].nil? or stack_element[3].empty?)
|
95
|
+
md5.update stack_element[3]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
elsif(ste_count > 0)
|
100
|
+
# current line doesn't start with a whitespace and we've already read stack trace elements: is it the next error in the stack
|
101
|
+
break
|
102
|
+
end
|
103
|
+
# move to next line
|
104
|
+
stack_trace.shift
|
105
|
+
end
|
106
|
+
|
107
|
+
# 3: if stack trace not empty, compute digest for next error
|
108
|
+
if not stack_trace.empty?
|
109
|
+
md5.update compute_digest(stack_trace, level+1)
|
110
|
+
end
|
111
|
+
|
112
|
+
return md5.hexdigest
|
113
|
+
end
|
114
|
+
|
115
|
+
def is_excluded?(stack_element)
|
116
|
+
# 1: exclude elements without source info ?
|
117
|
+
if @exclude_no_source and (stack_element[2].nil? or stack_element[2].empty?) and (stack_element[3].nil? or stack_element[3].empty?)
|
118
|
+
return true
|
119
|
+
end
|
120
|
+
# 2: Regex based exclusion
|
121
|
+
@excludes.each do |pattern|
|
122
|
+
if pattern.match(stack_element[1])
|
123
|
+
return true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
|
129
|
+
end # class LogStash::Filters::JavaStackDigest
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-java_stack_digest'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'Logstash filter that computes a digest of Java stack traces.'
|
6
|
+
s.description = 'Logstash filter that computes a digest of Java stack traces.'
|
7
|
+
s.homepage = 'https://github.com/pismy/logstash-filter-java_stack_digest'
|
8
|
+
s.authors = ['Pierre Smeyers']
|
9
|
+
s.email = 'pierre.smeyers@gmail.com'
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
|
+
# Tests
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
|
17
|
+
# Special flag to let us know this is actually a logstash plugin
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
19
|
+
|
20
|
+
# Gem dependencies
|
21
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
22
|
+
s.add_development_dependency 'logstash-devutils'
|
23
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
require "logstash/filters/java_stack_digest"
|
4
|
+
|
5
|
+
describe LogStash::Filters::JavaStackDigest do
|
6
|
+
stack_trace = %q(com.xyz.MyApp$MyClient$MyClientException: An error occurred while getting Alice's things
|
7
|
+
and the error message wraps on
|
8
|
+
several lines
|
9
|
+
at com.xyz.MyApp$MyClient.getTheThings(MyApp.java:26)
|
10
|
+
at com.xyz.MyApp$MyService.displayThings(MyApp.java:16)
|
11
|
+
at com.xyz.MyApp$MyService$$FastClassByCGLIB$$e7645040.invoke()
|
12
|
+
at net.sf.cglib.proxy.MethodProxy.invoke()
|
13
|
+
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint()
|
14
|
+
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
|
15
|
+
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed()
|
16
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke0()
|
17
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke()
|
18
|
+
at sun.reflect.DelegatingMethodAccessorImpl.invoke()
|
19
|
+
at java.lang.reflect.Method.invoke()
|
20
|
+
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs()
|
21
|
+
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod()
|
22
|
+
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke()
|
23
|
+
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
|
24
|
+
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke()
|
25
|
+
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
|
26
|
+
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke()
|
27
|
+
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
|
28
|
+
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke()
|
29
|
+
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
|
30
|
+
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept()
|
31
|
+
at com.xyz.MyApp$MyService$$EnhancerBySpringCGLIB$$c673c675.displayThings(<generated>)
|
32
|
+
at sun.reflect.GeneratedMethodAccessor647.invoke(Unknown Source)
|
33
|
+
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
34
|
+
at java.lang.reflect.Method.invoke(Method.java:498)
|
35
|
+
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
36
|
+
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
|
37
|
+
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
|
38
|
+
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
|
39
|
+
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
|
40
|
+
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
|
41
|
+
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
|
42
|
+
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
|
43
|
+
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
|
44
|
+
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
|
45
|
+
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
|
46
|
+
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
|
47
|
+
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
48
|
+
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
|
49
|
+
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
|
50
|
+
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
51
|
+
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
|
52
|
+
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
|
53
|
+
...
|
54
|
+
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
|
55
|
+
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
|
56
|
+
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
|
57
|
+
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
|
58
|
+
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
|
59
|
+
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
|
60
|
+
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
|
61
|
+
...
|
62
|
+
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
|
63
|
+
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
|
64
|
+
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
|
65
|
+
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
|
66
|
+
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
|
67
|
+
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
|
68
|
+
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
|
69
|
+
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
70
|
+
at java.lang.Thread.run(Thread.java:748)
|
71
|
+
...
|
72
|
+
Caused by: com.xyz.MyApp$HttpStack$HttpError: I/O error on GET http://dummy/user/alice/things
|
73
|
+
at com.xyz.MyApp$HttpStack.get(MyApp.java:40)
|
74
|
+
at com.xyz.MyApp$MyClient.getTheThings(MyApp.java:24)
|
75
|
+
... 23 common frames omitted
|
76
|
+
Caused by: java.net.SocketTimeoutException: Read timed out
|
77
|
+
at com.xyz.MyApp$HttpStack.get(MyApp.java:38)
|
78
|
+
... 24 common frames omitted)
|
79
|
+
|
80
|
+
# ---------------------------------------------------------------------
|
81
|
+
describe "Digest should be computed if stack trace present" do
|
82
|
+
let(:config) do <<-CONFIG
|
83
|
+
filter {
|
84
|
+
java_stack_digest {
|
85
|
+
}
|
86
|
+
}
|
87
|
+
CONFIG
|
88
|
+
end
|
89
|
+
|
90
|
+
sample("stack_trace" => stack_trace) do
|
91
|
+
expect(subject).to include("stack_digest")
|
92
|
+
expect(subject.get('stack_digest')).to eq('e801d2223555804c354eba382af40487')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# ---------------------------------------------------------------------
|
97
|
+
describe "Digest should not be computed if stack not trace present" do
|
98
|
+
let(:config) do <<-CONFIG
|
99
|
+
filter {
|
100
|
+
java_stack_digest {
|
101
|
+
}
|
102
|
+
}
|
103
|
+
CONFIG
|
104
|
+
end
|
105
|
+
|
106
|
+
sample("field" => "value") do
|
107
|
+
expect(subject).not_to include("stack_digest")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# ---------------------------------------------------------------------
|
112
|
+
describe "Digest with exclusion config 1" do
|
113
|
+
let(:config) do <<-CONFIG
|
114
|
+
filter {
|
115
|
+
java_stack_digest {
|
116
|
+
exclude_no_source => false
|
117
|
+
}
|
118
|
+
}
|
119
|
+
CONFIG
|
120
|
+
end
|
121
|
+
|
122
|
+
sample("stack_trace" => stack_trace) do
|
123
|
+
expect(subject).to include("stack_digest")
|
124
|
+
expect(subject.get('stack_digest')).to eq('498f8151629971495ed5dd8c3713d45e')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# ---------------------------------------------------------------------
|
129
|
+
describe "Digest with exclusion config 2" do
|
130
|
+
let(:config) do <<-CONFIG
|
131
|
+
filter {
|
132
|
+
java_stack_digest {
|
133
|
+
exclude_no_source => false
|
134
|
+
excludes => ['\\$\\$FastClassByCGLIB\\$\\$', '\\$\\$EnhancerBySpringCGLIB\\$\\$']
|
135
|
+
}
|
136
|
+
}
|
137
|
+
CONFIG
|
138
|
+
end
|
139
|
+
|
140
|
+
sample("stack_trace" => stack_trace) do
|
141
|
+
expect(subject).to include("stack_digest")
|
142
|
+
expect(subject.get('stack_digest')).to eq('ff887f4f5d9e588df37afbb4ceee6980')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# ---------------------------------------------------------------------
|
147
|
+
describe "Digest should be computed if stack trace present with non default config" do
|
148
|
+
let(:config) do <<-CONFIG
|
149
|
+
filter {
|
150
|
+
java_stack_digest {
|
151
|
+
source => "java_stack"
|
152
|
+
target => "stack_md5"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
CONFIG
|
156
|
+
end
|
157
|
+
|
158
|
+
sample("java_stack" => stack_trace) do
|
159
|
+
expect(subject).to include("stack_md5")
|
160
|
+
expect(subject.get('stack_md5')).to eq('e801d2223555804c354eba382af40487')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-java_stack_digest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pierre Smeyers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-30 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: '2.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: '2.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: Logstash filter that computes a digest of Java stack traces.
|
42
|
+
email: pierre.smeyers@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- CHANGELOG.md
|
48
|
+
- CONTRIBUTORS
|
49
|
+
- DEVELOPER.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- lib/logstash/filters/java_stack_digest.rb
|
54
|
+
- logstash-filter-java_stack_digest.gemspec
|
55
|
+
- spec/filters/java_stack_digest_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: https://github.com/pismy/logstash-filter-java_stack_digest
|
58
|
+
licenses:
|
59
|
+
- Apache-2.0
|
60
|
+
metadata:
|
61
|
+
logstash_plugin: 'true'
|
62
|
+
logstash_group: filter
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.6.13
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Logstash filter that computes a digest of Java stack traces.
|
83
|
+
test_files:
|
84
|
+
- spec/filters/java_stack_digest_spec.rb
|
85
|
+
- spec/spec_helper.rb
|