logstash-patterns-core 4.1.2 → 4.2.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
- SHA1:
3
- metadata.gz: 22859cd7eb657e34fd50382564d8278cb6c51267
4
- data.tar.gz: d2a3a2d31d9fc671e8f91b2150ded01d0f4b62df
2
+ SHA256:
3
+ metadata.gz: 2dedffff182dadbed4b39e8e721d412b0d2d1f6f57798dd37dcd034b12c64588
4
+ data.tar.gz: ae6ea53743eb51e7e5d5d7a8951f6628bf9996dae0ccc41b6016c792819835dd
5
5
  SHA512:
6
- metadata.gz: 5fbcaa7f6debbf1a1449d592c1dc2ef2129f0091b7d4918da66c062bc7e779a549863705c9d5854b1ee6403a982a5dfbd58f284d241833a7d89cda0ce701be9a
7
- data.tar.gz: 27af30d700ec261798dd43ab86e0a1ab09075d017d572a11022f28f5ea964cf795d21375badb4cf0c91db176ae26e2296c8d1e3385063f2e6abc28f8e8ac1463
6
+ metadata.gz: 3673dcbada411244ed620b7827fe85bcfa74fcbea74b6668139242c9ab1f24c2cf44a1f780ccd4fb49ea94b8289b72a761b6996bc739406d87ebbef10a5a66ce
7
+ data.tar.gz: 5052131a60ae6ac99d169ca0564882a052569e6ff704ff6972c5ab9ab6356c98ac5cb6bf09f6b3a9560bce6bad6b62d6321835cf2b0c606125f197e60123da7f
@@ -1,3 +1,15 @@
1
+ ## 4.2.0
2
+ - Fix: Java stack trace's JAVAFILE to better match generated names
3
+ - Fix: match Information/INFORMATION in LOGLEVEL [#274](https://github.com/logstash-plugins/logstash-patterns-core/pull/274)
4
+ - Fix: NAGIOS TIMEPERIOD unknown (from/to) field matching [#275](https://github.com/logstash-plugins/logstash-patterns-core/pull/275)
5
+ - Fix: HTTPD access log parse failure on missing response [#282](https://github.com/logstash-plugins/logstash-patterns-core/pull/282)
6
+ - Fix: UNIXPATH to avoid DoS on long paths with unmatching chars [#292](https://github.com/logstash-plugins/logstash-patterns-core/pull/292)
7
+
8
+ For longer paths, a non matching character towards the end of the path would cause the RegExp engine a long time to abort.
9
+ With this change we're also explicit about not supporting relative paths (using the `PATH` pattern), these won't be properly matched.
10
+
11
+ - Feat: allow UNIXPATH to match non-ascii chars [#291](https://github.com/logstash-plugins/logstash-patterns-core/pull/291)
12
+
1
13
  ## 4.1.2
2
14
  - Fix some documentation issues
3
15
 
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
3
  gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE CHANGED
@@ -1,13 +1,202 @@
1
- Copyright (c) 2012–2016 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-patterns-core.svg)](https://travis-ci.org/logstash-plugins/logstash-patterns-core)
3
+ [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-patterns-core.svg)](https://travis-ci.com/logstash-plugins/logstash-patterns-core)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-patterns-core'
4
- s.version = '4.1.2'
4
+ s.version = '4.2.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Patterns to be used in logstash"
7
7
  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"
@@ -32,9 +32,9 @@ HOSTNAME \b(?:[0-9A-Za-z][0-9A-Za-z-]{0,62})(?:\.(?:[0-9A-Za-z][0-9A-Za-z-]{0,62
32
32
  IPORHOST (?:%{IP}|%{HOSTNAME})
33
33
  HOSTPORT %{IPORHOST}:%{POSINT}
34
34
 
35
- # paths
35
+ # paths (only absolute paths are matched)
36
36
  PATH (?:%{UNIXPATH}|%{WINPATH})
37
- UNIXPATH (/([\w_%!$@:.,+~-]+|\\.)*)+
37
+ UNIXPATH (/[[[:alnum:]]_%!$@:.,+~-]*)+
38
38
  TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+))
39
39
  WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+
40
40
  URIPROTO [A-Za-z]([A-Za-z0-9+\-.]+)+
@@ -48,7 +48,7 @@ URIPATHPARAM %{URIPATH}(?:%{URIPARAM})?
48
48
  URI %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:%{URIPATHPARAM})?
49
49
 
50
50
  # Months: January, Feb, 3, 03, 12, December
51
- MONTH \b(?:[Jj]an(?:uary|uar)?|[Ff]eb(?:ruary|ruar)?|[Mm](?:a|ä)?r(?:ch|z)?|[Aa]pr(?:il)?|[Mm]a(?:y|i)?|[Jj]un(?:e|i)?|[Jj]ul(?:y)?|[Aa]ug(?:ust)?|[Ss]ep(?:tember)?|[Oo](?:c|k)?t(?:ober)?|[Nn]ov(?:ember)?|[Dd]e(?:c|z)(?:ember)?)\b
51
+ MONTH \b(?:[Jj]an(?:uary|uar)?|[Ff]eb(?:ruary|ruar)?|[Mm](?:a|ä)?r(?:ch|z)?|[Aa]pr(?:il)?|[Mm]a(?:y|i)?|[Jj]un(?:e|i)?|[Jj]ul(?:y|i)?|[Aa]ug(?:ust)?|[Ss]ep(?:tember)?|[Oo](?:c|k)?t(?:ober)?|[Nn]ov(?:ember)?|[Dd]e(?:c|z)(?:ember)?)\b
52
52
  MONTHNUM (?:0?[1-9]|1[0-2])
53
53
  MONTHNUM2 (?:0[1-9]|1[0-2])
54
54
  MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])
@@ -92,4 +92,4 @@ QS %{QUOTEDSTRING}
92
92
  SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}:
93
93
 
94
94
  # Log Levels
95
- LOGLEVEL ([Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)
95
+ LOGLEVEL ([Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo?(?:rmation)?|INFO?(?:RMATION)?|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)
@@ -31,7 +31,7 @@ HAPROXYCAPTUREDRESPONSEHEADERS %{DATA:captured_response_headers}
31
31
  # HAPROXYCAPTUREDRESPONSEHEADERS %{DATA:response_header_content_type}\|%{DATA:response_header_content_encoding}\|%{DATA:response_header_cache_control}\|%{DATA:response_header_last_modified}
32
32
 
33
33
  # parse a haproxy 'httplog' line
34
- HAPROXYHTTPBASE %{IP:client_ip}:%{INT:client_port} \[%{HAPROXYDATE:accept_date}\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:time_request}/%{INT:time_queue}/%{INT:time_backend_connect}/%{INT:time_backend_response}/%{NOTSPACE:time_duration} %{INT:http_status_code} %{NOTSPACE:bytes_read} %{DATA:captured_request_cookie} %{DATA:captured_response_cookie} %{NOTSPACE:termination_state} %{INT:actconn}/%{INT:feconn}/%{INT:beconn}/%{INT:srvconn}/%{NOTSPACE:retries} %{INT:srv_queue}/%{INT:backend_queue} (\{%{HAPROXYCAPTUREDREQUESTHEADERS}\})?( )?(\{%{HAPROXYCAPTUREDRESPONSEHEADERS}\})?( )?"(<BADREQ>|(%{WORD:http_verb} (%{URIPROTO:http_proto}://)?(?:%{USER:http_user}(?::[^@]*)?@)?(?:%{URIHOST:http_host})?(?:%{URIPATHPARAM:http_request})?( HTTP/%{NUMBER:http_version})?))?"
34
+ HAPROXYHTTPBASE %{IP:client_ip}:%{INT:client_port} \[%{HAPROXYDATE:accept_date}\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:time_request}/%{INT:time_queue}/%{INT:time_backend_connect}/%{INT:time_backend_response}/%{NOTSPACE:time_duration} %{INT:http_status_code} %{NOTSPACE:bytes_read} %{DATA:captured_request_cookie} %{DATA:captured_response_cookie} %{NOTSPACE:termination_state} %{INT:actconn}/%{INT:feconn}/%{INT:beconn}/%{INT:srvconn}/%{NOTSPACE:retries} %{INT:srv_queue}/%{INT:backend_queue} (\{%{HAPROXYCAPTUREDREQUESTHEADERS}\})?( )?(\{%{HAPROXYCAPTUREDRESPONSEHEADERS}\})?( )?"(<BADREQ>|(%{WORD:http_verb} (%{URIPROTO:http_proto}://)?(?:%{USER:http_user}(?::[^@]*)?@)?(?:%{URIHOST:http_host})?(?:%{URIPATHPARAM:http_request})?( HTTP/%{NUMBER:http_version})?))?"?
35
35
 
36
36
  HAPROXYHTTP (?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:timestamp8601}) %{IPORHOST:syslog_server} %{SYSLOGPROG}: %{HAPROXYHTTPBASE}
37
37
 
@@ -2,7 +2,7 @@ HTTPDUSER %{EMAILADDRESS}|%{USER}
2
2
  HTTPDERROR_DATE %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{YEAR}
3
3
 
4
4
  # Log formats
5
- HTTPD_COMMONLOG %{IPORHOST:clientip} %{HTTPDUSER:ident} %{HTTPDUSER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-)
5
+ HTTPD_COMMONLOG %{IPORHOST:clientip} %{HTTPDUSER:ident} %{HTTPDUSER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" (?:-|%{NUMBER:response}) (?:-|%{NUMBER:bytes})
6
6
  HTTPD_COMBINEDLOG %{HTTPD_COMMONLOG} %{QS:referrer} %{QS:agent}
7
7
 
8
8
  # Error logs
@@ -1,14 +1,12 @@
1
1
  JAVACLASS (?:[a-zA-Z$_][a-zA-Z$_0-9]*\.)*[a-zA-Z$_][a-zA-Z$_0-9]*
2
2
  #Space is an allowed character to match special cases like 'Native Method' or 'Unknown Source'
3
- JAVAFILE (?:[A-Za-z0-9_. -]+)
3
+ JAVAFILE (?:[a-zA-Z$_0-9. -]+)
4
4
  #Allow special <init>, <clinit> methods
5
5
  JAVAMETHOD (?:(<(?:cl)?init>)|[a-zA-Z$_][a-zA-Z$_0-9]*)
6
6
  #Line number is optional in special cases 'Native method' or 'Unknown source'
7
7
  JAVASTACKTRACEPART %{SPACE}at %{JAVACLASS:class}\.%{JAVAMETHOD:method}\(%{JAVAFILE:file}(?::%{NUMBER:line})?\)
8
8
  # Java Logs
9
9
  JAVATHREAD (?:[A-Z]{2}-Processor[\d]+)
10
- JAVACLASS (?:[a-zA-Z0-9-]+\.)+[A-Za-z0-9$]+
11
- JAVAFILE (?:[A-Za-z0-9_.-]+)
12
10
  JAVALOGMESSAGE (.*)
13
11
  # MMM dd, yyyy HH:mm:ss eg: Jan 9, 2014 7:13:13 AM
14
12
  CATALINA_DATESTAMP %{MONTH} %{MONTHDAY}, 20%{YEAR} %{HOUR}:?%{MINUTE}(?::?%{SECOND}) (?:AM|PM)
@@ -89,7 +89,7 @@ NAGIOS_PASSIVE_HOST_CHECK %{NAGIOS_TYPE_PASSIVE_HOST_CHECK:nagios_type}: %{DATA:
89
89
  NAGIOS_SERVICE_EVENT_HANDLER %{NAGIOS_TYPE_SERVICE_EVENT_HANDLER:nagios_type}: %{DATA:nagios_hostname};%{DATA:nagios_service};%{DATA:nagios_state};%{DATA:nagios_statelevel};%{DATA:nagios_event_handler_name}
90
90
  NAGIOS_HOST_EVENT_HANDLER %{NAGIOS_TYPE_HOST_EVENT_HANDLER:nagios_type}: %{DATA:nagios_hostname};%{DATA:nagios_state};%{DATA:nagios_statelevel};%{DATA:nagios_event_handler_name}
91
91
 
92
- NAGIOS_TIMEPERIOD_TRANSITION %{NAGIOS_TYPE_TIMEPERIOD_TRANSITION:nagios_type}: %{DATA:nagios_service};%{DATA:nagios_unknown1};%{DATA:nagios_unknown2}
92
+ NAGIOS_TIMEPERIOD_TRANSITION %{NAGIOS_TYPE_TIMEPERIOD_TRANSITION:nagios_type}: %{DATA:nagios_service};%{NUMBER:nagios_unknown1};%{NUMBER:nagios_unknown2}
93
93
 
94
94
  ####################
95
95
  #### External checks
@@ -63,6 +63,19 @@ describe "TOMCATLOG" do
63
63
  end
64
64
  end
65
65
 
66
+ describe 'LOGLEVEL' do
67
+ it 'matches info label' do
68
+ expect(grok_match(subject, 'INFO')).to pass
69
+ expect(grok_match(subject, 'info')).to pass
70
+ end
71
+
72
+ it 'matches information label' do
73
+ expect(grok_match(subject, 'information')).to pass
74
+ expect(grok_match(subject, 'Information')).to pass
75
+ expect(grok_match(subject, 'INFORMATION')).to pass
76
+ end
77
+ end
78
+
66
79
  describe "IPORHOST" do
67
80
 
68
81
  let(:pattern) { "IPORHOST" }
@@ -90,19 +103,209 @@ describe "UNIXPATH" do
90
103
  let(:value) { '/foo/bar' }
91
104
 
92
105
  it "should match the path" do
93
- expect(grok_match(pattern,value)).to pass
106
+ expect(grok_match(pattern, value, true)).to pass
94
107
  end
95
108
 
96
109
  context "when using comma separators and other regexp" do
97
110
 
111
+ let(:pattern) { '((a=(?<a>%{UNIXPATH})?|b=(?<b>%{UNIXPATH})?)(,\s)?)+' }
112
+
113
+ let(:grok) do
114
+ grok = LogStash::Filters::Grok.new("match" => ["message", pattern])
115
+ grok.register
116
+ grok
117
+ end
118
+
98
119
  let(:value) { 'a=/some/path, b=/some/other/path' }
99
120
 
121
+ it "was expected to extract both but never really did" do # or maybe on JRuby 1.7
122
+ event = build_event(value)
123
+ grok.filter(event)
124
+ expect( event.to_hash['a'] ).to eql '/some/path,'
125
+ expect( event.to_hash['b'] ).to be nil
126
+ end
127
+
128
+ end
129
+
130
+ context 'relative path' do
131
+
132
+ let(:path_matcher) do # non-exact matcher
133
+ grok = LogStash::Filters::Grok.new("match" => ["message", '%{UNIXPATH:path}'])
134
+ grok.register
135
+ lambda { |msg| event = build_event(msg); grok.filter(event); event }
136
+ end
137
+
138
+ it "should not match (only partially)" do
139
+ expect(grok_match(pattern, 'a/./b/c', true)).to_not pass
140
+ event = path_matcher.('a/./b/c')
141
+ expect( event.to_hash['path'] ).to eql '/./b/c'
142
+
143
+ expect(grok_match(pattern, ',/.', true)).to_not pass
144
+ event = path_matcher.(',/.')
145
+ expect( event.to_hash['path'] ).to eql '/.'
146
+
147
+ expect(grok_match(pattern, '+/.../', true)).to_not pass
148
+ event = path_matcher.('+/.../')
149
+ expect( event.to_hash['path'] ).to eql '/.../'
150
+
151
+ expect(grok_match(pattern, '~/b/', true)).to_not pass
152
+ event = path_matcher.('~/b/')
153
+ expect( event.to_hash['path'] ).to eql '/b/'
154
+
155
+ expect(grok_match(pattern, './b//', true)).to_not pass
156
+ expect(grok_match(pattern, 'a//b', true)).to_not pass
157
+ end
158
+
159
+ it "should not match paths starting with ." do
160
+ expect(grok_match(pattern, '../0', true)).to_not pass
161
+ expect(grok_match(pattern, './~', true)).to_not pass
162
+ expect(grok_match(pattern, '.../-', true)).to_not pass
163
+ expect(grok_match(pattern, './', true)).to_not pass
164
+ expect(grok_match(pattern, './,', true)).to_not pass
165
+ expect(grok_match(pattern, '../', true)).to_not pass
166
+ expect(grok_match(pattern, '.a/', true)).to_not pass
167
+ expect(grok_match(pattern, '.~/', true)).to_not pass
168
+ end
169
+
170
+ it "should not match expression wout separator" do
171
+ expect(grok_match(pattern, '.')).to_not pass
172
+ expect(grok_match(pattern, '..')).to_not pass
173
+ expect(grok_match(pattern, '...')).to_not pass
174
+ expect(grok_match(pattern, '.,')).to_not pass
175
+ expect(grok_match(pattern, '.-')).to_not pass
176
+ end
177
+
178
+ end
179
+
180
+ context "dotted path" do
181
+
182
+ it "should match path containing ." do
183
+ expect(grok_match(pattern, '/some/./path/', true)).to pass
184
+ expect(grok_match(pattern, '/some/../path', true)).to pass
185
+ expect(grok_match(pattern, '/../.', true)).to pass
186
+ expect(grok_match(pattern, '/.', true)).to pass
187
+ expect(grok_match(pattern, '/..', true)).to pass
188
+ expect(grok_match(pattern, '/...', true)).to pass
189
+ end
190
+
191
+ end
192
+
193
+ context "separators" do
194
+
195
+ it "should match root" do
196
+ expect(grok_match(pattern, '/', true)).to pass
197
+ end
198
+
199
+ it "should match" do
200
+ expect(grok_match(pattern, '//', true)).to pass
201
+ expect(grok_match(pattern, '//00', true)).to pass
202
+ expect(grok_match(pattern, '///a', true)).to pass
203
+ expect(grok_match(pattern, '/a//', true)).to pass
204
+ expect(grok_match(pattern, '///a//b/c///', true)).to pass
205
+ end
206
+
207
+ it "should not match windows separator" do
208
+ expect(grok_match(pattern, "\\a", true)).to_not pass
209
+ expect(grok_match(pattern, '/0\\', true)).to_not pass
210
+ expect(grok_match(pattern, "/a\\b", true)).to_not pass
211
+ end
212
+
213
+ end
214
+
215
+ context "long path" do
216
+
217
+ let(:grok) do
218
+ grok = LogStash::Filters::Grok.new("match" => ["message", '%{UNIXPATH:path} '], 'timeout_millis' => 1500)
219
+ grok.register
220
+ grok
221
+ end
222
+
223
+ let(:value) { '/opt/abcdef/1/.22/3:3+3/foo@BAR/X-Y+Z/~Sample_l_SUBc b' }
224
+
100
225
  it "should match the path" do
101
- expect(grok_match(pattern,value)).to pass
226
+ event = build_event(value)
227
+ grok.filter(event)
228
+ expect( event.to_hash['path'] ).to eql '/opt/abcdef/1/.22/3:3+3/foo@BAR/X-Y+Z/~Sample_l_SUBc'
229
+ end
230
+
231
+ it "should not match with invalid chars (or cause DoS)" do
232
+ event = build_event(value.sub('SUB', '&^_'))
233
+ grok.filter(event) # used to call a looong looop (DoS) despite the timeout guard
234
+ expect( event.to_hash['tags'] ).to include '_grokparsefailure'
102
235
  end
103
236
  end
237
+
238
+ it "matches paths with non-ascii characters" do
239
+ event = build_event path = '/opt/Čierný_Peter/.中'
240
+ build_grok('UNIXPATH:path').filter event
241
+ expect( event.get('path') ).to eql path
242
+ end
243
+
104
244
  end
105
245
 
246
+ describe "WINPATH" do
247
+
248
+ let(:pattern) { 'WINPATH' }
249
+ let(:value) { 'C:\\foo\\bar' }
250
+
251
+ it "should match the path" do
252
+ expect(grok_match(pattern, value, true)).to pass
253
+ end
254
+
255
+ it "should match root path" do
256
+ expect(grok_match(pattern, 'C:\\', true)).to pass
257
+ expect(grok_match(pattern, 'C:\\\\', true)).to pass
258
+ expect(grok_match(pattern, 'a:\\', true)).to pass
259
+ expect(grok_match(pattern, 'x:\\\\', true)).to pass
260
+ end
261
+
262
+ it "should match paths with spaces" do
263
+ expect(grok_match(pattern, 'C:\\Documents and Settings\\Public', true)).to pass
264
+ expect(grok_match(pattern, 'C:\\\\Users\\\\Public\\\\.Mozilla Firefox', true)).to pass
265
+ end
266
+
267
+ it "should not match unix-style paths" do
268
+ expect(grok_match(pattern, '/foo', true)).to_not pass
269
+ expect(grok_match(pattern, '//C/path', true)).to_not pass
270
+ expect(grok_match(pattern, '/', true)).to_not pass
271
+ expect(grok_match(pattern, '/foo/bar', true)).to_not pass
272
+ expect(grok_match(pattern, '/..', true)).to_not pass
273
+ expect(grok_match(pattern, 'C://', true)).to_not pass
274
+ end
275
+
276
+ it "matches paths with non-ascii characters" do
277
+ expect(grok_match(pattern, 'C:\\Čierný Peter\\.中.exe', true)).to pass
278
+ end
279
+
280
+ context 'relative paths' do
281
+
282
+ it "should not match" do
283
+ expect(grok_match(pattern, 'a\\bar', true)).to_not pass
284
+ expect(grok_match(pattern, 'foo\\bar', true)).to_not pass
285
+ expect(grok_match(pattern, 'C\\A\\B', true)).to_not pass
286
+ expect(grok_match(pattern, 'C\\\\0', true)).to_not pass
287
+ expect(grok_match(pattern, '.\\0', true)).to_not pass
288
+ expect(grok_match(pattern, '..\\', true)).to_not pass
289
+ expect(grok_match(pattern, '...\\-', true)).to_not pass
290
+ expect(grok_match(pattern, '.\\', true)).to_not pass
291
+ expect(grok_match(pattern, '.\\,', true)).to_not pass
292
+ expect(grok_match(pattern, '..\\', true)).to_not pass
293
+ expect(grok_match(pattern, '.a\\', true)).to_not pass
294
+ end
295
+
296
+ it "should not match expression wout separator" do
297
+ expect(grok_match(pattern, '.')).to_not pass
298
+ expect(grok_match(pattern, '..')).to_not pass
299
+ expect(grok_match(pattern, '...')).to_not pass
300
+ expect(grok_match(pattern, 'C:')).to_not pass
301
+ expect(grok_match(pattern, 'C')).to_not pass
302
+ end
303
+
304
+ end
305
+
306
+ end
307
+
308
+
106
309
  describe "URIPROTO" do
107
310
  let(:pattern) { 'URIPROTO' }
108
311
 
@@ -56,4 +56,21 @@ describe "HAPROXY" do
56
56
 
57
57
  end
58
58
 
59
+ context "Parsing HAPROXY log line that is truncated and thus not ending with a double quote or HTTP version." do
60
+
61
+ let(:value) { 'Jul 31 22:20:22 loadbalancer haproxy[1190]: 203.0.113.54:59968 [31/Jul/2017:22:20:22.447] loadbalancer default/instance8 135/0/1/19/156 200 1015 - - --VR 8/8/0/0/0 0/0 "GET /path/to/request/that/exceeds/more/than/1024/characterssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss'}
62
+ subject { grok_match(haproxyhttpbase_pattern, value)}
63
+
64
+ it { should include("client_ip" => "203.0.113.54") }
65
+ it { should include("http_verb" => "GET") }
66
+ it { should include("server_name" => "instance8") }
67
+ it { should include("http_request" => "/path/to/request/that/exceeds/more/than/1024/characterssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss") }
68
+ it { should_not have_key("http_version") }
69
+
70
+ it "generates a message field" do
71
+ expect(subject["message"]).to include("loadbalancer default/instance8")
72
+ end
73
+
74
+ end
75
+
59
76
  end
@@ -4,12 +4,15 @@ require "logstash/patterns/core"
4
4
 
5
5
  describe "HTTPD_COMBINEDLOG" do
6
6
 
7
- context "HTTPD_COMBINEDLOG", "Typical test case" do
7
+ let(:pattern) { 'HTTPD_COMBINEDLOG' }
8
+ let(:grok) { grok_match(pattern, message) }
8
9
 
9
- let(:value) { '83.149.9.216 - - [24/Feb/2015:23:13:42 +0000] "GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1" 200 203023 "http://semicomplete.com/presentations/logstash-monitorama-2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"'}
10
+ context "typical test case" do
10
11
 
11
- it "generates the clientip field" do
12
- expect(grok_match(subject, value)).to include(
12
+ let(:message) { '83.149.9.216 - - [24/Feb/2015:23:13:42 +0000] "GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1" 200 203023 "http://semicomplete.com/presentations/logstash-monitorama-2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"'}
13
+
14
+ it "matches" do
15
+ expect(grok).to include(
13
16
  'clientip' => '83.149.9.216',
14
17
  'verb' => 'GET',
15
18
  'request' => '/presentations/logstash-monitorama-2013/images/kibana-search.png',
@@ -21,14 +24,32 @@ describe "HTTPD_COMBINEDLOG" do
21
24
  )
22
25
  end
23
26
 
27
+ it "does not capture 'null' fields" do
28
+ expect(grok).to include('auth' => '-', 'ident' => '-')
29
+ end
30
+
31
+ end
32
+
33
+ context "email address in auth field" do
34
+
35
+ let(:message) { '10.0.0.1 - username@example.com [07/Apr/2016:18:42:24 +0000] "GET /bar/foo/users/1/username%40example.com/authenticate?token=blargh&client_id=15 HTTP/1.1" 400 75 "" "Mozilla/5.0 (iPad; CPU OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1"'}
36
+
37
+ it "gets captured" do
38
+ expect(grok).to include("auth" => "username@example.com")
39
+ end
40
+
24
41
  end
25
42
 
26
- context "HTTPD_COMBINEDLOG", "Email address in auth field" do
43
+ context 'sample OPTIONS line' do
44
+
45
+ let(:message) { '83.149.9.216 - a.user [11/Jan/2020:23:05:27 +0100] "OPTIONS /remote.php/ HTTP/1.1" - 7908 "-" "monitoring-client (v2.2)"' }
27
46
 
28
- let(:value) { '10.0.0.1 - username@example.com [07/Apr/2016:18:42:24 +0000] "GET /bar/foo/users/1/username%40example.com/authenticate?token=blargh&client_id=15 HTTP/1.1" 400 75 "" "Mozilla/5.0 (iPad; CPU OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1"'}
47
+ it 'matches' do
48
+ expect(grok).to include("verb" => "OPTIONS", 'request' => '/remote.php/', 'httpversion' => '1.1', "bytes" => '7908')
49
+ end
29
50
 
30
- it "generates the clientip field" do
31
- expect(grok_match(subject, value)).to include("auth" => "username@example.com")
51
+ it 'does not capture optional response code' do
52
+ expect(grok.keys).to_not include("response")
32
53
  end
33
54
 
34
55
  end
@@ -37,13 +58,16 @@ end
37
58
 
38
59
  describe "HTTPD_ERRORLOG" do
39
60
 
40
- context "HTTPD_ERRORLOG", "matches a full httpd 2.4 message" do
41
- let(:value) {
61
+ let(:pattern) { 'HTTPD_ERRORLOG' }
62
+ let(:grok) { grok_match(pattern, message) }
63
+
64
+ context "matches a full httpd 2.4 message" do
65
+ let(:message) do
42
66
  "[Mon Aug 31 09:30:48.958285 2015] [proxy_fcgi:error] [pid 28787:tid 140169587934976] (70008)Partial results are valid but processing is incomplete: [client 58.13.45.166:59307] AH01075: Error dispatching request to : (reading input brigade), referer: http://example.com/index.php?id_product=11&controller=product"
43
- }
67
+ end
44
68
  it "generates the fields" do
45
69
 
46
- expect(grok_match(subject, value)).to include(
70
+ expect(grok).to include(
47
71
  'timestamp' => 'Mon Aug 31 09:30:48.958285 2015',
48
72
  'module' => 'proxy_fcgi',
49
73
  'loglevel' => 'error',
@@ -54,26 +78,26 @@ describe "HTTPD_ERRORLOG" do
54
78
  'clientip' => '58.13.45.166',
55
79
  'clientport' => '59307',
56
80
  'errorcode' => 'AH01075',
57
- 'message' => [ value, 'Error dispatching request to : (reading input brigade), referer: http://example.com/index.php?id_product=11&controller=product' ],
81
+ 'message' => [ message, 'Error dispatching request to : (reading input brigade), referer: http://example.com/index.php?id_product=11&controller=product' ],
58
82
  )
59
83
  end
60
84
  end
61
85
 
62
86
  context "HTTPD_ERRORLOG", "matches a httpd 2.2 log message" do
63
- let(:value) {
87
+ let(:message) do
64
88
  "[Mon Aug 31 16:27:04 2015] [error] [client 10.17.42.3] Premature end of script headers: example.com"
65
- }
89
+ end
66
90
  it "generates the fields" do
67
- expect(grok_match(subject, value)).to include(
91
+ expect(grok).to include(
68
92
  'timestamp' => 'Mon Aug 31 16:27:04 2015',
69
93
  'loglevel' => 'error',
70
94
  'clientip' => '10.17.42.3',
71
- 'message' => [ value, 'Premature end of script headers: example.com' ]
95
+ 'message' => [ message, 'Premature end of script headers: example.com' ]
72
96
  )
73
97
  end
74
98
  end
75
99
 
76
- context "HTTPD_ERRORLOG", "matches a short httpd 2.4 message" do
100
+ context "HTTPD_ERRORLOG", "a short httpd 2.4 message" do
77
101
  let(:value1) {
78
102
  "[Mon Aug 31 07:15:38.664897 2015] [proxy_fcgi:error] [pid 28786:tid 140169629898496] [client 81.139.1.34:52042] AH01071: Got error 'Primary script unknown\n'"
79
103
  }
@@ -107,7 +131,7 @@ describe "HTTPD_ERRORLOG" do
107
131
  end
108
132
  end
109
133
 
110
- context "HTTPD_ERRORLOG", "matches an httpd 2.4 restart" do
134
+ context "HTTPD_ERRORLOG", "a httpd 2.4 restart message" do
111
135
  let(:value1) {
112
136
  "[Mon Aug 31 06:29:47.406518 2015] [mpm_event:notice] [pid 24968:tid 140169861986176] AH00489: Apache/2.4.16 (Ubuntu) configured -- resuming normal operations"
113
137
  }
@@ -139,5 +163,22 @@ describe "HTTPD_ERRORLOG" do
139
163
  end
140
164
  end
141
165
 
166
+ context 'a debug message' do
167
+ let(:message) do
168
+ '[Fri Feb 01 22:03:08.319124 2019] [authz_core:debug] [pid 9:tid 140597881775872] mod_authz_core.c(820): [client 172.17.0.1:50752] AH01626: authorization result of <RequireAny>: granted'
169
+ end
170
+
171
+ it 'matches imperfectly (legacy)' do
172
+ expect(grok).to include({
173
+ "timestamp"=>"Fri Feb 01 22:03:08.319124 2019",
174
+ "module"=>"authz_core",
175
+ "loglevel"=>"debug",
176
+ "pid"=>"9",
177
+ "tid"=>"140597881775872",
178
+ "errorcode"=>"mod_authz_core.c(820)",
179
+ "message"=>[message, "[client 172.17.0.1:50752] AH01626: authorization result of <RequireAny>: granted"]
180
+ })
181
+ end
182
+ end
142
183
 
143
184
  end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "logstash/patterns/core"
4
+
5
+ describe "JAVA" do
6
+ describe "JAVACLASS" do
7
+ let(:example) { 'hudson.node_monitors.AbstractAsyncNodeMonitorDescriptor' }
8
+ it "matches a java class with underscores" do
9
+ expect(grok_match(subject, example, true)['tags']).to be_nil
10
+ end
11
+ end
12
+ describe "JAVAFILE" do
13
+ let(:example) { 'Native Method' }
14
+ it "matches a java file name with spaces" do
15
+ expect(grok_match(subject, example, true)['tags']).to be_nil
16
+ end
17
+ end
18
+ end
19
+
20
+ describe "JAVASTACKTRACEPART" do
21
+ let(:pattern) { 'JAVASTACKTRACEPART' }
22
+ let(:message) { ' at com.sample.stacktrace.StackTraceExample.aMethod(StackTraceExample.java:42)' }
23
+ it "matches" do
24
+ grok = grok_match(pattern, message, true)
25
+ expect(grok).to include({
26
+ "message"=>" at com.sample.stacktrace.StackTraceExample.aMethod(StackTraceExample.java:42)",
27
+ "method"=>"aMethod",
28
+ "class"=>"com.sample.stacktrace.StackTraceExample",
29
+ "file"=>"StackTraceExample.java",
30
+ "line"=>"42"
31
+ })
32
+ end
33
+
34
+ context 'generated file' do
35
+ let(:message) { ' at org.jruby.RubyMethod$INVOKER$i$call.call(RubyMethod$INVOKER$i$call.gen)' }
36
+ it "matches" do
37
+ grok = grok_match(pattern, message, true)
38
+ expect(grok).to include({
39
+ "method"=>"call",
40
+ "class"=>"org.jruby.RubyMethod$INVOKER$i$call",
41
+ "file"=>"RubyMethod$INVOKER$i$call.gen",
42
+ })
43
+ end
44
+ end
45
+ end
@@ -82,7 +82,7 @@ end
82
82
 
83
83
  describe "NAGIOSLOGLINE - TIMEPERIOD TRANSITION" do
84
84
 
85
- let(:value) { "[1427925600] TIMEPERIOD TRANSITION: 24X7;1;1" }
85
+ let(:value) { "[1427925600] TIMEPERIOD TRANSITION: 24X7;-1;1" }
86
86
  let(:grok) { grok_match(subject, value) }
87
87
 
88
88
  it "a pattern pass the grok expression" do
@@ -105,6 +105,10 @@ describe "NAGIOSLOGLINE - TIMEPERIOD TRANSITION" do
105
105
  expect(grok).to include("nagios_service" => "24X7")
106
106
  end
107
107
 
108
+ it "generates the period from/to fields" do
109
+ expect(grok).to include("nagios_unknown1" => "-1", "nagios_unknown2" => "1")
110
+ end
111
+
108
112
  # Regression test for but fixed in Nagios patterns #30
109
113
  it "doesn't end in a semi-colon" do
110
114
  expect(grok['message']).to_not end_with(";")
@@ -24,15 +24,19 @@ end
24
24
  require "logstash/filters/grok"
25
25
 
26
26
  module GrokHelpers
27
- def grok_match(label, message)
28
- grok = build_grok(label)
27
+ def grok_match(label, message, exact_match = false)
28
+ grok = build_grok(label, exact_match)
29
29
  event = build_event(message)
30
30
  grok.filter(event)
31
31
  event.to_hash
32
32
  end
33
33
 
34
- def build_grok(label)
35
- grok = LogStash::Filters::Grok.new("match" => ["message", "%{#{label}}"])
34
+ def build_grok(label, exact_match = false)
35
+ if exact_match
36
+ grok = LogStash::Filters::Grok.new("match" => ["message", "^%{#{label}}$"])
37
+ else
38
+ grok = LogStash::Filters::Grok.new("match" => ["message", "%{#{label}}"])
39
+ end
36
40
  grok.register
37
41
  grok
38
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-patterns-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -58,7 +58,9 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
- 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
61
+ description: This gem is a Logstash plugin required to be installed on top of the
62
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
63
+ gem is not a stand-alone program
62
64
  email: info@elastic.co
63
65
  executables: []
64
66
  extensions: []
@@ -99,6 +101,7 @@ files:
99
101
  - spec/patterns/firewalls_spec.rb
100
102
  - spec/patterns/haproxy_spec.rb
101
103
  - spec/patterns/httpd_spec.rb
104
+ - spec/patterns/java_spec.rb
102
105
  - spec/patterns/maven_spec.rb
103
106
  - spec/patterns/mongodb_spec.rb
104
107
  - spec/patterns/nagios_spec.rb
@@ -129,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
132
  version: '0'
130
133
  requirements: []
131
134
  rubyforge_project:
132
- rubygems_version: 2.4.8
135
+ rubygems_version: 2.6.13
133
136
  signing_key:
134
137
  specification_version: 4
135
138
  summary: Patterns to be used in logstash
@@ -139,6 +142,7 @@ test_files:
139
142
  - spec/patterns/firewalls_spec.rb
140
143
  - spec/patterns/haproxy_spec.rb
141
144
  - spec/patterns/httpd_spec.rb
145
+ - spec/patterns/java_spec.rb
142
146
  - spec/patterns/maven_spec.rb
143
147
  - spec/patterns/mongodb_spec.rb
144
148
  - spec/patterns/nagios_spec.rb