fluent-plugin-grok-parser 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/fluent-plugin-grok-parser.gemspec +1 -1
- data/lib/fluent/plugin/grok.rb +5 -0
- data/test/test_grok_parser.rb +37 -0
- data/test/test_grok_parser_in_tcp.rb +6 -0
- data/test/test_multiline_grok_parser.rb +6 -0
- 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: 81e9e7db22e4262df86b7e9fd832ba8cb9b82a5f
|
4
|
+
data.tar.gz: 6e7c3210287f264f86a5ee28d8e6a10b5714f41d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5523e5b7fedd8e9a1f7d07223c5b6e7a546d71fbe502132a86ca2cfb01067a63a8e8e21d7e3a16d9a08d21227c04d4a4fb2d0502ce0189fe6e49556cce63124
|
7
|
+
data.tar.gz: 0af251adce899635f0479411af832e3e125bdced10434d09e841b94d20b552cce2603a8106086711aa71d1aa962ff3d98cb97f5732a9600b3260054672102151
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ extracts the first IP address that matches in the log.
|
|
33
33
|
</source>
|
34
34
|
```
|
35
35
|
|
36
|
-
|
36
|
+
For Fluentd v0.12, use following style:
|
37
37
|
|
38
38
|
```aconf
|
39
39
|
<source>
|
@@ -68,7 +68,7 @@ You can also use Fluentd v0.12 style:
|
|
68
68
|
</source>
|
69
69
|
```
|
70
70
|
|
71
|
-
|
71
|
+
For Fluentd v0.12, use following style:
|
72
72
|
|
73
73
|
```aconf
|
74
74
|
<source>
|
@@ -106,7 +106,7 @@ You can parse multiple line text.
|
|
106
106
|
</source>
|
107
107
|
```
|
108
108
|
|
109
|
-
|
109
|
+
For Fluentd v0.12, use following style:
|
110
110
|
|
111
111
|
```aconf
|
112
112
|
<source>
|
@@ -135,7 +135,7 @@ You can use multiple grok patterns to parse your data.
|
|
135
135
|
</source>
|
136
136
|
```
|
137
137
|
|
138
|
-
|
138
|
+
For Fluentd v0.12, use following style:
|
139
139
|
|
140
140
|
```aconf
|
141
141
|
<source>
|
@@ -312,7 +312,7 @@ Here is a sample config using the Grok parser with `in_tail` and the `types` par
|
|
312
312
|
|
313
313
|
If you want to use this plugin with Fluentd v0.12.x or earlier, you can use this plugin version v1.0.0.
|
314
314
|
|
315
|
-
See also: [Plugin Management | Fluentd](http://docs.fluentd.org/articles/plugin-management#
|
315
|
+
See also: [Plugin Management | Fluentd](http://docs.fluentd.org/articles/plugin-management#plugin-version-management)
|
316
316
|
|
317
317
|
## License
|
318
318
|
|
@@ -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 = "2.1.
|
7
|
+
spec.version = "2.1.3"
|
8
8
|
spec.authors = ["kiyoto", "Kenji Okimoto"]
|
9
9
|
spec.email = ["kiyoto@treasure-data.com", "okimoto@clear-code.com"]
|
10
10
|
spec.summary = %q{Fluentd plugin to support Logstash-inspired Grok format for parsing logs}
|
data/lib/fluent/plugin/grok.rb
CHANGED
@@ -51,6 +51,10 @@ module Fluent
|
|
51
51
|
@parsers << expand_pattern_expression(grok_conf["pattern"], grok_conf)
|
52
52
|
end
|
53
53
|
end
|
54
|
+
@parsers.compact!
|
55
|
+
if @parsers.empty?
|
56
|
+
raise Fluent::ConfigError, 'no grok patterns. Check configuration, e.g. typo, configuration syntax, etc'
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
private
|
@@ -70,6 +74,7 @@ module Fluent
|
|
70
74
|
raise e
|
71
75
|
rescue => e
|
72
76
|
$log.error(error: e)
|
77
|
+
nil
|
73
78
|
end
|
74
79
|
|
75
80
|
def expand_pattern(pattern)
|
data/test/test_grok_parser.rb
CHANGED
@@ -11,6 +11,10 @@ def str2time(str_time, format = nil)
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class GrokParserTest < ::Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
Fluent::Test.setup
|
16
|
+
end
|
17
|
+
|
14
18
|
class Timestamp < self
|
15
19
|
def test_timestamp_iso8601
|
16
20
|
internal_test_grok_pattern("%{TIMESTAMP_ISO8601:time}", "Some stuff at 2014-01-01T00:00:00+0900",
|
@@ -157,6 +161,39 @@ class GrokParserTest < ::Test::Unit::TestCase
|
|
157
161
|
end
|
158
162
|
end
|
159
163
|
|
164
|
+
def test_no_grok_patterns
|
165
|
+
assert_raise Fluent::ConfigError do
|
166
|
+
create_driver('')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_invalid_config_value_type
|
171
|
+
assert_raise Fluent::ConfigError do
|
172
|
+
create_driver(%[
|
173
|
+
<grok>
|
174
|
+
pattern %{PATH:path:foo}
|
175
|
+
</grok>
|
176
|
+
])
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_invalid_config_value_type_and_normal_grok_pattern
|
181
|
+
d = create_driver(%[
|
182
|
+
<grok>
|
183
|
+
pattern %{PATH:path:foo}
|
184
|
+
</grok>
|
185
|
+
<grok>
|
186
|
+
pattern %{IP:ip_address}
|
187
|
+
</grok>
|
188
|
+
])
|
189
|
+
assert_equal(1, d.instance.instance_variable_get(:@grok).parsers.size)
|
190
|
+
logs = $log.instance_variable_get(:@logger).instance_variable_get(:@logdev).logs
|
191
|
+
error_logs = logs.grep(/error_class/)
|
192
|
+
assert_equal(1, error_logs.size)
|
193
|
+
error_message = error_logs.first[/error="(.+)"/, 1]
|
194
|
+
assert_equal("unknown value conversion for key:'path', type:'foo'", error_message)
|
195
|
+
end
|
196
|
+
|
160
197
|
private
|
161
198
|
|
162
199
|
def create_driver(conf)
|
@@ -29,12 +29,18 @@ class TcpInputWithGrokTest < Test::Unit::TestCase
|
|
29
29
|
bind 127.0.0.1
|
30
30
|
<parse>
|
31
31
|
@type grok
|
32
|
+
<grok>
|
33
|
+
pattern %{GREEDYDATA:message}
|
34
|
+
</grok>
|
32
35
|
</parse>
|
33
36
|
]
|
34
37
|
IPv6_CONFIG = BASE_CONFIG + %[
|
35
38
|
bind ::1
|
36
39
|
<parse>
|
37
40
|
@type grok
|
41
|
+
<grok>
|
42
|
+
pattern %{GREEDYDATA:message}
|
43
|
+
</grok>
|
38
44
|
</parse>
|
39
45
|
]
|
40
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-grok-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kiyoto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|