logstash-core 1.5.0.rc3.snapshot2-java → 1.5.0.rc3.snapshot3-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash/config/config_ast.rb +59 -15
- data/lib/logstash/event.rb +4 -0
- data/lib/logstash/filters/base.rb +0 -18
- data/lib/logstash/java_integration.rb +56 -17
- data/lib/logstash/util/accessors.rb +2 -1
- data/lib/logstash/version.rb +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: 349047620a2726f0c42566a25c9e6a2b229d9ece
|
4
|
+
data.tar.gz: d6d9a858c12499f66ff7f0d2e250267208bd77d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5fe3f78adde94e7fbc5327fdebb3534f3086f14d86d558a6f225c930256bbdf7edd9ce175bc08757e6c3cbc6872db8166a25f439718712a3eb20b5c5e4a18d0
|
7
|
+
data.tar.gz: d0f571cbc5d26b5b0a54a4e79b3ca87abb698bd5d4ad9a05bc6ff7ecfdf7f1f726f1b40c99643c99319f58d742d45f06f08c7a7c95048421051f7f2a9ada60cc
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'logstash/errors'
|
3
3
|
require "treetop"
|
4
|
+
|
4
5
|
class Treetop::Runtime::SyntaxNode
|
6
|
+
|
5
7
|
def compile
|
6
8
|
return "" if elements.nil?
|
7
9
|
return elements.collect(&:compile).reject(&:empty?).join("")
|
@@ -55,11 +57,31 @@ class Treetop::Runtime::SyntaxNode
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
60
|
+
|
58
61
|
module LogStash; module Config; module AST
|
62
|
+
|
63
|
+
def self.defered_conditionals=(val)
|
64
|
+
@defered_conditionals = val
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.defered_conditionals
|
68
|
+
@defered_conditionals
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.defered_conditionals_index
|
72
|
+
@defered_conditionals_index
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.defered_conditionals_index=(val)
|
76
|
+
@defered_conditionals_index = val
|
77
|
+
end
|
78
|
+
|
59
79
|
class Node < Treetop::Runtime::SyntaxNode; end
|
60
80
|
|
61
81
|
class Config < Node
|
62
82
|
def compile
|
83
|
+
LogStash::Config::AST.defered_conditionals = []
|
84
|
+
LogStash::Config::AST.defered_conditionals_index = 0
|
63
85
|
code = []
|
64
86
|
|
65
87
|
code << <<-CODE
|
@@ -94,6 +116,9 @@ module LogStash; module Config; module AST
|
|
94
116
|
end
|
95
117
|
|
96
118
|
code += definitions.join("\n").split("\n", -1).collect { |l| " #{l}" }
|
119
|
+
|
120
|
+
code += LogStash::Config::AST.defered_conditionals
|
121
|
+
|
97
122
|
return code.join("\n")
|
98
123
|
end
|
99
124
|
end
|
@@ -124,20 +149,15 @@ module LogStash; module Config; module AST
|
|
124
149
|
#{name}_flush = lambda do |options, &block|
|
125
150
|
@logger.debug? && @logger.debug(\"Flushing\", :plugin => #{name})
|
126
151
|
|
127
|
-
|
152
|
+
events = #{name}.flush(options)
|
128
153
|
|
129
|
-
return if
|
154
|
+
return if events.nil? || events.empty?
|
130
155
|
|
131
|
-
|
132
|
-
@logger.debug? && @logger.debug(\"Flushing\", :plugin => #{name}, :event => event)
|
156
|
+
@logger.debug? && @logger.debug(\"Flushing\", :plugin => #{name}, :events => events)
|
133
157
|
|
134
|
-
|
135
|
-
#{plugin.compile_starting_here.gsub(/^/, " ")}
|
136
|
-
|
137
|
-
block.call(event)
|
138
|
-
events.flatten.each{|e| block.call(e) if e != event}
|
139
|
-
end
|
158
|
+
#{plugin.compile_starting_here.gsub(/^/, " ")}
|
140
159
|
|
160
|
+
events.each{|e| block.call(e)}
|
141
161
|
end
|
142
162
|
|
143
163
|
if #{name}.respond_to?(:flush)
|
@@ -210,7 +230,7 @@ module LogStash; module Config; module AST
|
|
210
230
|
return "start_input(#{variable_name})"
|
211
231
|
when "filter"
|
212
232
|
return <<-CODE
|
213
|
-
|
233
|
+
#{variable_name}.filter(event) {|new_event| events << new_event }
|
214
234
|
CODE
|
215
235
|
when "output"
|
216
236
|
return "#{variable_name}.handle(event)\n"
|
@@ -357,14 +377,38 @@ module LogStash; module Config; module AST
|
|
357
377
|
# at the end, events is returned to handle the case where no branch match and no branch code is executed
|
358
378
|
# so we must make sure to return the current event.
|
359
379
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
380
|
+
type = recursive_select_parent(PluginSection).first.plugin_type.text_value
|
381
|
+
|
382
|
+
if type == "filter"
|
383
|
+
i = LogStash::Config::AST.defered_conditionals_index += 1
|
384
|
+
source = <<-CODE
|
385
|
+
def cond_func_#{i}(input_events)
|
386
|
+
result = []
|
387
|
+
input_events.each do |event|
|
388
|
+
events = [event]
|
389
|
+
#{super}
|
390
|
+
end
|
391
|
+
result += events
|
392
|
+
end
|
393
|
+
result
|
394
|
+
end
|
395
|
+
CODE
|
396
|
+
LogStash::Config::AST.defered_conditionals << source
|
397
|
+
|
398
|
+
<<-CODE
|
399
|
+
events = cond_func_#{i}(events)
|
400
|
+
CODE
|
401
|
+
else
|
402
|
+
<<-CODE
|
403
|
+
#{super}
|
404
|
+
end
|
405
|
+
CODE
|
406
|
+
end
|
364
407
|
end
|
365
408
|
end
|
366
409
|
|
367
410
|
class BranchEntry < Node; end
|
411
|
+
|
368
412
|
class If < BranchEntry
|
369
413
|
def compile
|
370
414
|
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
data/lib/logstash/event.rb
CHANGED
@@ -235,6 +235,10 @@ class LogStash::Event
|
|
235
235
|
# Take the inside of the %{ ... }
|
236
236
|
key = tok[2 ... -1]
|
237
237
|
|
238
|
+
if key[0] == "+" && !@data.has_key?(TIMESTAMP)
|
239
|
+
raise LogStash::Error, "Unable to format \"#{key}\" in string \"#{format}\", #{TIMESTAMP} field not found"
|
240
|
+
end
|
241
|
+
|
238
242
|
if key == "+%s"
|
239
243
|
# Got %{+%s}, support for unix epoch time
|
240
244
|
next @data[TIMESTAMP].to_i
|
@@ -146,24 +146,6 @@ class LogStash::Filters::Base < LogStash::Plugin
|
|
146
146
|
raise "#{self.class}#filter must be overidden"
|
147
147
|
end # def filter
|
148
148
|
|
149
|
-
|
150
|
-
# in 1.5.0 multi_filter is meant to be used in the generated filter function in LogStash::Config::AST::Plugin only
|
151
|
-
# and is temporary until we refactor the filter method interface to accept events list and return events list,
|
152
|
-
# just list in multi_filter see https://github.com/elastic/logstash/issues/2872.
|
153
|
-
# refactoring the filter method will mean updating all plugins which we want to avoid doing for 1.5.0.
|
154
|
-
#
|
155
|
-
# @param events [Array<LogStash::Event] list of events to filter
|
156
|
-
# @return [Array<LogStash::Event] filtered events and any new events generated by the filter
|
157
|
-
public
|
158
|
-
def multi_filter(events)
|
159
|
-
result = []
|
160
|
-
events.each do |event|
|
161
|
-
result << event
|
162
|
-
filter(event){|new_event| result << new_event}
|
163
|
-
end
|
164
|
-
result
|
165
|
-
end
|
166
|
-
|
167
149
|
public
|
168
150
|
def execute(event, &block)
|
169
151
|
filter(event, &block)
|
@@ -6,36 +6,75 @@ require "java"
|
|
6
6
|
# not test for is_a?(Array) or is_a?(Hash) and we do not want to include tests for
|
7
7
|
# both classes everywhere. see LogStash::JSon.
|
8
8
|
|
9
|
-
class
|
10
|
-
#
|
11
|
-
|
12
|
-
|
9
|
+
class Array
|
10
|
+
# enable class equivalence between Array and ArrayList
|
11
|
+
# so that ArrayList will work with case o when Array ...
|
12
|
+
def self.===(other)
|
13
|
+
return true if other.is_a?(Java::JavaUtil::Collection)
|
13
14
|
super
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
class Hash
|
19
|
+
# enable class equivalence between Hash and LinkedHashMap
|
20
|
+
# so that LinkedHashMap will work with case o when Hash ...
|
21
|
+
def self.===(other)
|
22
|
+
return true if other.is_a?(Java::JavaUtil::Map)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# this is a temporary fix to solve a bug in JRuby where classes implementing the Map interface, like LinkedHashMap
|
29
|
+
# have a bug in the has_key? method that is implemented in the Enumerable module that is somehow mixed in the Map interface.
|
30
|
+
# this bug makes has_key? (and all its aliases) return false for a key that has a nil value.
|
31
|
+
# Only LinkedHashMap is patched here because patching the Map interface is not working.
|
32
|
+
# TODO find proper fix, and submit upstream
|
33
|
+
# releavant JRuby files:
|
34
|
+
# https://github.com/jruby/jruby/blob/master/core/src/main/ruby/jruby/java/java_ext/java.util.rb
|
35
|
+
# https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/java/proxies/MapJavaProxy.java
|
17
36
|
class Java::JavaUtil::LinkedHashMap
|
18
|
-
|
37
|
+
def has_key?(key)
|
38
|
+
self.containsKey(key)
|
39
|
+
end
|
40
|
+
alias_method :include?, :has_key?
|
41
|
+
alias_method :member?, :has_key?
|
42
|
+
alias_method :key?, :has_key?
|
43
|
+
end
|
44
|
+
|
45
|
+
module java::util::Map
|
46
|
+
# have Map objects like LinkedHashMap objects report is_a?(Array) == true
|
19
47
|
def is_a?(clazz)
|
20
48
|
return true if clazz == Hash
|
21
49
|
super
|
22
50
|
end
|
23
51
|
end
|
24
52
|
|
25
|
-
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
return true if other.is_a?(Java::JavaUtil::ArrayList)
|
53
|
+
module java::util::Collection
|
54
|
+
# have Collections objects like ArrayList report is_a?(Array) == true
|
55
|
+
def is_a?(clazz)
|
56
|
+
return true if clazz == Array
|
30
57
|
super
|
31
58
|
end
|
32
|
-
end
|
33
59
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
60
|
+
# support the Ruby Array delete method on a Java Collection
|
61
|
+
def delete(o)
|
62
|
+
self.removeAll([o]) ? o : block_given? ? yield : nil
|
63
|
+
end
|
64
|
+
|
65
|
+
# support the Ruby intersection method on Java Collection
|
66
|
+
def &(other)
|
67
|
+
# transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array intersection contract
|
68
|
+
duped = Java::JavaUtil::LinkedHashSet.new(self)
|
69
|
+
duped.retainAll(other)
|
70
|
+
duped
|
71
|
+
end
|
72
|
+
|
73
|
+
# support the Ruby union method on Java Collection
|
74
|
+
def |(other)
|
75
|
+
# transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array union contract
|
76
|
+
duped = Java::JavaUtil::LinkedHashSet.new(self)
|
77
|
+
duped.addAll(other)
|
78
|
+
duped
|
40
79
|
end
|
41
80
|
end
|
data/lib/logstash/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.rc3.
|
4
|
+
version: 1.5.0.rc3.snapshot3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jordan Sissel
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-04-
|
13
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cabin
|