logstash-input-beats 0.9.3 → 0.9.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 +2 -0
- data/lib/logstash/inputs/beats.rb +8 -7
- data/logstash-input-beats.gemspec +1 -1
- data/spec/inputs/beats_spec.rb +38 -11
- 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: b1047898fca8c088bad07177c83065b172ffa397
|
4
|
+
data.tar.gz: 30c529c2f394241878c37b9228c3bf099e963ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f5fec20da96051d40ba23240b459ad3f3d50440ce1f3713fdfd91af281e1c96d2fee096349c66b13570a5c43312f74b73edc01b1d75b04383c9c0b39c76bec
|
7
|
+
data.tar.gz: 1bc58dfa1626cd59b7c1c76ed25d22c7b6ee1e9268ac91e3875ca052825f4aec08769d13ce2e09f83a95d2307fcb6a97261819caf2ef255b3d0ec95c41dd8cfe
|
data/CHANGELOG.md
CHANGED
@@ -125,21 +125,22 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
|
|
125
125
|
@lumberjack.close
|
126
126
|
end
|
127
127
|
|
128
|
-
|
128
|
+
public
|
129
129
|
def create_event(codec, map)
|
130
130
|
# Filebeats uses the `message` key and LSF `line`
|
131
131
|
target_field = target_field_for_codec ? map.delete(target_field_for_codec) : nil
|
132
132
|
|
133
133
|
if target_field.nil?
|
134
|
-
|
134
|
+
event = LogStash::Event.new(map)
|
135
|
+
decorate(event)
|
136
|
+
return event
|
135
137
|
else
|
136
|
-
|
137
|
-
# All codes expects to work on string
|
138
|
+
# All codecs expects to work on string
|
138
139
|
@codec.decode(target_field.to_s) do |decoded|
|
139
|
-
decorate(decoded)
|
140
140
|
ts = coerce_ts(map.delete("@timestamp"))
|
141
141
|
decoded["@timestamp"] = ts unless ts.nil?
|
142
142
|
map.each { |k, v| decoded[k] = v }
|
143
|
+
decorate(decoded)
|
143
144
|
return decoded
|
144
145
|
end
|
145
146
|
end
|
@@ -151,10 +152,10 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
|
|
151
152
|
timestamp = LogStash::Timestamp.coerce(ts)
|
152
153
|
return timestamp if timestamp
|
153
154
|
|
154
|
-
|
155
|
+
@logger.warn("Unrecognized @timestamp value, setting current time to @timestamp",
|
155
156
|
:value => ts.inspect)
|
156
157
|
rescue LogStash::TimestampParserError => e
|
157
|
-
|
158
|
+
@logger.warn("Error parsing @timestamp string, setting current time to @timestamp",
|
158
159
|
:value => ts.inspect, :exception => e.message)
|
159
160
|
end
|
160
161
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "logstash-input-beats"
|
3
|
-
s.version = "0.9.
|
3
|
+
s.version = "0.9.4"
|
4
4
|
s.licenses = ["Apache License (2.0)"]
|
5
5
|
s.summary = "Receive events using the lumberjack protocol."
|
6
6
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
data/spec/inputs/beats_spec.rb
CHANGED
@@ -72,28 +72,55 @@ describe LogStash::Inputs::Beats do
|
|
72
72
|
|
73
73
|
describe "#processing of events" do
|
74
74
|
subject(:beats) { LogStash::Inputs::Beats.new(config) }
|
75
|
+
let(:codec) { LogStash::Codecs::Multiline.new("pattern" => '\n', "what" => "previous") }
|
75
76
|
|
76
|
-
let(:
|
77
|
-
|
78
|
-
|
79
|
-
allow(connection).to receive(:run).and_yield(lines)
|
80
|
-
beats.register
|
81
|
-
expect_any_instance_of(Lumberjack::Beats::Server).to receive(:accept).and_return(connection)
|
77
|
+
let(:config) do
|
78
|
+
{ "port" => port, "ssl_certificate" => certificate.ssl_cert, "ssl_key" => certificate.ssl_key,
|
79
|
+
"type" => "example", "codec" => codec }
|
82
80
|
end
|
83
81
|
|
82
|
+
|
84
83
|
context "#codecs" do
|
85
|
-
let(:
|
86
|
-
{ "port" => port, "ssl_certificate" => certificate.ssl_cert, "ssl_key" => certificate.ssl_key,
|
87
|
-
"type" => "example", "codec" => codec }
|
88
|
-
end
|
84
|
+
let(:lines) { {"line" => "one\ntwo\n two.2\nthree\n", "tags" => ["syslog"]} }
|
89
85
|
|
90
|
-
|
86
|
+
before do
|
87
|
+
allow(connection).to receive(:run).and_yield(lines)
|
88
|
+
beats.register
|
89
|
+
expect_any_instance_of(Lumberjack::Beats::Server).to receive(:accept).and_return(connection)
|
90
|
+
end
|
91
|
+
|
91
92
|
it "clone the codec per connection" do
|
92
93
|
expect(beats.codec).to receive(:clone).once
|
93
94
|
expect(beats).to receive(:invoke) { break }
|
94
95
|
beats.run(queue)
|
95
96
|
end
|
96
97
|
end
|
98
|
+
|
99
|
+
context "#create_event" do
|
100
|
+
let(:config) { super.merge({ "add_field" => { "foo" => "bar", "[@metadata][hidden]" => "secret"}, "tags" => ["bonjour"]}) }
|
101
|
+
let(:event_map) { { "hello" => "world" } }
|
102
|
+
let(:codec) { LogStash::Codecs::Plain.new }
|
103
|
+
|
104
|
+
context "without a `target_field` defined" do
|
105
|
+
it "decorates the event" do
|
106
|
+
event = beats.create_event(codec, event_map)
|
107
|
+
expect(event["foo"]).to eq("bar")
|
108
|
+
expect(event["[@metadata][hidden]"]).to eq("secret")
|
109
|
+
expect(event["tags"]).to include("bonjour")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with a `target_field` defined" do
|
114
|
+
let(:event_map) { super.merge({"message" => "with a field"}) }
|
115
|
+
|
116
|
+
it "decorates the event" do
|
117
|
+
event = beats.create_event(beats.codec, event_map)
|
118
|
+
expect(event["foo"]).to eq("bar")
|
119
|
+
expect(event["[@metadata][hidden]"]).to eq("secret")
|
120
|
+
expect(event["tags"]).to include("bonjour")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
97
124
|
end
|
98
125
|
|
99
126
|
unless LogStash::CompatibilityLayerApiV1.is_v1?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-beats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|