fluent-plugin-grok-parser 0.0.3 → 0.0.4
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/README.md +2 -2
- data/fluent-plugin-grok-parser.gemspec +1 -1
- data/lib/fluent/plugin/grok.rb +2 -1
- data/lib/fluent/plugin/parser_multiline_grok.rb +1 -1
- data/test/test_grok_parser.rb +1 -2
- data/test/test_multiline_grok_parser.rb +17 -9
- 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: 3677fbf9646ab3f74f7e182c89d65bb8e12c7912
|
4
|
+
data.tar.gz: b922f2cc49ad69e8c39f9c9b3948ad174a327f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5154e8e2ee992db507da6fc4a6dde6aa57882a6bc12e228900793921d8234d1b266c572d5897a5c13fe84b187b6cb044cafffff4c74e10b8dc6836b947db6c68
|
7
|
+
data.tar.gz: 34a14a13f62a00e3c6c148e9668e1a58ac77e0fce1a79f48ef94f8d7d3eb85ee95a581d130d5cdfd9790b4e14b30fe1d3efada3bd6db0f0432b03a4fce86f7bb
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ You can parse multiple line text.
|
|
54
54
|
path /path/to/log
|
55
55
|
format multiline_grok
|
56
56
|
grok_pattern %{IP:ip_address}\n%{GREEDYDATA:message}
|
57
|
-
|
57
|
+
multiline_start_regexp /^\s/
|
58
58
|
tag grokked_log
|
59
59
|
</source>
|
60
60
|
```
|
@@ -75,7 +75,7 @@ You can use multiple grok patterns to parse your data.
|
|
75
75
|
|
76
76
|
Fluentd accumulates data in the buffer forever to parse complete data when no pattern matches.
|
77
77
|
|
78
|
-
You can use this parser without `
|
78
|
+
You can use this parser without `multiline_start_regexp` when you know your data structure perfectly.
|
79
79
|
|
80
80
|
|
81
81
|
## How to write Grok patterns
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-grok-parser"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.4"
|
8
8
|
spec.authors = ["kiyoto"]
|
9
9
|
spec.email = ["kiyoto@treasure-data.com"]
|
10
10
|
spec.summary = %q{Fluentd plugin to support Logstash-inspired Grok format for parsing logs}
|
data/lib/fluent/plugin/grok.rb
CHANGED
@@ -14,13 +14,14 @@ module Fluent
|
|
14
14
|
\}/x
|
15
15
|
|
16
16
|
attr_reader :parsers
|
17
|
+
attr_reader :multiline_start_regexp
|
17
18
|
|
18
19
|
def initialize(plugin, conf)
|
19
20
|
@pattern_map = {}
|
20
21
|
@parsers = []
|
21
22
|
@multiline_mode = false
|
22
23
|
@conf = conf
|
23
|
-
if plugin.
|
24
|
+
if plugin.respond_to?(:firstline?)
|
24
25
|
@multiline_mode = true
|
25
26
|
end
|
26
27
|
if @conf['multiline_start_regexp']
|
data/test/test_grok_parser.rb
CHANGED
@@ -73,8 +73,7 @@ class GrokParserTest < ::Test::Unit::TestCase
|
|
73
73
|
private
|
74
74
|
|
75
75
|
def internal_test_grok_pattern(grok_pattern, text, expected_time, expected_record, options = {})
|
76
|
-
parser = TextParser::GrokParser.
|
77
|
-
parser.configure(Config::Element.new('ROOT', '', {"grok_pattern" => grok_pattern}.merge(options), []))
|
76
|
+
parser = Fluent::Test::ParserTestDriver.new(TextParser::GrokParser).configure({"grok_pattern" => grok_pattern}.merge(options))
|
78
77
|
|
79
78
|
# for the old, return based API
|
80
79
|
time, record = parser.parse(text)
|
@@ -19,9 +19,9 @@ MESSAGE
|
|
19
19
|
grok_pattern %{HOSTNAME:hostname} %{GREEDYDATA:message}
|
20
20
|
multiline_start_regexp /^\s/
|
21
21
|
]
|
22
|
-
|
22
|
+
d = create_driver(conf)
|
23
23
|
|
24
|
-
|
24
|
+
d.parse(text) do |time, record|
|
25
25
|
assert_equal({ "hostname" => "host1", "message" => message }, record)
|
26
26
|
end
|
27
27
|
end
|
@@ -36,7 +36,7 @@ TEXT
|
|
36
36
|
conf = %[
|
37
37
|
grok_pattern %{HOSTNAME:hostname} %{DATA:message1}\\n %{DATA:message2}\\n %{DATA:message3}\\nend
|
38
38
|
]
|
39
|
-
|
39
|
+
d = create_driver(conf)
|
40
40
|
|
41
41
|
expected = {
|
42
42
|
"hostname" => "host1",
|
@@ -44,17 +44,25 @@ TEXT
|
|
44
44
|
"message2" => "message2",
|
45
45
|
"message3" => "message3"
|
46
46
|
}
|
47
|
-
|
47
|
+
d.parse(text) do |time, record|
|
48
48
|
assert_equal(expected, record)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_empty_range_text_in_text
|
53
|
+
text = " [b-a]"
|
54
|
+
conf = %[
|
55
|
+
grok_pattern %{HOSTNAME:hostname} %{GREEDYDATA:message}
|
56
|
+
multiline_start_regexp /^\s/
|
57
|
+
]
|
58
|
+
d = create_driver(conf)
|
59
|
+
|
60
|
+
assert(d.instance.firstline?(text))
|
61
|
+
end
|
62
|
+
|
52
63
|
private
|
53
64
|
|
54
|
-
def
|
55
|
-
|
56
|
-
io = StringIO.new(conf)
|
57
|
-
parser.configure(Config::Parser.parse(io, "fluent.conf"))
|
58
|
-
parser
|
65
|
+
def create_driver(conf)
|
66
|
+
Fluent::Test::ParserTestDriver.new(TextParser::MultilineGrokParser).configure(conf)
|
59
67
|
end
|
60
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-grok-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kiyoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|