logstash-filter-grok 4.3.0 → 4.4.0

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
  SHA256:
3
- metadata.gz: a9d8be42f7b846a0684d25d18ec624a81574b52e394df863afa004d458ecd915
4
- data.tar.gz: 605d0cea73b747d9900bebfc2a99f59d2950300af7ef52ec5b9cb3f556a7d5fd
3
+ metadata.gz: 87eff1d28b6fd87d466b877482c6a81f7c831085fa412648e99b06b01f63bdb7
4
+ data.tar.gz: c97a71386c92e197718de56e99d7d93da9be6c9106b268d87f0fce7679aa320e
5
5
  SHA512:
6
- metadata.gz: '096791bcc8691300c8e59aa8c6741d499c515b6fc70b3f7e4deea0c23440bce1875d98d7aaad0d6f8d8ab12dc526051e46e2a61b590422d646d7939221ec3fc7'
7
- data.tar.gz: efe3dcc313d22e67986828351b365b9383c5c91d0a4caf8da78bd8c34126e7088d81ce9c672a6dc0758a9c3c4d1e4a2cae53e2df2c79bcd510848b69ecac9945
6
+ metadata.gz: 3542aeedd78021a4d27060a8cb28f2f4818d0b898f18ad1bc756f9fda7ca80bf07876bbff07d78d7390388c0cab6a6a939fdaea66d81d02f10a7f896c77fc461
7
+ data.tar.gz: 344c2f04142ae37a4cf1b5fafca6d3c592b80eac15829a5bd342c550b40b3204acaf2e0c3e8ffd2cf0a310a269c7caa8492c3ca4b1178cd0d505cbc9cb6c6c7a
data/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
+ ## 4.4.0
2
+ - Feat: ECS compatibility support [#162](https://github.com/logstash-plugins/logstash-filter-grok/pull/162)
3
+
4
+ The filter supports using (built-in) patterns definition that are fully Elactic Common Schema compliant.
5
+
1
6
  ## 4.3.0
2
- - Added: added target support [#156](https://github.com/logstash-plugins/logstash-filter-grok/pull/156)
7
+ - Added: added target support [#156](https://github.com/logstash-plugins/logstash-filter-grok/pull/156)
3
8
 
4
9
  ## 4.2.0
5
- - Added: support for timeout_scope [#153](https://github.com/logstash-plugins/logstash-filter-grok/pull/153)
10
+ - Added: support for timeout_scope [#153](https://github.com/logstash-plugins/logstash-filter-grok/pull/153)
6
11
 
7
12
  ## 4.1.1
8
13
  - Fix formatting for code sample [#148](https://github.com/logstash-plugins/logstash-filter-grok/pull/148)
data/LICENSE CHANGED
@@ -1,13 +1,202 @@
1
- Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
1
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- http://www.apache.org/licenses/LICENSE-2.0
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2020 Elastic and contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-grok.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-grok)
3
+ [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-filter-grok.svg)](https://travis-ci.com/logstash-plugins/logstash-filter-grok)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
data/docs/index.asciidoc CHANGED
@@ -175,6 +175,21 @@ Another option is to define patterns _inline_ in the filter using `pattern_defin
175
175
  This is mostly for convenience and allows user to define a pattern which can be used just in that
176
176
  filter. This newly defined patterns in `pattern_definitions` will not be available outside of that particular `grok` filter.
177
177
 
178
+ [id="plugins-{type}s-{plugin}-ecs"]
179
+ ==== Migrating to Elastic Common Schema (ECS)
180
+
181
+ To ease migration to the {ecs-ref}[Elastic Common Schema (ECS)], the filter
182
+ plugin offers a new set of ECS-compliant patterns in addition to the existing
183
+ patterns. The new ECS pattern definitions capture event field names that are
184
+ compliant with the schema.
185
+
186
+ The ECS pattern set has all of the pattern definitions from the legacy set, and is
187
+ a drop-in replacement. Use the <<plugins-{type}s-{plugin}-ecs_compatibility>>
188
+ setting to switch modes.
189
+
190
+ New features and enhancements will be added to the ECS-compliant files. The
191
+ legacy patterns may still receive bug fixes which are backwards compatible.
192
+
178
193
 
179
194
  [id="plugins-{type}s-{plugin}-options"]
180
195
  ==== Grok Filter Configuration Options
@@ -185,6 +200,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
185
200
  |=======================================================================
186
201
  |Setting |Input type|Required
187
202
  | <<plugins-{type}s-{plugin}-break_on_match>> |<<boolean,boolean>>|No
203
+ | <<plugins-{type}s-{plugin}-ecs_compatibility>> |<<string,string>>|No
188
204
  | <<plugins-{type}s-{plugin}-keep_empty_captures>> |<<boolean,boolean>>|No
189
205
  | <<plugins-{type}s-{plugin}-match>> |<<hash,hash>>|No
190
206
  | <<plugins-{type}s-{plugin}-named_captures_only>> |<<boolean,boolean>>|No
@@ -213,6 +229,20 @@ Break on first match. The first successful match by grok will result in the
213
229
  filter being finished. If you want grok to try all patterns (maybe you are
214
230
  parsing different things), then set this to false.
215
231
 
232
+ [id="plugins-{type}s-{plugin}-ecs_compatibility"]
233
+ ===== `ecs_compatibility`
234
+
235
+ * Value type is <<string,string>>
236
+ * Supported values are:
237
+ ** `disabled`: the plugin will load legacy (built-in) pattern definitions
238
+ ** `v1`: all patterns provided by the plugin will use ECS compliant captures
239
+ * Default value depends on which version of Logstash is running:
240
+ ** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
241
+ ** Otherwise, the default value is `disabled`.
242
+
243
+ Controls this plugin's compatibility with the {ecs-ref}[Elastic Common Schema (ECS)].
244
+ The value of this setting affects extracted event field names when a composite pattern (such as `HTTPD_COMMONLOG`) is matched.
245
+
216
246
  [id="plugins-{type}s-{plugin}-keep_empty_captures"]
217
247
  ===== `keep_empty_captures`
218
248
 
@@ -3,8 +3,8 @@
3
3
  require "logstash/namespace"
4
4
  require "logstash/environment"
5
5
  require "logstash/patterns/core"
6
+ require 'logstash/plugin_mixins/ecs_compatibility_support'
6
7
  require "grok-pure" # rubygem 'jls-grok'
7
- require "set"
8
8
  require "timeout"
9
9
 
10
10
  # Parse arbitrary text and structure it.
@@ -144,6 +144,8 @@
144
144
  # filter. This newly defined patterns in `pattern_definitions` will not be available outside of that particular `grok` filter.
145
145
  #
146
146
  class LogStash::Filters::Grok < LogStash::Filters::Base
147
+ include LogStash::PluginMixins::ECSCompatibilitySupport
148
+
147
149
  config_name "grok"
148
150
 
149
151
  # A hash of matches of field => value
@@ -250,22 +252,14 @@
250
252
  # will be parsed and `hello world` will overwrite the original message.
251
253
  config :overwrite, :validate => :array, :default => []
252
254
 
253
- # Register default pattern paths
254
- @@patterns_path ||= Set.new
255
- @@patterns_path += [
256
- LogStash::Patterns::Core.path,
257
- LogStash::Environment.pattern_path("*")
258
- ]
259
-
260
255
  def register
261
256
  # a cache of capture name handler methods.
262
257
  @handlers = {}
263
258
 
264
259
  @patternfiles = []
265
-
266
- # Have @@patterns_path show first. Last-in pattern definitions win; this
267
- # will let folks redefine built-in patterns at runtime.
268
- @patternfiles += patterns_files_from_paths(@@patterns_path.to_a, "*")
260
+ # Have (default) patterns_path show first. Last-in pattern definitions wins
261
+ # this will let folks redefine built-in patterns at runtime
262
+ @patternfiles += patterns_files_from_paths(patterns_path, "*")
269
263
  @patternfiles += patterns_files_from_paths(@patterns_dir, @patterns_files_glob)
270
264
 
271
265
  @patterns = Hash.new { |h,k| h[k] = [] }
@@ -278,11 +272,11 @@
278
272
  patterns = [patterns] if patterns.is_a?(String)
279
273
  @metric_match_fields.gauge(field, patterns.length)
280
274
 
281
- @logger.trace("Grok compile", :field => field, :patterns => patterns)
275
+ @logger.trace? && @logger.trace("Grok compile", :field => field, :patterns => patterns)
282
276
  patterns.each do |pattern|
283
- @logger.debug? and @logger.debug("regexp: #{@type}/#{field}", :pattern => pattern)
277
+ @logger.debug? && @logger.debug("regexp: #{@type}/#{field}", :pattern => pattern)
284
278
  grok = Grok.new
285
- grok.logger = @logger unless @logger.nil?
279
+ grok.logger = @logger
286
280
  add_patterns_from_files(@patternfiles, grok)
287
281
  add_patterns_from_inline_definition(@pattern_definitions, grok)
288
282
  grok.compile(pattern, @named_captures_only)
@@ -301,15 +295,14 @@
301
295
  def filter(event)
302
296
  matched = false
303
297
 
304
- @logger.debug? and @logger.debug("Running grok filter", :event => event)
298
+ @logger.debug? && @logger.debug("Running grok filter", :event => event.to_hash)
305
299
 
306
300
  @patterns.each do |field, groks|
307
301
  if match(groks, field, event)
308
302
  matched = true
309
303
  break if @break_on_match
310
304
  end
311
- #break if done
312
- end # @patterns.each
305
+ end
313
306
 
314
307
  if matched
315
308
  @match_counter.increment(1)
@@ -319,7 +312,7 @@
319
312
  @tag_on_failure.each {|tag| event.tag(tag)}
320
313
  end
321
314
 
322
- @logger.debug? and @logger.debug("Event now: ", :event => event)
315
+ @logger.debug? && @logger.debug("Event now: ", :event => event.to_hash)
323
316
  rescue GrokTimeoutException => e
324
317
  @logger.warn(e.message)
325
318
  metric.increment(:timeouts)
@@ -331,6 +324,24 @@
331
324
 
332
325
  private
333
326
 
327
+ # The default pattern paths, depending on environment.
328
+ def patterns_path
329
+ patterns_path = []
330
+ case ecs_compatibility
331
+ when :disabled
332
+ patterns_path << LogStash::Patterns::Core.path # :legacy
333
+ when :v1
334
+ patterns_path << LogStash::Patterns::Core.path('ecs-v1')
335
+ else
336
+ fail(NotImplementedError, "ECS #{ecs_compatibility} is not supported by this plugin.")
337
+ end
338
+ # allow plugin to be instantiated outside the LS environment (in tests)
339
+ if defined? LogStash::Environment.pattern_path
340
+ patterns_path << LogStash::Environment.pattern_path("*")
341
+ end
342
+ patterns_path
343
+ end
344
+
334
345
  def match(groks, field, event)
335
346
  input = event.get(field)
336
347
  if input.is_a?(Array)
@@ -343,7 +354,7 @@
343
354
  match_against_groks(groks, field, input, event)
344
355
  end
345
356
  rescue StandardError => e
346
- @logger.warn("Grok regexp threw exception", :exception => e.message, :backtrace => e.backtrace, :class => e.class.name)
357
+ @logger.warn("Grok regexp threw exception", :message => e.message, :exception => e.class, :backtrace => e.backtrace)
347
358
  return false
348
359
  end
349
360
 
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
-
3
2
  s.name = 'logstash-filter-grok'
4
- s.version = '4.3.0'
3
+ s.version = '4.4.0'
5
4
  s.licenses = ['Apache License (2.0)']
6
5
  s.summary = "Parses unstructured event data into fields"
7
6
  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"
@@ -22,10 +21,11 @@ Gem::Specification.new do |s|
22
21
  # Gem dependencies
23
22
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
23
  s.add_runtime_dependency "logstash-core", ">= 5.6.0"
24
+ s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~> 1.0'
25
25
 
26
26
  s.add_runtime_dependency 'jls-grok', '~> 0.11.3'
27
27
  s.add_runtime_dependency 'stud', '~> 0.0.22'
28
- s.add_runtime_dependency 'logstash-patterns-core'
28
+ s.add_runtime_dependency 'logstash-patterns-core', '>= 4.3.0', '< 5'
29
29
 
30
- s.add_development_dependency 'logstash-devutils', '= 1.3.6'
30
+ s.add_development_dependency 'logstash-devutils'
31
31
  end
@@ -21,13 +21,7 @@ describe LogStash::Filters::Grok do
21
21
 
22
22
  describe "base-line performance", :performance => true do
23
23
 
24
- EXPECTED_MIN_RATE = 15_000 # per second
25
- # NOTE: based on Travis CI (docker) numbers :
26
- # logstash_1_d010d1d29244 | LogStash::Filters::Grok
27
- # logstash_1_d010d1d29244 | base-line performance
28
- # logstash_1_d010d1d29244 | filters/grok parse rate: 14464/sec, elapsed: 20.740866999999998s
29
- # logstash_1_d010d1d29244 | filters/grok parse rate: 29957/sec, elapsed: 10.014199s
30
- # logstash_1_d010d1d29244 | filters/grok parse rate: 32932/sec, elapsed: 9.109601999999999s
24
+ EXPECTED_MIN_RATE = 30_000 # per second - based on Travis CI (docker) numbers
31
25
 
32
26
  let(:config) do
33
27
  { 'match' => { "message" => "%{SYSLOGLINE}" }, 'overwrite' => [ "message" ] }
@@ -87,10 +81,9 @@ describe LogStash::Filters::Grok do
87
81
  puts "filters/grok(timeout => 0) warmed up in #{wout_timeout_duration}"
88
82
  before_sample!
89
83
  no_timeout_durations = Array.new(SAMPLE_COUNT).map do
90
- duration = do_sample_filter(filter_wout_timeout)
91
- puts "filters/grok(timeout => 0) took #{duration}"
92
- duration
84
+ do_sample_filter(filter_wout_timeout)
93
85
  end
86
+ puts "filters/grok(timeout => 0) took #{no_timeout_durations}"
94
87
 
95
88
  expected_duration = avg(no_timeout_durations)
96
89
  expected_duration += (expected_duration / 100) * ACCEPTED_TIMEOUT_DEGRADATION
@@ -100,12 +93,17 @@ describe LogStash::Filters::Grok do
100
93
  with_timeout_duration = do_sample_filter(filter_with_timeout) # warmup
101
94
  puts "filters/grok(timeout_scope => event) warmed up in #{with_timeout_duration}"
102
95
 
103
- before_sample!
104
- expect do
105
- duration = do_sample_filter(filter_with_timeout)
106
- puts "filters/grok(timeout_scope => event) took #{duration}"
107
- duration
108
- end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times
96
+ try(3) do
97
+ before_sample!
98
+ durations = []
99
+ begin
100
+ expect do
101
+ do_sample_filter(filter_with_timeout).tap { |duration| durations << duration }
102
+ end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times
103
+ ensure
104
+ puts "filters/grok(timeout_scope => event) took #{durations}"
105
+ end
106
+ end
109
107
  end
110
108
 
111
109
  @private
@@ -119,10 +117,6 @@ describe LogStash::Filters::Grok do
119
117
  end
120
118
  end
121
119
 
122
- def sample_event(hash)
123
- LogStash::Event.new("message" => SAMPLE_MESSAGE)
124
- end
125
-
126
120
  end
127
121
 
128
122
  @private
@@ -38,6 +38,16 @@ describe LogStash::Filters::Grok do
38
38
  expect( event.get("pid") ).to eql "1713"
39
39
  end
40
40
 
41
+ context 'in ecs mode' do
42
+ let(:config) { super.merge('ecs_compatibility' => 'v1') }
43
+
44
+ it "matches pattern" do
45
+ expect( event.get("host") ).to eql "hostname"=>"evita"
46
+ expect( event.get("process") ).to eql "name"=>"postfix/smtpd", "pid"=>1713
47
+ expect( event.get("message") ).to eql "connect from camomile.cloud9.net[168.100.1.3]"
48
+ end
49
+ end
50
+
41
51
  context 'with target' do
42
52
  let(:config) { { "match" => { "message" => "%{SYSLOGLINE}" }, "target" => "grok" } }
43
53
 
@@ -393,15 +403,17 @@ describe LogStash::Filters::Grok do
393
403
  "message" => [
394
404
  "(.*f){20}", "(.*e){20}", "(.*d){20}", "(.*c){20}", "(.*b){20}",
395
405
  "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
406
+ "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
407
+ "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
396
408
  "(.*a){20}"
397
409
  ]
398
410
  },
399
- 'timeout_millis' => 500,
411
+ 'timeout_millis' => 750,
400
412
  'timeout_scope' => 'pattern'
401
413
  }
402
414
  }
403
415
 
404
- sample( 'b' * 10 + 'c' * 10 + 'd' * 10 + 'e' * 10 + ' ' + 'a' * 20 ) do
416
+ sample( 'b' * 15 + 'c' * 15 + 'd' * 15 + 'e' * 15 + ' ' + 'a' * 20 ) do
405
417
  expect( event.get("tags") ).to be nil
406
418
  end
407
419
  end
@@ -413,15 +425,17 @@ describe LogStash::Filters::Grok do
413
425
  "message" => [
414
426
  "(.*f){20}", "(.*e){20}", "(.*d){20}", "(.*c){20}", "(.*b){20}",
415
427
  "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
428
+ "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
429
+ "(.*a){25}", "(.*a){24}", "(.*a){23}", "(.*a){22}", "(.*a){21}",
416
430
  "(.*a){20}"
417
431
  ]
418
432
  },
419
- 'timeout_millis' => 500,
433
+ 'timeout_millis' => 750,
420
434
  'timeout_scope' => 'event'
421
435
  }
422
436
  }
423
437
 
424
- sample( 'b' * 10 + 'c' * 10 + 'd' * 10 + 'e' * 10 + ' ' + 'a' * 20 ) do
438
+ sample( 'b' * 15 + 'c' * 15 + 'd' * 15 + 'e' * 15 + ' ' + 'a' * 20 ) do
425
439
  expect( event.get("tags") ).to include("_groktimeout")
426
440
  expect( event.get("tags") ).not_to include("_grokparsefailure")
427
441
  end
@@ -774,7 +788,7 @@ describe LogStash::Filters::Grok do
774
788
  end
775
789
 
776
790
  sample("message" => 'hello') do
777
- insist { subject.get("tags") } == ["_grokparsefailure"]
791
+ expect(subject.get("tags")).to eql ["_grokparsefailure"]
778
792
  end
779
793
 
780
794
  after do
@@ -804,7 +818,7 @@ describe LogStash::Filters::Grok do
804
818
  end
805
819
 
806
820
  sample("message" => '0') do
807
- insist { subject.get("tags") } == nil
821
+ expect(subject.get("tags")).to be nil
808
822
  end
809
823
 
810
824
  after do
@@ -833,7 +847,7 @@ describe LogStash::Filters::Grok do
833
847
  end
834
848
 
835
849
  sample("message" => '0') do
836
- insist { subject.get("tags") } == nil
850
+ expect(subject.get("tags")).to be nil
837
851
  end
838
852
 
839
853
  after do
@@ -859,7 +873,7 @@ describe LogStash::Filters::Grok do
859
873
  end
860
874
 
861
875
  sample("message" => '0') do
862
- insist { subject.get("tags") } == nil
876
+ expect(subject.get("tags")).to be nil
863
877
  end
864
878
 
865
879
  after do
@@ -879,17 +893,17 @@ describe LogStash::Filters::Grok do
879
893
  CONFIG
880
894
 
881
895
  sample "treebranch" do
882
- insist { subject.get("name2") } == "branch"
896
+ expect(subject.get("name2")).to eql "branch"
883
897
  end
884
898
 
885
899
  sample "bushbeard" do
886
- insist { subject.get("name1") } == "bush"
900
+ expect(subject.get("name1")).to eql "bush"
887
901
  end
888
902
 
889
903
  sample "treebeard" do
890
- insist { subject.get("name1") } == "tree"
891
- insist { subject.get("name2") } == "beard"
904
+ expect(subject.get("name1")).to eql "tree"
905
+ expect(subject.get("name2")).to eql "beard"
892
906
  end
893
907
  end
894
908
  end
895
- end
909
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-grok
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 5.6.0
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
53
+ name: logstash-mixin-ecs_compatibility_support
54
+ prerelease: false
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
47
61
  - !ruby/object:Gem::Dependency
48
62
  requirement: !ruby/object:Gem::Requirement
49
63
  requirements:
@@ -77,7 +91,10 @@ dependencies:
77
91
  requirements:
78
92
  - - ">="
79
93
  - !ruby/object:Gem::Version
80
- version: '0'
94
+ version: 4.3.0
95
+ - - "<"
96
+ - !ruby/object:Gem::Version
97
+ version: '5'
81
98
  name: logstash-patterns-core
82
99
  prerelease: false
83
100
  type: :runtime
@@ -85,21 +102,24 @@ dependencies:
85
102
  requirements:
86
103
  - - ">="
87
104
  - !ruby/object:Gem::Version
88
- version: '0'
105
+ version: 4.3.0
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: '5'
89
109
  - !ruby/object:Gem::Dependency
90
110
  requirement: !ruby/object:Gem::Requirement
91
111
  requirements:
92
- - - '='
112
+ - - ">="
93
113
  - !ruby/object:Gem::Version
94
- version: 1.3.6
114
+ version: '0'
95
115
  name: logstash-devutils
96
116
  prerelease: false
97
117
  type: :development
98
118
  version_requirements: !ruby/object:Gem::Requirement
99
119
  requirements:
100
- - - '='
120
+ - - ">="
101
121
  - !ruby/object:Gem::Version
102
- version: 1.3.6
122
+ version: '0'
103
123
  description: This gem is a Logstash plugin required to be installed on top of the
104
124
  Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
105
125
  gem is not a stand-alone program