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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b56a245878d9ddd1ab1c5ea39e5a92cd6b08839c
4
- data.tar.gz: 820135576c4bcbf0947a65d1b69336f6d6da220f
3
+ metadata.gz: 81e9e7db22e4262df86b7e9fd832ba8cb9b82a5f
4
+ data.tar.gz: 6e7c3210287f264f86a5ee28d8e6a10b5714f41d
5
5
  SHA512:
6
- metadata.gz: 6c5ac02ed48995a8ebcdb8127f1ad05347da22fb2916beeec99bb08dfae6d7eb0f5b73d625c56a4f111dc5c43ab74ca7f950719bbef8c2963f50c19d68cf6fee
7
- data.tar.gz: a12c3a6695962295b8cd3f534473caba908e4fa27f3a062996995d35684bfb1d275838155e316c75a82596b66dfa653ea1efb8f192d2ea6becc55fac2df70cba
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
- You can also use Fluentd v0.12 style:
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
- You can also use Fluentd v0.12 style:
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
- You can also use Fluentd v0.12 style:
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
- You can also use Fluentd v0.12 style:
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#ldquomdashgemfilerdquo-option)
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.2"
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}
@@ -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)
@@ -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
 
@@ -95,6 +95,12 @@ TEXT
95
95
  end
96
96
  end
97
97
 
98
+ def test_no_grok_patterns
99
+ assert_raise Fluent::ConfigError do
100
+ create_driver('')
101
+ end
102
+ end
103
+
98
104
  private
99
105
 
100
106
  def create_driver(conf)
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.2
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-02-09 00:00:00.000000000 Z
12
+ date: 2017-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler