logstash-codec-fluent 3.0.2-java → 3.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/codecs/fluent.rb +56 -11
- data/logstash-codec-fluent.gemspec +2 -2
- data/spec/codecs/fluent_spec.rb +54 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c9c31b9f410df8d1944039aa31ea73374aa0a82
|
4
|
+
data.tar.gz: 429c22a14929f5aa6d370fe7b4047435af915e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9486c210461b70b5aea183e803f8574b3e4f42279dda27a02577a6f6de65eb4b4973a765a936f8af7ee14c88514aa7b06cbe2371986b22152151de2857186190
|
7
|
+
data.tar.gz: df6c52150440881313b96a28bccd70fc87a9f618770dd61122dccf1509d617f0432acd0c55e0db63aae8977fade0aeb87f5ec6142ba521b682348cf654ffbf0c
|
@@ -28,25 +28,17 @@ require "logstash/util"
|
|
28
28
|
class LogStash::Codecs::Fluent < LogStash::Codecs::Base
|
29
29
|
config_name "fluent"
|
30
30
|
|
31
|
-
public
|
32
31
|
def register
|
33
32
|
require "msgpack"
|
34
33
|
@decoder = MessagePack::Unpacker.new
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@decoder.each do |tag, epochtime, map|
|
41
|
-
event = LogStash::Event.new(map.merge(
|
42
|
-
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
|
43
|
-
"tags" => tag
|
44
|
-
))
|
45
|
-
yield event
|
36
|
+
def decode(data, &block)
|
37
|
+
@decoder.feed_each(data) do |item|
|
38
|
+
decode_event(item, &block)
|
46
39
|
end
|
47
40
|
end # def decode
|
48
41
|
|
49
|
-
public
|
50
42
|
def encode(event)
|
51
43
|
tag = event.get("tags") || "log"
|
52
44
|
epochtime = event.timestamp.to_i
|
@@ -59,4 +51,57 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
|
|
59
51
|
@on_event.call(event, MessagePack.pack([tag, epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)]))
|
60
52
|
end # def encode
|
61
53
|
|
54
|
+
private
|
55
|
+
|
56
|
+
def decode_event(data, &block)
|
57
|
+
tag = data[0]
|
58
|
+
entries = data[1]
|
59
|
+
|
60
|
+
case entries
|
61
|
+
when String
|
62
|
+
# PackedForward
|
63
|
+
option = data[2]
|
64
|
+
compressed = (option && option['compressed'] == 'gzip')
|
65
|
+
if compressed
|
66
|
+
raise(LogStash::Error, "PackedForward with compression is not supported")
|
67
|
+
end
|
68
|
+
|
69
|
+
entries_decoder = MessagePack::Unpacker.new
|
70
|
+
entries_decoder.feed_each(entries) do |entry|
|
71
|
+
epochtime = entry[0]
|
72
|
+
map = entry[1]
|
73
|
+
event = LogStash::Event.new(map.merge(
|
74
|
+
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
|
75
|
+
"tags" => [ tag ]
|
76
|
+
))
|
77
|
+
yield event
|
78
|
+
end
|
79
|
+
when Array
|
80
|
+
# Forward
|
81
|
+
entries.each do |entry|
|
82
|
+
epochtime = entry[0]
|
83
|
+
map = entry[1]
|
84
|
+
event = LogStash::Event.new(map.merge(
|
85
|
+
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
|
86
|
+
"tags" => [ tag ]
|
87
|
+
))
|
88
|
+
yield event
|
89
|
+
end
|
90
|
+
when Fixnum
|
91
|
+
# Message
|
92
|
+
epochtime = entries
|
93
|
+
map = data[2]
|
94
|
+
event = LogStash::Event.new(map.merge(
|
95
|
+
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
|
96
|
+
"tags" => [ tag ]
|
97
|
+
))
|
98
|
+
yield event
|
99
|
+
else
|
100
|
+
raise(LogStash::Error, "Unknown event type")
|
101
|
+
end
|
102
|
+
rescue StandardError => e
|
103
|
+
@logger.error("Fluent parse error, original data now in message field", :error => e, :data => data)
|
104
|
+
yield LogStash::Event.new("message" => data, "tags" => [ "_fluentparsefailure" ])
|
105
|
+
end
|
106
|
+
|
62
107
|
end # class LogStash::Codecs::Fluent
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-codec-fluent'
|
4
|
-
s.version = '3.
|
4
|
+
s.version = '3.1.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This codec handles fluentd's msgpack schema."
|
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"
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_runtime_dependency 'msgpack'
|
30
30
|
end
|
31
31
|
|
32
|
-
s.add_development_dependency 'logstash-devutils'
|
32
|
+
s.add_development_dependency 'logstash-devutils', ">= 1.0.0"
|
33
33
|
end
|
34
34
|
|
data/spec/codecs/fluent_spec.rb
CHANGED
@@ -37,7 +37,60 @@ describe LogStash::Codecs::Fluent do
|
|
37
37
|
|
38
38
|
it "should decode without errors" do
|
39
39
|
subject.decode(message) do |event|
|
40
|
-
|
40
|
+
expect(event.get("name")).to eq("foo")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "event decoding (buckets of events)" do
|
47
|
+
|
48
|
+
let(:tag) { "mytag" }
|
49
|
+
let(:epochtime) { event.timestamp.to_i }
|
50
|
+
let(:data) { LogStash::Util.normalize(event.to_hash) }
|
51
|
+
let(:message) do
|
52
|
+
MessagePack.pack([tag,
|
53
|
+
[
|
54
|
+
[epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)],
|
55
|
+
[epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)],
|
56
|
+
[epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)]
|
57
|
+
]
|
58
|
+
])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should decode without errors" do
|
62
|
+
count = 0
|
63
|
+
|
64
|
+
subject.decode(message) do |event|
|
65
|
+
expect(event.get("name")).to eq("foo")
|
66
|
+
count += 1
|
67
|
+
end
|
68
|
+
|
69
|
+
expect(count).to eq(3)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "event decoding (broken package)" do
|
75
|
+
|
76
|
+
let(:tag) { "mytag" }
|
77
|
+
let(:epochtime) { event.timestamp.to_s }
|
78
|
+
let(:data) { LogStash::Util.normalize(event.to_hash) }
|
79
|
+
let(:message) do
|
80
|
+
MessagePack.pack([tag,
|
81
|
+
epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)
|
82
|
+
])
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should decode with errors" do
|
86
|
+
subject.decode(message) do |event|
|
87
|
+
expect(event.get("name")).not_to eq("foo")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should inject a failure event" do
|
92
|
+
subject.decode(message) do |event|
|
93
|
+
expect(event.get("tags")).to include("_fluentparsefailure")
|
41
94
|
end
|
42
95
|
end
|
43
96
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-codec-fluent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 1.0.0
|
53
53
|
name: logstash-devutils
|
54
54
|
prerelease: false
|
55
55
|
type: :development
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 1.0.0
|
61
61
|
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
|
62
62
|
email: info@elastic.co
|
63
63
|
executables: []
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.8
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: This codec handles fluentd's msgpack schema.
|