fluent-plugin-parser 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fluent-plugin-parser.gemspec +2 -1
- data/lib/fluent/plugin/out_parser.rb +26 -9
- data/test/custom_parser.rb +4 -4
- data/test/plugin/test_out_parser.rb +1 -1
- data/test/plugin/test_out_parser_for_parsers.rb +4 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a7890c46c538f109454bf0442db0dcd2a4f75b0
|
4
|
+
data.tar.gz: f50a1814587e4702f3ae47eef54f6a4208ecd4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37956f2b75dc8aed2f471ea321afbea843f97ca568a09e3cf169bb159f38c8d481e431c30141611cb909d8a7dfb712856aec4fd24d5937edb9610c1576fc85af
|
7
|
+
data.tar.gz: 5e8af5d4544c7cd879345c06a10d28210974f2de34cd1a75ad1e63232739269b32e6e0eedd5ffc13ee740ec2fadd10fefe385bdfa1186b76be266f0399027b59
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-parser"
|
4
|
-
gem.version = "0.4.
|
4
|
+
gem.version = "0.4.1"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.description = %q{fluentd plugin to parse single field, or to combine log structure into single field}
|
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
|
17
|
+
gem.add_development_dependency "test-unit"
|
17
18
|
gem.add_development_dependency "rake"
|
18
19
|
gem.add_runtime_dependency "fluentd", ">= 0.10.54"
|
19
20
|
end
|
@@ -21,6 +21,11 @@ class Fluent::ParserOutput < Fluent::Output
|
|
21
21
|
require 'time'
|
22
22
|
end
|
23
23
|
|
24
|
+
# Define `log` method for v0.10.42 or earlier
|
25
|
+
unless method_defined?(:log)
|
26
|
+
define_method("log") { $log }
|
27
|
+
end
|
28
|
+
|
24
29
|
def configure(conf)
|
25
30
|
super
|
26
31
|
|
@@ -70,8 +75,16 @@ class Fluent::ParserOutput < Fluent::Output
|
|
70
75
|
raw_value = record[@key_name]
|
71
76
|
begin
|
72
77
|
@parser.parse(raw_value) do |t,values|
|
73
|
-
|
74
|
-
|
78
|
+
if values
|
79
|
+
t ||= time
|
80
|
+
handle_parsed(tag, record, t, values)
|
81
|
+
else
|
82
|
+
log.warn "pattern not match with data '#{raw_value}'" unless @suppress_parse_error_log
|
83
|
+
if @reserve_data
|
84
|
+
t = time
|
85
|
+
handle_parsed(tag, record, time, {})
|
86
|
+
end
|
87
|
+
end
|
75
88
|
end
|
76
89
|
rescue Fluent::TextParser::ParserError => e
|
77
90
|
log.warn e.message unless @suppress_parse_error_log
|
@@ -82,8 +95,16 @@ class Fluent::ParserOutput < Fluent::Output
|
|
82
95
|
end
|
83
96
|
replaced_string = replace_invalid_byte(raw_value)
|
84
97
|
@parser.parse(replaced_string) do |t,values|
|
85
|
-
|
86
|
-
|
98
|
+
if values
|
99
|
+
t ||= time
|
100
|
+
handle_parsed(tag, record, t, values)
|
101
|
+
else
|
102
|
+
log.warn "pattern not match with data '#{raw_value}'" unless @suppress_parse_error_log
|
103
|
+
if @reserve_data
|
104
|
+
t = time
|
105
|
+
handle_parsed(tag, record, time, {})
|
106
|
+
end
|
107
|
+
end
|
87
108
|
end
|
88
109
|
else
|
89
110
|
raise
|
@@ -106,11 +127,7 @@ class Fluent::ParserOutput < Fluent::Output
|
|
106
127
|
if @reserve_data
|
107
128
|
r = r ? record.merge(r) : record
|
108
129
|
end
|
109
|
-
|
110
|
-
Fluent::Engine.emit(tag, t, r)
|
111
|
-
else
|
112
|
-
log.warn "pattern not match #{raw_value}" unless @suppress_parse_error_log
|
113
|
-
end
|
130
|
+
Fluent::Engine.emit(tag, t, r)
|
114
131
|
end
|
115
132
|
|
116
133
|
def replace_invalid_byte(string)
|
data/test/custom_parser.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Fluent
|
2
2
|
class TextParser
|
3
|
-
class KVPairParser
|
3
|
+
class KVPairParser < Parser
|
4
|
+
Plugin.register_parser('kv_pair', self)
|
5
|
+
|
4
6
|
# key<delim1>value is pair and <pair><delim2><pair> ...
|
5
7
|
# newline splits records
|
6
8
|
include Configurable
|
@@ -16,7 +18,7 @@ module Fluent
|
|
16
18
|
@time_parser = TimeParser.new(@time_format)
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
21
|
+
def parse(text)
|
20
22
|
text.split("\n").each do |line|
|
21
23
|
pairs = text.split(@delim2)
|
22
24
|
record = {}
|
@@ -33,7 +35,5 @@ module Fluent
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
36
|
-
|
37
|
-
register_template("kv_pair", Proc.new { KVPairParser.new })
|
38
38
|
end
|
39
39
|
end
|
@@ -196,7 +196,7 @@ class ParserOutputTest < Test::Unit::TestCase
|
|
196
196
|
d3x = create_driver(%[
|
197
197
|
tag parsed
|
198
198
|
key_name data
|
199
|
-
format /^(?<x
|
199
|
+
format /^(?<x>\\d)(?<y>\\d) (?<t>.+)$/
|
200
200
|
reserve_data yes
|
201
201
|
], 'test.in')
|
202
202
|
time = Time.parse("2012-04-02 18:20:59").to_i
|
@@ -153,7 +153,7 @@ add_prefix parsed
|
|
153
153
|
key_name message
|
154
154
|
format syslog
|
155
155
|
EOF
|
156
|
-
time = Time.parse("
|
156
|
+
time = Time.parse("11/05 15:59:30").to_i # time is assumed as current year
|
157
157
|
d.run do
|
158
158
|
d.emit({"message" => logs[0]}, time)
|
159
159
|
d.emit({"message" => logs[1]}, time)
|
@@ -165,7 +165,7 @@ EOF
|
|
165
165
|
|
166
166
|
e = emits[0]
|
167
167
|
assert_equal 'parsed.in', e[0]
|
168
|
-
assert_equal Time.parse("
|
168
|
+
assert_equal Time.parse("11/05 16:19:48").to_i, e[1]
|
169
169
|
r = e[2]
|
170
170
|
assert_equal 'myhost.local', r['host']
|
171
171
|
assert_equal 'netbiosd', r['ident']
|
@@ -174,7 +174,7 @@ EOF
|
|
174
174
|
|
175
175
|
e = emits[1]
|
176
176
|
assert_equal 'parsed.in', e[0]
|
177
|
-
assert_equal Time.parse("
|
177
|
+
assert_equal Time.parse("11/05 16:21:20").to_i, e[1]
|
178
178
|
r = e[2]
|
179
179
|
assert_equal 'myhost.local', r['host']
|
180
180
|
assert_equal 'coreaudiod', r['ident']
|
@@ -183,7 +183,7 @@ EOF
|
|
183
183
|
|
184
184
|
e = emits[2]
|
185
185
|
assert_equal 'parsed.in', e[0]
|
186
|
-
assert_equal Time.parse("
|
186
|
+
assert_equal Time.parse("11/05 16:21:20").to_i, e[1]
|
187
187
|
r = e[2]
|
188
188
|
assert_equal 'myhost.local', r['host']
|
189
189
|
assert_equal 'coreaudiod', r['ident']
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
94
|
version: '0'
|
81
95
|
requirements: []
|
82
96
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.5
|
84
98
|
signing_key:
|
85
99
|
specification_version: 4
|
86
100
|
summary: plugin to parse/combine fluentd log messages
|