logstash-filter-grok 3.2.3 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/filters/grok/timeout_enforcer.rb +51 -26
- data/logstash-filter-grok.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b034532a205ad23ce96a26ec94a38168714f89b5
|
4
|
+
data.tar.gz: 864f130d2549eeafff4c1f4b5fdd8ab6e2646bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd8cfade5fef7b64a5199c500574db16848de04fade4cabbfae9c58f07667cc94c23a41ed117f383c683baf44ec06b1b6aeb1048349ca620d147f0139d1d2e7
|
7
|
+
data.tar.gz: 1753891e587a891e65cb57b540814d619192a9bf5ef1d71fedb703207e9d5004fd1da26f3cd0725430620555e5bad05b19c2d3b43ef0e79ab937298e71e5931f
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
java_import java.util.concurrent.locks.ReentrantLock
|
2
|
+
|
1
3
|
class LogStash::Filters::Grok::TimeoutEnforcer
|
2
4
|
attr_reader :running
|
3
|
-
|
5
|
+
|
4
6
|
def initialize(logger, timeout_nanos)
|
5
7
|
@logger = logger
|
6
8
|
@running = true
|
@@ -8,8 +10,8 @@ class LogStash::Filters::Grok::TimeoutEnforcer
|
|
8
10
|
|
9
11
|
# Stores running matches with their start time, this is used to cancel long running matches
|
10
12
|
# Is a map of Thread => start_time
|
11
|
-
@
|
12
|
-
@
|
13
|
+
@threads_to_start_time = {}
|
14
|
+
@state_lock = java.util.concurrent.locks.ReentrantLock.new
|
13
15
|
end
|
14
16
|
|
15
17
|
def grok_till_timeout(event, grok, field, value)
|
@@ -22,26 +24,59 @@ class LogStash::Filters::Grok::TimeoutEnforcer
|
|
22
24
|
ensure
|
23
25
|
stop_thread_groking(thread)
|
24
26
|
# Clear any interrupts from any previous invocations that were not caught by Joni
|
27
|
+
# It may appear that this should go in #stop_thread_groking but that would actually
|
28
|
+
# break functionality! If this were moved there we would clear the interrupt
|
29
|
+
# immediately after setting it in #cancel_timed_out, hence this MUST be here
|
25
30
|
thread.interrupted
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
34
|
+
def start!
|
35
|
+
@timer_thread = Thread.new do
|
36
|
+
while @running
|
37
|
+
begin
|
38
|
+
cancel_timed_out!
|
39
|
+
rescue Exception => e
|
40
|
+
@logger.error("Error while attempting to check/cancel excessively long grok patterns",
|
41
|
+
:message => e.message,
|
42
|
+
:class => e.class.name,
|
43
|
+
:backtrace => e.backtrace
|
44
|
+
)
|
45
|
+
end
|
46
|
+
sleep 0.25
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def stop!
|
52
|
+
@running = false
|
53
|
+
# Check for the thread mostly for a fast start/shutdown scenario
|
54
|
+
@timer_thread.join if @timer_thread
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# These methods are private in large part because if they aren't called
|
60
|
+
# in specific sequence and used together in specific ways the interrupt
|
61
|
+
# behavior will be incorrect. Do NOT use or modify these methods unless
|
62
|
+
# you know what you are doing!
|
63
|
+
|
29
64
|
def start_thread_groking(thread)
|
30
65
|
# Clear any interrupts from any previous invocations that were not caught by Joni
|
31
66
|
thread.interrupted
|
32
|
-
|
67
|
+
synchronize do
|
33
68
|
@threads_to_start_time[thread] = java.lang.System.nanoTime()
|
34
69
|
end
|
35
70
|
end
|
36
71
|
|
37
72
|
def stop_thread_groking(thread)
|
38
|
-
|
73
|
+
synchronize do
|
39
74
|
@threads_to_start_time.delete(thread)
|
40
75
|
end
|
41
76
|
end
|
42
77
|
|
43
78
|
def cancel_timed_out!
|
44
|
-
|
79
|
+
synchronize do
|
45
80
|
@threads_to_start_time.each do |thread,start_time|
|
46
81
|
now = java.lang.System.nanoTime # save ourselves some nanotime calls
|
47
82
|
elapsed = java.lang.System.nanoTime - start_time
|
@@ -56,26 +91,16 @@ class LogStash::Filters::Grok::TimeoutEnforcer
|
|
56
91
|
end
|
57
92
|
end
|
58
93
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
:backtrace => e.backtrace
|
69
|
-
)
|
70
|
-
end
|
71
|
-
sleep 0.25
|
72
|
-
end
|
73
|
-
end
|
94
|
+
# We use this instead of a Mutex because JRuby mutexes are interruptible
|
95
|
+
# We actually don't want that behavior since we always clear the interrupt in
|
96
|
+
# grok_till_timeout
|
97
|
+
def synchronize
|
98
|
+
# The JRuby Mutex uses lockInterruptibly which is what we DO NOT want
|
99
|
+
@state_lock.lock()
|
100
|
+
yield
|
101
|
+
ensure
|
102
|
+
@state_lock.unlock()
|
74
103
|
end
|
75
104
|
|
76
|
-
|
77
|
-
@running = false
|
78
|
-
# Check for the thread mostly for a fast start/shutdown scenario
|
79
|
-
@timer_thread.join if @timer_thread
|
80
|
-
end
|
105
|
+
|
81
106
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-grok'
|
4
|
-
s.version = '3.2.
|
4
|
+
s.version = '3.2.4'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Parse arbitrary text and structure it."
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-grok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|