logstash-core-event-java 2.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar +0 -0
- data/lib/logstash-core-event-java.rb +1 -0
- data/lib/logstash-core-event-java/logstash-core-event-java.jar +0 -0
- data/lib/logstash-core-event-java/logstash-core-event-java.rb +28 -0
- data/lib/logstash-core-event-java/version.rb +8 -0
- data/lib/logstash-core-event-java_jars.rb +6 -0
- data/lib/logstash-core-event.rb +1 -0
- data/lib/logstash/event.rb +26 -0
- data/lib/logstash/string_interpolation.rb +18 -0
- data/lib/logstash/timestamp.rb +28 -0
- data/lib/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar +0 -0
- data/lib/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar +0 -0
- data/logstash-core-event-java.gemspec +31 -0
- data/spec/event_spec.rb +289 -0
- data/spec/timestamp_spec.rb +29 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b8b4e8b94ae05ed8f2eb1af7bd990be9acf5322
|
4
|
+
data.tar.gz: cef8c61a58927d1907d798da7732d4e1288645c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f16f37d45723ffd2297634a285a2b0f7213daa7361df2f5e321d770b81f70f45e3e10c67ba657fe390ffda04bec247a470b8746706b074457653848d1bb316c
|
7
|
+
data.tar.gz: 454ce13338a43a136f53596f498e18d7a154e5b59e8733346d7e4b3a5fdceef5e6068017ba6e428f96794fb2a486b2250983a2f13c7be7ecb640333f56b128f0
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash-core-event-java/logstash-core-event-java"
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "java"
|
4
|
+
|
5
|
+
module LogStash
|
6
|
+
end
|
7
|
+
|
8
|
+
require "logstash-core-event-java_jars"
|
9
|
+
|
10
|
+
# local dev setup
|
11
|
+
classes_dir = File.expand_path("../../../build/classes/main", __FILE__)
|
12
|
+
|
13
|
+
if File.directory?(classes_dir)
|
14
|
+
# if in local dev setup, add target to classpath
|
15
|
+
$CLASSPATH << classes_dir unless $CLASSPATH.include?(classes_dir)
|
16
|
+
else
|
17
|
+
# otherwise use included jar
|
18
|
+
begin
|
19
|
+
require "logstash-core-event-java/logstash-core-event-java.jar"
|
20
|
+
rescue Exception => e
|
21
|
+
raise("Error loading logstash-core-event-java/logstash-core-event-java.jar file, cause: #{e.message}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require "jruby_event_ext"
|
26
|
+
require "jruby_timestamp_ext"
|
27
|
+
require "logstash/event"
|
28
|
+
require "logstash/timestamp"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# this is a generated file, to avoid over-writing it just delete this comment
|
2
|
+
require 'jar_dependencies'
|
3
|
+
|
4
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.7.1' )
|
5
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.7.0' )
|
6
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.7.1-1' )
|
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash-core-event-java/logstash-core-event-java"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "logstash/json"
|
5
|
+
require "logstash/string_interpolation"
|
6
|
+
require "cabin"
|
7
|
+
|
8
|
+
# transcient pipeline events for normal in-flow signaling as opposed to
|
9
|
+
# flow altering exceptions. for now having base classes is adequate and
|
10
|
+
# in the future it might be necessary to refactor using like a BaseEvent
|
11
|
+
# class to have a common interface for all pileline events to support
|
12
|
+
# eventual queueing persistence for example, TBD.
|
13
|
+
class LogStash::ShutdownEvent; end
|
14
|
+
class LogStash::FlushEvent; end
|
15
|
+
|
16
|
+
module LogStash
|
17
|
+
FLUSH = LogStash::FlushEvent.new
|
18
|
+
|
19
|
+
# LogStash::SHUTDOWN is used by plugins
|
20
|
+
SHUTDOWN = LogStash::ShutdownEvent.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# for backward compatibility, require "logstash/event" is used a lots of places so let's bootstrap the
|
24
|
+
# Java code loading from here.
|
25
|
+
# TODO: (colin) I think we should mass replace require "logstash/event" with require "logstash-core-event"
|
26
|
+
require "logstash-core-event"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module LogStash
|
4
|
+
module StringInterpolation
|
5
|
+
extend self
|
6
|
+
|
7
|
+
# clear the global compiled templates cache
|
8
|
+
def clear_cache
|
9
|
+
Java::ComLogstash::StringInterpolation.get_instance.clear_cache;
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Fixnum] the compiled templates cache size
|
13
|
+
def cache_size
|
14
|
+
Java::ComLogstash::StringInterpolation.get_instance.cache_size;
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "logstash-core-event"
|
5
|
+
|
6
|
+
module LogStash
|
7
|
+
class TimestampParserError < StandardError; end
|
8
|
+
|
9
|
+
class Timestamp
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
# TODO (colin) implement in Java
|
13
|
+
def <=>(other)
|
14
|
+
self.time <=> other.time
|
15
|
+
end
|
16
|
+
|
17
|
+
# TODO (colin) implement in Java
|
18
|
+
def +(other)
|
19
|
+
self.time + other
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO (colin) implement in Java
|
23
|
+
def -(value)
|
24
|
+
self.time - (value.is_a?(Timestamp) ? value.time : value)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'logstash-core-event-java/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.authors = ["Elastic"]
|
8
|
+
gem.email = ["info@elastic.co"]
|
9
|
+
gem.description = %q{The core event component of logstash, the scalable log and event management tool}
|
10
|
+
gem.summary = %q{logstash-core-event-java - The core event component of logstash}
|
11
|
+
gem.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
12
|
+
gem.license = "Apache License (2.0)"
|
13
|
+
|
14
|
+
gem.files = Dir.glob(["logstash-core-event-java.gemspec", "lib/**/*.jar", "lib/**/*.rb", "spec/**/*.rb"])
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "logstash-core-event-java"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = LOGSTASH_CORE_EVENT_JAVA_VERSION
|
19
|
+
|
20
|
+
gem.platform = "java"
|
21
|
+
|
22
|
+
gem.add_runtime_dependency "jar-dependencies"
|
23
|
+
|
24
|
+
# as of Feb 3rd 2016, the ruby-maven gem is resolved to version 3.3.3 and that version
|
25
|
+
# has an rdoc problem that causes a bundler exception. 3.3.9 is the current latest version
|
26
|
+
# which does not have this problem.
|
27
|
+
gem.add_runtime_dependency "ruby-maven", "~> 3.3.9"
|
28
|
+
|
29
|
+
gem.requirements << "jar com.fasterxml.jackson.core:jackson-core, 2.7.1"
|
30
|
+
gem.requirements << "jar com.fasterxml.jackson.core:jackson-databind, 2.7.1-1"
|
31
|
+
end
|
data/spec/event_spec.rb
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "logstash/util"
|
5
|
+
require "logstash/event"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
TIMESTAMP = "@timestamp"
|
9
|
+
|
10
|
+
describe LogStash::Event do
|
11
|
+
context "to_json" do
|
12
|
+
it "should serialize simple values" do
|
13
|
+
e = LogStash::Event.new({"foo" => "bar", "bar" => 1, "baz" => 1.0, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
14
|
+
expect(JSON.parse(e.to_json)).to eq(JSON.parse("{\"foo\":\"bar\",\"bar\":1,\"baz\":1.0,\"@timestamp\":\"2015-05-28T23:02:05.350Z\",\"@version\":\"1\"}"))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should serialize deep hash values" do
|
18
|
+
e = LogStash::Event.new({"foo" => {"bar" => 1, "baz" => 1.0, "biz" => "boz"}, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
19
|
+
expect(JSON.parse(e.to_json)).to eq(JSON.parse("{\"foo\":{\"bar\":1,\"baz\":1.0,\"biz\":\"boz\"},\"@timestamp\":\"2015-05-28T23:02:05.350Z\",\"@version\":\"1\"}"))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should serialize deep array values" do
|
23
|
+
e = LogStash::Event.new({"foo" => ["bar", 1, 1.0], TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
24
|
+
expect(JSON.parse(e.to_json)).to eq(JSON.parse("{\"foo\":[\"bar\",1,1.0],\"@timestamp\":\"2015-05-28T23:02:05.350Z\",\"@version\":\"1\"}"))
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should serialize deep hash from field reference assignments" do
|
28
|
+
e = LogStash::Event.new({TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
29
|
+
e["foo"] = "bar"
|
30
|
+
e["bar"] = 1
|
31
|
+
e["baz"] = 1.0
|
32
|
+
e["[fancy][pants][socks]"] = "shoes"
|
33
|
+
expect(JSON.parse(e.to_json)).to eq(JSON.parse("{\"@timestamp\":\"2015-05-28T23:02:05.350Z\",\"@version\":\"1\",\"foo\":\"bar\",\"bar\":1,\"baz\":1.0,\"fancy\":{\"pants\":{\"socks\":\"shoes\"}}}"))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "[]" do
|
38
|
+
it "should get simple values" do
|
39
|
+
e = LogStash::Event.new({"foo" => "bar", "bar" => 1, "baz" => 1.0, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
40
|
+
expect(e["foo"]).to eq("bar")
|
41
|
+
expect(e["[foo]"]).to eq("bar")
|
42
|
+
expect(e["bar"]).to eq(1)
|
43
|
+
expect(e["[bar]"]).to eq(1)
|
44
|
+
expect(e["baz"]).to eq(1.0)
|
45
|
+
expect(e["[baz]"]).to eq(1.0)
|
46
|
+
expect(e[TIMESTAMP].to_s).to eq("2015-05-28T23:02:05.350Z")
|
47
|
+
expect(e["[#{TIMESTAMP}]"].to_s).to eq("2015-05-28T23:02:05.350Z")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should get deep hash values" do
|
51
|
+
e = LogStash::Event.new({"foo" => {"bar" => 1, "baz" => 1.0}})
|
52
|
+
expect(e["[foo][bar]"]).to eq(1)
|
53
|
+
expect(e["[foo][baz]"]).to eq(1.0)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should get deep array values" do
|
57
|
+
e = LogStash::Event.new({"foo" => ["bar", 1, 1.0]})
|
58
|
+
expect(e["[foo][0]"]).to eq("bar")
|
59
|
+
expect(e["[foo][1]"]).to eq(1)
|
60
|
+
expect(e["[foo][2]"]).to eq(1.0)
|
61
|
+
expect(e["[foo][3]"]).to be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "[]=" do
|
66
|
+
it "should set simple values" do
|
67
|
+
e = LogStash::Event.new()
|
68
|
+
expect(e["foo"] = "bar").to eq("bar")
|
69
|
+
expect(e["foo"]).to eq("bar")
|
70
|
+
|
71
|
+
e = LogStash::Event.new({"foo" => "test"})
|
72
|
+
expect(e["foo"] = "bar").to eq("bar")
|
73
|
+
expect(e["foo"]).to eq("bar")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should set deep hash values" do
|
77
|
+
e = LogStash::Event.new()
|
78
|
+
expect(e["[foo][bar]"] = "baz").to eq("baz")
|
79
|
+
expect(e["[foo][bar]"]).to eq("baz")
|
80
|
+
expect(e["[foo][baz]"]).to be_nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should set deep array values" do
|
84
|
+
e = LogStash::Event.new()
|
85
|
+
expect(e["[foo][0]"] = "bar").to eq("bar")
|
86
|
+
expect(e["[foo][0]"]).to eq("bar")
|
87
|
+
expect(e["[foo][1]"] = 1).to eq(1)
|
88
|
+
expect(e["[foo][1]"]).to eq(1)
|
89
|
+
expect(e["[foo][2]"] = 1.0 ).to eq(1.0)
|
90
|
+
expect(e["[foo][2]"]).to eq(1.0)
|
91
|
+
expect(e["[foo][3]"]).to be_nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should add key when setting nil value" do
|
95
|
+
e = LogStash::Event.new()
|
96
|
+
e["[foo]"] = nil
|
97
|
+
expect(e.to_hash).to include("foo" => nil)
|
98
|
+
end
|
99
|
+
|
100
|
+
# BigDecinal is now natively converted by JRuby, see https://github.com/elastic/logstash/pull/4838
|
101
|
+
it "should set BigDecimal" do
|
102
|
+
e = LogStash::Event.new()
|
103
|
+
e["[foo]"] = BigDecimal.new(1)
|
104
|
+
expect(e["foo"]).to be_kind_of(BigDecimal)
|
105
|
+
expect(e["foo"]).to eq(BigDecimal.new(1))
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should set RubyBignum" do
|
109
|
+
e = LogStash::Event.new()
|
110
|
+
e["[foo]"] = -9223372036854776000
|
111
|
+
expect(e["foo"]).to be_kind_of(Bignum)
|
112
|
+
expect(e["foo"]).to eq(-9223372036854776000)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "timestamp" do
|
117
|
+
it "getters should present a Ruby LogStash::Timestamp" do
|
118
|
+
e = LogStash::Event.new()
|
119
|
+
expect(e.timestamp.class).to eq(LogStash::Timestamp)
|
120
|
+
expect(e[TIMESTAMP].class).to eq(LogStash::Timestamp)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "to_hash should inject a Ruby LogStash::Timestamp" do
|
124
|
+
e = LogStash::Event.new()
|
125
|
+
|
126
|
+
expect(e.to_java).to be_kind_of(Java::ComLogstash::Event)
|
127
|
+
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::ComLogstash::Timestamp)
|
128
|
+
|
129
|
+
expect(e.to_hash[TIMESTAMP]).to be_kind_of(LogStash::Timestamp)
|
130
|
+
# now make sure the original map was not touched
|
131
|
+
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::ComLogstash::Timestamp)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should set timestamp" do
|
135
|
+
e = LogStash::Event.new
|
136
|
+
now = Time.now
|
137
|
+
e["@timestamp"] = LogStash::Timestamp.at(now.to_i)
|
138
|
+
expect(e.timestamp.to_i).to eq(now.to_i)
|
139
|
+
expect(e["@timestamp"].to_i).to eq(now.to_i)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "append" do
|
144
|
+
it "should append" do
|
145
|
+
event = LogStash::Event.new("message" => "hello world")
|
146
|
+
event.append(LogStash::Event.new("message" => "another thing"))
|
147
|
+
expect(event["message"]).to eq(["hello world", "another thing"])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "tags" do
|
152
|
+
it "should tag" do
|
153
|
+
event = LogStash::Event.new("message" => "hello world")
|
154
|
+
expect(event["tags"]).to be_nil
|
155
|
+
event["tags"] = ["foo"]
|
156
|
+
expect(event["tags"]).to eq(["foo"])
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
# noop logger used to test the injectable logger in Event
|
162
|
+
# this implementation is not complete because only the warn
|
163
|
+
# method is used in Event.
|
164
|
+
module DummyLogger
|
165
|
+
def self.warn(message)
|
166
|
+
# do nothing
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "logger" do
|
171
|
+
|
172
|
+
let(:logger) { double("Logger") }
|
173
|
+
after(:each) { LogStash::Event.logger = LogStash::Event::DEFAULT_LOGGER }
|
174
|
+
|
175
|
+
# the following 2 specs are using both a real module (DummyLogger)
|
176
|
+
# and a mock. both tests are needed to make sure the implementation
|
177
|
+
# supports both types of objects.
|
178
|
+
|
179
|
+
it "should set logger using a module" do
|
180
|
+
LogStash::Event.logger = DummyLogger
|
181
|
+
expect(DummyLogger).to receive(:warn).once
|
182
|
+
LogStash::Event.new(TIMESTAMP => "invalid timestamp")
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should set logger using a mock" do
|
186
|
+
LogStash::Event.logger = logger
|
187
|
+
expect(logger).to receive(:warn).once
|
188
|
+
LogStash::Event.new(TIMESTAMP => "invalid timestamp")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should unset logger" do
|
192
|
+
# first set
|
193
|
+
LogStash::Event.logger = logger
|
194
|
+
expect(logger).to receive(:warn).once
|
195
|
+
LogStash::Event.new(TIMESTAMP => "invalid timestamp")
|
196
|
+
|
197
|
+
# then unset
|
198
|
+
LogStash::Event.logger = LogStash::Event::DEFAULT_LOGGER
|
199
|
+
expect(logger).to receive(:warn).never
|
200
|
+
# this will produce a log line in stdout by the Java Event
|
201
|
+
LogStash::Event.new(TIMESTAMP => "ignore this log")
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
it "should warn on parsing error" do
|
206
|
+
LogStash::Event.logger = logger
|
207
|
+
expect(logger).to receive(:warn).once.with(/^Error parsing/)
|
208
|
+
LogStash::Event.new(TIMESTAMP => "invalid timestamp")
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should warn on invalid timestamp object" do
|
212
|
+
LogStash::Event.logger = logger
|
213
|
+
expect(logger).to receive(:warn).once.with(/^Unrecognized/)
|
214
|
+
LogStash::Event.new(TIMESTAMP => Array.new)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context "to_hash" do
|
219
|
+
let (:source_hash) { {"a" => 1, "b" => [1, 2, 3, {"h" => 1, "i" => "baz"}], "c" => {"d" => "foo", "e" => "bar", "f" => [4, 5, "six"]}} }
|
220
|
+
let (:source_hash_with_matada) { source_hash.merge({"@metadata" => {"a" => 1, "b" => 2}}) }
|
221
|
+
subject { LogStash::Event.new(source_hash_with_matada) }
|
222
|
+
|
223
|
+
it "should include @timestamp and @version" do
|
224
|
+
h = subject.to_hash
|
225
|
+
expect(h).to include("@timestamp")
|
226
|
+
expect(h).to include("@version")
|
227
|
+
expect(h).not_to include("@metadata")
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should include @timestamp and @version and @metadata" do
|
231
|
+
h = subject.to_hash_with_metadata
|
232
|
+
expect(h).to include("@timestamp")
|
233
|
+
expect(h).to include("@version")
|
234
|
+
expect(h).to include("@metadata")
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should produce valid deep Ruby hash without metadata" do
|
238
|
+
h = subject.to_hash
|
239
|
+
h.delete("@timestamp")
|
240
|
+
h.delete("@version")
|
241
|
+
expect(h).to eq(source_hash)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should produce valid deep Ruby hash with metadata" do
|
245
|
+
h = subject.to_hash_with_metadata
|
246
|
+
h.delete("@timestamp")
|
247
|
+
h.delete("@version")
|
248
|
+
expect(h).to eq(source_hash_with_matada)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context "from_json" do
|
253
|
+
let (:source_json) { "{\"foo\":1, \"bar\":\"baz\"}" }
|
254
|
+
let (:blank_strings) {["", " ", " "]}
|
255
|
+
let (:bare_strings) {["aa", " aa", "aa "]}
|
256
|
+
|
257
|
+
it "should produce a new event from json" do
|
258
|
+
expect(LogStash::Event.from_json(source_json).size).to eq(1)
|
259
|
+
|
260
|
+
event = LogStash::Event.from_json(source_json)[0]
|
261
|
+
expect(event["[foo]"]).to eq(1)
|
262
|
+
expect(event["[bar]"]).to eq("baz")
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should ignore blank strings" do
|
266
|
+
blank_strings.each do |s|
|
267
|
+
expect(LogStash::Event.from_json(s).size).to eq(0)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should raise TypeError on nil string" do
|
272
|
+
expect{LogStash::Event.from_json(nil)}.to raise_error TypeError
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should consistently handle nil" do
|
276
|
+
blank_strings.each do |s|
|
277
|
+
expect{LogStash::Event.from_json(nil)}.to raise_error
|
278
|
+
expect{LogStash::Event.new(LogStash::Json.load(nil))}.to raise_error
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should consistently handle bare string" do
|
283
|
+
bare_strings.each do |s|
|
284
|
+
expect{LogStash::Event.from_json(s)}.to raise_error LogStash::Json::ParserError
|
285
|
+
expect{LogStash::Event.new(LogStash::Json.load(s))}.to raise_error LogStash::Json::ParserError
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "logstash/timestamp"
|
5
|
+
|
6
|
+
describe LogStash::Timestamp do
|
7
|
+
context "constructors" do
|
8
|
+
it "should work" do
|
9
|
+
t = LogStash::Timestamp.new
|
10
|
+
expect(t.time.to_i).to be_within(1).of Time.now.to_i
|
11
|
+
|
12
|
+
t = LogStash::Timestamp.now
|
13
|
+
expect(t.time.to_i).to be_within(1).of Time.now.to_i
|
14
|
+
|
15
|
+
now = Time.now.utc
|
16
|
+
t = LogStash::Timestamp.new(now)
|
17
|
+
expect(t.time).to eq(now)
|
18
|
+
|
19
|
+
t = LogStash::Timestamp.at(now.to_i)
|
20
|
+
expect(t.time.to_i).to eq(now.to_i)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise exception on invalid format" do
|
24
|
+
expect{LogStash::Timestamp.new("foobar")}.to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-core-event-java
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Elastic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-29 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: '0'
|
19
|
+
name: jar-dependencies
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.3.9
|
33
|
+
name: ruby-maven
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.3.9
|
41
|
+
description: The core event component of logstash, the scalable log and event management tool
|
42
|
+
email:
|
43
|
+
- info@elastic.co
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar
|
49
|
+
- lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar
|
50
|
+
- lib/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar
|
51
|
+
- lib/logstash-core-event-java.rb
|
52
|
+
- lib/logstash-core-event-java/logstash-core-event-java.jar
|
53
|
+
- lib/logstash-core-event-java/logstash-core-event-java.rb
|
54
|
+
- lib/logstash-core-event-java/version.rb
|
55
|
+
- lib/logstash-core-event-java_jars.rb
|
56
|
+
- lib/logstash-core-event.rb
|
57
|
+
- lib/logstash/event.rb
|
58
|
+
- lib/logstash/string_interpolation.rb
|
59
|
+
- lib/logstash/timestamp.rb
|
60
|
+
- lib/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar
|
61
|
+
- lib/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar
|
62
|
+
- logstash-core-event-java.gemspec
|
63
|
+
- spec/event_spec.rb
|
64
|
+
- spec/timestamp_spec.rb
|
65
|
+
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
66
|
+
licenses:
|
67
|
+
- Apache License (2.0)
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements:
|
84
|
+
- jar com.fasterxml.jackson.core:jackson-core, 2.7.1
|
85
|
+
- jar com.fasterxml.jackson.core:jackson-databind, 2.7.1-1
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.8
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: logstash-core-event-java - The core event component of logstash
|
91
|
+
test_files:
|
92
|
+
- spec/event_spec.rb
|
93
|
+
- spec/timestamp_spec.rb
|