fluent-plugin-grok-parser 2.4.0 → 2.6.2
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/.travis.yml +3 -5
- data/README.md +35 -3
- data/appveyor.yml +3 -30
- data/fluent-plugin-grok-parser.gemspec +1 -1
- data/lib/fluent/plugin/grok.rb +10 -2
- data/lib/fluent/plugin/parser_grok.rb +5 -0
- data/patterns/grok-patterns +3 -3
- data/patterns/haproxy +1 -1
- data/patterns/httpd +3 -3
- data/patterns/java +1 -3
- data/patterns/linux-syslog +1 -1
- data/patterns/nagios +1 -1
- data/test/test_grok_parser.rb +90 -23
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5f5cd1dd1aa1de7edd4425755616b0488492d32847b8e254d79d0385d3cbd4
|
4
|
+
data.tar.gz: cc629c894253715304a18b3eccc2a2caba04069b9b22124893a8e77dacbf4c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7548442e6f18c3b302df37f9f8d9300374f116236fcecb30c8e2426e65f43038e011a312ff4641d779c26fd95f6f3d38db17145ea793a2a29f34b2ab7c6d0709
|
7
|
+
data.tar.gz: b5e05fbefb609cf206ddbbf8347a9e9f93e4ba4a4eb2aa1d653db6b54332c311b4c388d8cf7e85fad2d10919d444a2bb6a5fe7677024f999d43cfd7680785b9c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -95,8 +95,7 @@ You can use this parser without `multiline_start_regexp` when you know your data
|
|
95
95
|
|
96
96
|
## Configurations
|
97
97
|
|
98
|
-
* See also: [
|
99
|
-
* See also: [Parser Plugin Overview](https://docs.fluentd.org/v1.0/articles/parser-plugin-overview)
|
98
|
+
* See also: [Config: Parse Section - Fluentd](https://docs.fluentd.org/configuration/parse-section)
|
100
99
|
|
101
100
|
* **time_format** (string) (optional): The format of the time field.
|
102
101
|
* **grok_pattern** (string) (optional): The pattern of grok. You cannot specify multiple grok pattern with this.
|
@@ -105,6 +104,17 @@ You can use this parser without `multiline_start_regexp` when you know your data
|
|
105
104
|
* **grok_name_key** (string) (optional): The key name to store grok section's name
|
106
105
|
* **multi_line_start_regexp** (string) (optional): The regexp to match beginning of multiline. This is only for "multiline_grok".
|
107
106
|
|
107
|
+
### \<grok\> section (optional) (multiple)
|
108
|
+
|
109
|
+
* **name** (string) (optional): The name of this grok section
|
110
|
+
* **pattern** (string) (required): The pattern of grok
|
111
|
+
* **keep_time_key** (bool) (optional): If true, keep time field in the record.
|
112
|
+
* **time_key** (string) (optional): Specify time field for event time. If the event doesn't have this field, current time is used.
|
113
|
+
* Default value: `time`.
|
114
|
+
* **time_format** (string) (optional): Process value using specified format. This is available only when time_type is string
|
115
|
+
* **timezone** (string) (optional): Use specified timezone. one can parse/format the time value in the specified timezone.
|
116
|
+
|
117
|
+
|
108
118
|
## Examples
|
109
119
|
|
110
120
|
### Using grok\_failure\_key
|
@@ -184,6 +194,28 @@ This will add keys like following:
|
|
184
194
|
Add `grokfailure` key to the record if the record does not match any grok pattern.
|
185
195
|
See also test code for more details.
|
186
196
|
|
197
|
+
## How to parse time value using specific timezone
|
198
|
+
|
199
|
+
```aconf
|
200
|
+
<source>
|
201
|
+
@type tail
|
202
|
+
path /path/to/log
|
203
|
+
tag grokked_log
|
204
|
+
<parse>
|
205
|
+
@type grok
|
206
|
+
<grok>
|
207
|
+
name mylog-without-timezone
|
208
|
+
pattern %{DATESTAMP:time} %{GREEDYDATE:message}
|
209
|
+
timezone Asia/Tokyo
|
210
|
+
</grok>
|
211
|
+
</parse>
|
212
|
+
</source>
|
213
|
+
```
|
214
|
+
|
215
|
+
This will parse the `time` value as "Asia/Tokyo" timezone.
|
216
|
+
|
217
|
+
See [Config: Parse Section - Fluentd](https://docs.fluentd.org/configuration/parse-section) for more details about timezone.
|
218
|
+
|
187
219
|
## How to write Grok patterns
|
188
220
|
|
189
221
|
Grok patterns look like `%{PATTERN_NAME:name}` where ":name" is optional. If "name" is provided, then it
|
@@ -271,7 +303,7 @@ Here is a sample config using the Grok parser with `in_tail` and the `types` par
|
|
271
303
|
|
272
304
|
If you want to use this plugin with Fluentd v0.12.x or earlier, you can use this plugin version v1.x.
|
273
305
|
|
274
|
-
See also: [Plugin Management | Fluentd](
|
306
|
+
See also: [Plugin Management | Fluentd](https://docs.fluentd.org/deployment/plugin-management)
|
275
307
|
|
276
308
|
## License
|
277
309
|
|
data/appveyor.yml
CHANGED
@@ -5,11 +5,9 @@ version: '{build}'
|
|
5
5
|
|
6
6
|
install:
|
7
7
|
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
8
|
-
- IF %ridk%==0 "%devkit%\\devkitvars.bat"
|
9
8
|
- ruby --version
|
10
9
|
- gem --version
|
11
|
-
-
|
12
|
-
- IF %ridk%==1 ridk.cmd exec bundle install
|
10
|
+
- ridk.cmd exec bundle install
|
13
11
|
build: off
|
14
12
|
test_script:
|
15
13
|
- bundle exec rake test
|
@@ -17,34 +15,9 @@ test_script:
|
|
17
15
|
# https://www.appveyor.com/docs/installed-software/#ruby
|
18
16
|
environment:
|
19
17
|
matrix:
|
18
|
+
- ruby_version: "26-x64"
|
19
|
+
- ruby_version: "26"
|
20
20
|
- ruby_version: "25-x64"
|
21
|
-
ridk: 1
|
22
21
|
- ruby_version: "25"
|
23
|
-
ridk: 1
|
24
22
|
- ruby_version: "24-x64"
|
25
|
-
ridk: 1
|
26
23
|
- ruby_version: "24"
|
27
|
-
ridk: 1
|
28
|
-
- ruby_version: "23-x64"
|
29
|
-
devkit: C:\Ruby23-x64\DevKit
|
30
|
-
ridk: 0
|
31
|
-
- ruby_version: "23"
|
32
|
-
devkit: C:\Ruby23\DevKit
|
33
|
-
ridk: 0
|
34
|
-
- ruby_version: "22-x64"
|
35
|
-
devkit: C:\Ruby23-x64\DevKit
|
36
|
-
ridk: 0
|
37
|
-
- ruby_version: "21-x64"
|
38
|
-
devkit: C:\Ruby23-x64\DevKit
|
39
|
-
ridk: 0
|
40
|
-
- ruby_version: "22"
|
41
|
-
devkit: C:\Ruby23\DevKit
|
42
|
-
WIN_RAPID: true
|
43
|
-
ridk: 0
|
44
|
-
- ruby_version: "21"
|
45
|
-
devkit: C:\Ruby23\DevKit
|
46
|
-
WIN_RAPID: true
|
47
|
-
ridk: 0
|
48
|
-
matrix:
|
49
|
-
allow_failures:
|
50
|
-
- ruby_version: "21"
|
@@ -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.
|
7
|
+
spec.version = "2.6.2"
|
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
@@ -13,7 +13,7 @@ module Fluent
|
|
13
13
|
(?<pattern>[A-z0-9]+)
|
14
14
|
(?::(?<subname>[@\[\]A-z0-9_:.-]+?)
|
15
15
|
(?::(?<type>(?:string|bool|integer|float|
|
16
|
-
time(
|
16
|
+
time(?::.+?)?|
|
17
17
|
array(?::.)?)))?)?
|
18
18
|
)
|
19
19
|
\}/x
|
@@ -27,6 +27,8 @@ module Fluent
|
|
27
27
|
@multiline_mode = false
|
28
28
|
@conf = conf
|
29
29
|
@plugin = plugin
|
30
|
+
@time_format = nil
|
31
|
+
@timezone = nil
|
30
32
|
if @plugin.respond_to?(:firstline?)
|
31
33
|
@multiline_mode = true
|
32
34
|
end
|
@@ -39,6 +41,9 @@ module Fluent
|
|
39
41
|
if @plugin.respond_to?(:time_format)
|
40
42
|
@time_format = @plugin.time_format
|
41
43
|
end
|
44
|
+
if @plugin.respond_to?(:timezone)
|
45
|
+
@timezone = @plugin.timezone
|
46
|
+
end
|
42
47
|
end
|
43
48
|
|
44
49
|
def add_patterns_from_file(path)
|
@@ -105,6 +110,9 @@ module Fluent
|
|
105
110
|
if conf["time_format"] || @time_format
|
106
111
|
_conf["time_format"] = conf["time_format"] || @time_format
|
107
112
|
end
|
113
|
+
if conf["timezone"] || @timezone
|
114
|
+
_conf["timezone"] = conf["timezone"] || @timezone
|
115
|
+
end
|
108
116
|
_conf["expression"] = regexp
|
109
117
|
config = Fluent::Config::Element.new("parse", "", _conf, [])
|
110
118
|
parser = Fluent::Plugin::RegexpParser.new
|
@@ -131,7 +139,7 @@ module Fluent
|
|
131
139
|
else
|
132
140
|
replacement_pattern = "(?:#{curr_pattern})"
|
133
141
|
end
|
134
|
-
pattern.sub
|
142
|
+
pattern = pattern.sub(m[0]) do |s|
|
135
143
|
replacement_pattern
|
136
144
|
end
|
137
145
|
end
|
@@ -22,9 +22,14 @@ module Fluent
|
|
22
22
|
config_param :name, :string, default: nil
|
23
23
|
desc "The pattern of grok"
|
24
24
|
config_param :pattern, :string
|
25
|
+
desc "If true, keep time field in the record."
|
25
26
|
config_param :keep_time_key, :bool, default: false
|
27
|
+
desc "Specify time field for event time. If the event doesn't have this field, current time is used."
|
26
28
|
config_param :time_key, :string, default: "time"
|
29
|
+
desc "Process value using specified format. This is available only when time_type is string"
|
27
30
|
config_param :time_format, :string, default: nil
|
31
|
+
desc "Use specified timezone. one can parse/format the time value in the specified timezone."
|
32
|
+
config_param :timezone, :string, default: nil
|
28
33
|
end
|
29
34
|
|
30
35
|
def initialize
|
data/patterns/grok-patterns
CHANGED
@@ -37,7 +37,7 @@ PATH (?:%{UNIXPATH}|%{WINPATH})
|
|
37
37
|
UNIXPATH (/([\w_%!$@:.,+~-]+|\\.)*)+
|
38
38
|
TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+))
|
39
39
|
WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+
|
40
|
-
URIPROTO [A-Za-z]
|
40
|
+
URIPROTO [A-Za-z]([A-Za-z0-9+\-.]+)+
|
41
41
|
URIHOST %{IPORHOST}(?::%{POSINT:port})?
|
42
42
|
# uripath comes loosely from RFC1738, but mostly from what Firefox
|
43
43
|
# doesn't turn into %XX
|
@@ -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
|
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)?)
|
data/patterns/haproxy
CHANGED
@@ -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
|
|
data/patterns/httpd
CHANGED
@@ -2,14 +2,14 @@ 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})"
|
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
|
9
9
|
HTTPD20_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{LOGLEVEL:loglevel}\] (?:\[client %{IPORHOST:clientip}\] ){0,1}%{GREEDYDATA:message}
|
10
|
-
HTTPD24_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{WORD:module}:%{LOGLEVEL:loglevel}\] \[pid %{POSINT:pid}:tid %{NUMBER:tid}
|
10
|
+
HTTPD24_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{WORD:module}:%{LOGLEVEL:loglevel}\] \[pid %{POSINT:pid}(:tid %{NUMBER:tid})?\]( \(%{POSINT:proxy_errorcode}\)%{DATA:proxy_message}:)?( \[client %{IPORHOST:clientip}:%{POSINT:clientport}\])?( %{DATA:errorcode}:)? %{GREEDYDATA:message}
|
11
11
|
HTTPD_ERRORLOG %{HTTPD20_ERRORLOG}|%{HTTPD24_ERRORLOG}
|
12
12
|
|
13
13
|
# Deprecated
|
14
14
|
COMMONAPACHELOG %{HTTPD_COMMONLOG}
|
15
|
-
COMBINEDAPACHELOG %{HTTPD_COMBINEDLOG}
|
15
|
+
COMBINEDAPACHELOG %{HTTPD_COMBINEDLOG}
|
data/patterns/java
CHANGED
@@ -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 (?:[
|
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)
|
data/patterns/linux-syslog
CHANGED
@@ -11,6 +11,6 @@ SYSLOGLINE %{SYSLOGBASE2} %{GREEDYDATA:message}
|
|
11
11
|
# IETF 5424 syslog(8) format (see http://www.rfc-editor.org/info/rfc5424)
|
12
12
|
SYSLOG5424PRI <%{NONNEGINT:syslog5424_pri}>
|
13
13
|
SYSLOG5424SD \[%{DATA}\]+
|
14
|
-
SYSLOG5424BASE %{SYSLOG5424PRI}%{NONNEGINT:syslog5424_ver} +(?:%{TIMESTAMP_ISO8601:syslog5424_ts}|-) +(?:%{
|
14
|
+
SYSLOG5424BASE %{SYSLOG5424PRI}%{NONNEGINT:syslog5424_ver} +(?:%{TIMESTAMP_ISO8601:syslog5424_ts}|-) +(?:%{IPORHOST:syslog5424_host}|-) +(-|%{SYSLOG5424PRINTASCII:syslog5424_app}) +(-|%{SYSLOG5424PRINTASCII:syslog5424_proc}) +(-|%{SYSLOG5424PRINTASCII:syslog5424_msgid}) +(?:%{SYSLOG5424SD:syslog5424_sd}|-|)
|
15
15
|
|
16
16
|
SYSLOG5424LINE %{SYSLOG5424BASE} +%{GREEDYDATA:syslog5424_msg}
|
data/patterns/nagios
CHANGED
@@ -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};%{
|
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
|
data/test/test_grok_parser.rb
CHANGED
@@ -158,37 +158,49 @@ class GrokParserTest < ::Test::Unit::TestCase
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
|
162
|
-
|
163
|
-
|
161
|
+
sub_test_case "configure" do
|
162
|
+
test "no grok patterns" do
|
163
|
+
assert_raise Fluent::ConfigError do
|
164
|
+
create_driver('')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
test "invalid config value type" do
|
169
|
+
assert_raise Fluent::ConfigError do
|
170
|
+
create_driver(%[
|
171
|
+
<grok>
|
172
|
+
pattern %{PATH:path:foo}
|
173
|
+
</grok>
|
174
|
+
])
|
175
|
+
end
|
164
176
|
end
|
165
|
-
end
|
166
177
|
|
167
|
-
|
168
|
-
|
169
|
-
create_driver(%[
|
178
|
+
test "invalid config value type and normal grok pattern" do
|
179
|
+
d = create_driver(%[
|
170
180
|
<grok>
|
171
181
|
pattern %{PATH:path:foo}
|
172
182
|
</grok>
|
183
|
+
<grok>
|
184
|
+
pattern %{IP:ip_address}
|
185
|
+
</grok>
|
173
186
|
])
|
187
|
+
assert_equal(1, d.instance.instance_variable_get(:@grok).parsers.size)
|
188
|
+
logs = $log.instance_variable_get(:@logger).instance_variable_get(:@logdev).logs
|
189
|
+
error_logs = logs.grep(/error_class/)
|
190
|
+
assert_equal(1, error_logs.size)
|
191
|
+
error_message = error_logs.first[/error="(.+)"/, 1]
|
192
|
+
assert_equal("unknown value conversion for key:'path', type:'foo'", error_message)
|
174
193
|
end
|
175
|
-
end
|
176
194
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
assert_equal(1, d.instance.instance_variable_get(:@grok).parsers.size)
|
187
|
-
logs = $log.instance_variable_get(:@logger).instance_variable_get(:@logdev).logs
|
188
|
-
error_logs = logs.grep(/error_class/)
|
189
|
-
assert_equal(1, error_logs.size)
|
190
|
-
error_message = error_logs.first[/error="(.+)"/, 1]
|
191
|
-
assert_equal("unknown value conversion for key:'path', type:'foo'", error_message)
|
195
|
+
test "keep original configuration" do
|
196
|
+
config = %[
|
197
|
+
<grok>
|
198
|
+
pattern %{INT:user_id:integer} paid %{NUMBER:paid_amount:float}
|
199
|
+
</grok>
|
200
|
+
]
|
201
|
+
d = create_driver(config)
|
202
|
+
assert_equal("%{INT:user_id:integer} paid %{NUMBER:paid_amount:float}", d.instance.config.elements("grok").first["pattern"])
|
203
|
+
end
|
192
204
|
end
|
193
205
|
|
194
206
|
sub_test_case "grok_name_key" do
|
@@ -347,6 +359,61 @@ class GrokParserTest < ::Test::Unit::TestCase
|
|
347
359
|
assert_equal(event_time("28/Feb/2013:12:00:00 +0900", format: "%d/%b/%Y:%H:%M:%S %z"), time)
|
348
360
|
end
|
349
361
|
end
|
362
|
+
|
363
|
+
test "leading time type with following other type" do
|
364
|
+
d = create_driver(%[
|
365
|
+
<grok>
|
366
|
+
pattern \\[%{HTTPDATE:log_timestamp:time:%d/%b/%Y:%H:%M:%S %z}\\] %{GREEDYDATA:message}
|
367
|
+
</grok>
|
368
|
+
])
|
369
|
+
expected_record = {
|
370
|
+
"log_timestamp" => event_time("03/Feb/2019:06:47:21 +0530", format: "%d/%b/%Y:%H:%M:%S %z"),
|
371
|
+
"message" => "Python-urllib/2.7"
|
372
|
+
}
|
373
|
+
d.instance.parse('[03/Feb/2019:06:47:21 +0530] Python-urllib/2.7') do |time, record|
|
374
|
+
assert_equal(expected_record, record)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
test "timezone" do
|
379
|
+
d = create_driver(%[
|
380
|
+
<grok>
|
381
|
+
pattern %{TIMESTAMP_ISO8601:time} %{GREEDYDATA:message}
|
382
|
+
time_key time
|
383
|
+
time_format %Y-%m-%d %H:%M:%S
|
384
|
+
timezone Europe/Berlin
|
385
|
+
</grok>
|
386
|
+
])
|
387
|
+
d.instance.parse("2019-02-01 12:34:56 This is test") do |time, record|
|
388
|
+
assert_equal(event_time("2019-02-01 12:34:56 +0100"), time)
|
389
|
+
assert_equal({ "message" => "This is test" }, record)
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
test "multiple timezone" do
|
394
|
+
d = create_driver(%[
|
395
|
+
<grok>
|
396
|
+
pattern %{TIMESTAMP_ISO8601:time} 1 %{GREEDYDATA:message}
|
397
|
+
time_key time
|
398
|
+
time_format %Y-%m-%d %H:%M:%S
|
399
|
+
timezone Europe/Berlin
|
400
|
+
</grok>
|
401
|
+
<grok>
|
402
|
+
pattern %{TIMESTAMP_ISO8601:time} 2 %{GREEDYDATA:message}
|
403
|
+
time_key time
|
404
|
+
time_format %Y-%m-%d %H:%M:%S
|
405
|
+
timezone Asia/Aden
|
406
|
+
</grok>
|
407
|
+
])
|
408
|
+
d.instance.parse("2019-02-01 12:34:56 1 This is test") do |time, record|
|
409
|
+
assert_equal(event_time("2019-02-01 12:34:56 +0100"), time)
|
410
|
+
assert_equal({ "message" => "This is test" }, record)
|
411
|
+
end
|
412
|
+
d.instance.parse("2019-02-01 12:34:56 2 This is test") do |time, record|
|
413
|
+
assert_equal(event_time("2019-02-01 12:34:56 +0300"), time)
|
414
|
+
assert_equal({ "message" => "This is test" }, record)
|
415
|
+
end
|
416
|
+
end
|
350
417
|
end
|
351
418
|
|
352
419
|
private
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-grok-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kiyoto
|
8
8
|
- Kenji Okimoto
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2'
|
76
|
-
description:
|
76
|
+
description:
|
77
77
|
email:
|
78
78
|
- kiyoto@treasure-data.com
|
79
79
|
- okimoto@clear-code.com
|
@@ -123,7 +123,7 @@ homepage: https://github.com/fluent/fluent-plugin-grok-parser
|
|
123
123
|
licenses:
|
124
124
|
- Apache-2.0
|
125
125
|
metadata: {}
|
126
|
-
post_install_message:
|
126
|
+
post_install_message:
|
127
127
|
rdoc_options: []
|
128
128
|
require_paths:
|
129
129
|
- lib
|
@@ -138,9 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
141
|
+
rubygems_version: 3.1.2
|
142
|
+
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: Fluentd plugin to support Logstash-inspired Grok format for parsing logs
|
146
145
|
test_files:
|