fluent-plugin-grok-parser 2.1.4 → 2.1.5

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: c9d0d19c4e14ddb6d20cc30fce51ad12e8fc7b35
4
- data.tar.gz: 9d74e54424dde5bc2db237c9c3472ddb74119005
2
+ SHA256:
3
+ metadata.gz: 6d4b24f282982ed42f113abab9b094bba14f27354f1040956329986a53257f13
4
+ data.tar.gz: 421fb6798ce3c8636bd2258bf8a252eef1fe01025203cb9bd3017950b8541948
5
5
  SHA512:
6
- metadata.gz: 4ef02c0f2168481e7cb4dca8285f26ce350ea602b315fcec73a51cf74e96aa187a628f0693f99b7d6639474b06d81742c79b1a43780afd4e5e78eb83a748f88b
7
- data.tar.gz: 23e27a34ef129cdbd290a95d6f5f37313e4f1da86295e5304f3fb94459e13e71b52e2c493940df55ebf520ce57499e4a0755e8ce70802b983d28f68e241f22ae
6
+ metadata.gz: dee3c7bd1c321166dffa95cf65a001e8f066e2eafe745e928eab1b0c6e191a5ba4c2f21710f5ecb61f583571a029dd0c25cf187d8da98c746e5e830877c51c64
7
+ data.tar.gz: 4250e3d3f0b79c36f1993e2c27bfcc0258b2a69abb2ddad7765fdbdbe879d1eae9bbafdd3a9d1111c6094718dcda6d4b137df6ada6441cba89221f461a4dff95
data/Rakefile CHANGED
@@ -20,6 +20,42 @@ task "patterns:import" do
20
20
  cp(pattern, "patterns/", verbose: true)
21
21
  end
22
22
  end
23
+
24
+ # copied from "./lib/fluent/plugin/grok"
25
+ pattern_re =
26
+ /%\{ # match '%{' not prefixed with '\'
27
+ (?<name> # match the pattern name
28
+ (?<pattern>[A-z0-9]+)
29
+ (?::(?<subname>[@\[\]A-z0-9_:.-]+?)
30
+ (?::(?<type>(?:string|bool|integer|float|int|
31
+ time(?::.+)?|
32
+ array(?::.)?)))?)?
33
+ )
34
+ \}/x
35
+
36
+ Dir.glob("patterns/*") do |pattern_file|
37
+ new_lines = ""
38
+ File.readlines(pattern_file).each do |line|
39
+ case
40
+ when line.strip.empty?
41
+ new_lines << line
42
+ when line.start_with?("#")
43
+ new_lines << line
44
+ else
45
+ name, pattern = line.split(/\s+/, 2)
46
+ new_pattern = pattern.gsub(pattern_re) do |m|
47
+ matched = $~
48
+ if matched[:type] == "int"
49
+ "%{#{matched[:pattern]}:#{matched[:subname]}:integer}"
50
+ else
51
+ m
52
+ end
53
+ end
54
+ new_lines << "#{name} #{new_pattern}"
55
+ end
56
+ end
57
+ File.write(pattern_file, new_lines)
58
+ end
23
59
  end
24
60
 
25
61
  task :default => [:test, :build]
data/appveyor.yml ADDED
@@ -0,0 +1,31 @@
1
+ version: '{build}'
2
+ install:
3
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
4
+ - "%devkit%\\devkitvars.bat"
5
+ - ruby --version
6
+ - gem --version
7
+ - bundle install
8
+ build: off
9
+ test_script:
10
+ - bundle exec rake test
11
+
12
+ # https://www.appveyor.com/docs/installed-software/#ruby
13
+ environment:
14
+ matrix:
15
+ - ruby_version: "23-x64"
16
+ devkit: C:\Ruby23-x64\DevKit
17
+ - ruby_version: "23"
18
+ devkit: C:\Ruby23\DevKit
19
+ - ruby_version: "22-x64"
20
+ devkit: C:\Ruby23-x64\DevKit
21
+ - ruby_version: "21-x64"
22
+ devkit: C:\Ruby23-x64\DevKit
23
+ - ruby_version: "22"
24
+ devkit: C:\Ruby23\DevKit
25
+ WIN_RAPID: true
26
+ - ruby_version: "21"
27
+ devkit: C:\Ruby23\DevKit
28
+ WIN_RAPID: true
29
+ matrix:
30
+ allow_failures:
31
+ - 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.1.4"
7
+ spec.version = "2.1.5"
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/patterns/aws CHANGED
@@ -1,6 +1,6 @@
1
1
  S3_REQUEST_LINE (?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})
2
2
 
3
- S3_ACCESS_LOG %{WORD:owner} %{NOTSPACE:bucket} \[%{HTTPDATE:timestamp}\] %{IP:clientip} %{NOTSPACE:requester} %{NOTSPACE:request_id} %{NOTSPACE:operation} %{NOTSPACE:key} (?:"%{S3_REQUEST_LINE}"|-) (?:%{INT:response:int}|-) (?:-|%{NOTSPACE:error_code}) (?:%{INT:bytes:int}|-) (?:%{INT:object_size:int}|-) (?:%{INT:request_time_ms:int}|-) (?:%{INT:turnaround_time_ms:int}|-) (?:%{QS:referrer}|-) (?:"?%{QS:agent}"?|-) (?:-|%{NOTSPACE:version_id})
3
+ S3_ACCESS_LOG %{WORD:owner} %{NOTSPACE:bucket} \[%{HTTPDATE:timestamp}\] %{IP:clientip} %{NOTSPACE:requester} %{NOTSPACE:request_id} %{NOTSPACE:operation} %{NOTSPACE:key} (?:"%{S3_REQUEST_LINE}"|-) (?:%{INT:response:integer}|-) (?:-|%{NOTSPACE:error_code}) (?:%{INT:bytes:integer}|-) (?:%{INT:object_size:integer}|-) (?:%{INT:request_time_ms:integer}|-) (?:%{INT:turnaround_time_ms:integer}|-) (?:%{QS:referrer}|-) (?:"?%{QS:agent}"?|-) (?:-|%{NOTSPACE:version_id})
4
4
 
5
5
  ELB_URIPATHPARAM %{URIPATH:path}(?:%{URIPARAM:params})?
6
6
 
@@ -8,7 +8,7 @@ ELB_URI %{URIPROTO:proto}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST:urihost})?(?:%{
8
8
 
9
9
  ELB_REQUEST_LINE (?:%{WORD:verb} %{ELB_URI:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})
10
10
 
11
- ELB_ACCESS_LOG %{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:elb} %{IP:clientip}:%{INT:clientport:int} (?:(%{IP:backendip}:?:%{INT:backendport:int})|-) %{NUMBER:request_processing_time:float} %{NUMBER:backend_processing_time:float} %{NUMBER:response_processing_time:float} %{INT:response:int} %{INT:backend_response:int} %{INT:received_bytes:int} %{INT:bytes:int} "%{ELB_REQUEST_LINE}"
11
+ ELB_ACCESS_LOG %{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:elb} %{IP:clientip}:%{INT:clientport:integer} (?:(%{IP:backendip}:?:%{INT:backendport:integer})|-) %{NUMBER:request_processing_time:float} %{NUMBER:backend_processing_time:float} %{NUMBER:response_processing_time:float} %{INT:response:integer} %{INT:backend_response:integer} %{INT:received_bytes:integer} %{INT:bytes:integer} "%{ELB_REQUEST_LINE}"
12
12
 
13
- CLOUDFRONT_ACCESS_LOG (?<timestamp>%{YEAR}-%{MONTHNUM}-%{MONTHDAY}\t%{TIME})\t%{WORD:x_edge_location}\t(?:%{NUMBER:sc_bytes:int}|-)\t%{IPORHOST:clientip}\t%{WORD:cs_method}\t%{HOSTNAME:cs_host}\t%{NOTSPACE:cs_uri_stem}\t%{NUMBER:sc_status:int}\t%{GREEDYDATA:referrer}\t%{GREEDYDATA:agent}\t%{GREEDYDATA:cs_uri_query}\t%{GREEDYDATA:cookies}\t%{WORD:x_edge_result_type}\t%{NOTSPACE:x_edge_request_id}\t%{HOSTNAME:x_host_header}\t%{URIPROTO:cs_protocol}\t%{INT:cs_bytes:int}\t%{GREEDYDATA:time_taken:float}\t%{GREEDYDATA:x_forwarded_for}\t%{GREEDYDATA:ssl_protocol}\t%{GREEDYDATA:ssl_cipher}\t%{GREEDYDATA:x_edge_response_result_type}
13
+ CLOUDFRONT_ACCESS_LOG (?<timestamp>%{YEAR}-%{MONTHNUM}-%{MONTHDAY}\t%{TIME})\t%{WORD:x_edge_location}\t(?:%{NUMBER:sc_bytes:integer}|-)\t%{IPORHOST:clientip}\t%{WORD:cs_method}\t%{HOSTNAME:cs_host}\t%{NOTSPACE:cs_uri_stem}\t%{NUMBER:sc_status:integer}\t%{GREEDYDATA:referrer}\t%{GREEDYDATA:agent}\t%{GREEDYDATA:cs_uri_query}\t%{GREEDYDATA:cookies}\t%{WORD:x_edge_result_type}\t%{NOTSPACE:x_edge_request_id}\t%{HOSTNAME:x_host_header}\t%{URIPROTO:cs_protocol}\t%{INT:cs_bytes:integer}\t%{GREEDYDATA:time_taken:float}\t%{GREEDYDATA:x_forwarded_for}\t%{GREEDYDATA:ssl_protocol}\t%{GREEDYDATA:ssl_cipher}\t%{GREEDYDATA:x_edge_response_result_type}
14
14
 
@@ -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]+(\+[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
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
@@ -7,9 +7,9 @@ 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}\]( \(%{POSINT:proxy_errorcode}\)%{DATA:proxy_message}:)?( \[client %{IPORHOST:clientip}:%{POSINT:clientport}\])? %{DATA:errorcode}: %{GREEDYDATA:message}
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}
@@ -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}|-) +(?:%{HOSTNAME:syslog5424_host}|-) +(-|%{SYSLOG5424PRINTASCII:syslog5424_app}) +(-|%{SYSLOG5424PRINTASCII:syslog5424_proc}) +(-|%{SYSLOG5424PRINTASCII:syslog5424_msgid}) +(?:%{SYSLOG5424SD:syslog5424_sd}|-|)
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}
@@ -0,0 +1 @@
1
+ MY_AWESOME_PATTERN %{GREEDYDATA:message}
data/test/helper.rb CHANGED
@@ -2,9 +2,14 @@ require "fluent/test"
2
2
  require "fluent/test/helpers"
3
3
  require "fluent/test/driver/input"
4
4
  require "fluent/test/driver/parser"
5
+ require "pathname"
5
6
 
6
7
  Test::Unit::TestCase.include(Fluent::Test::Helpers)
7
8
 
9
+ def fixtures(name)
10
+ Pathname(__dir__).expand_path + "fixtures" + name
11
+ end
12
+
8
13
  def unused_port
9
14
  s = TCPServer.open(0)
10
15
  port = s.addr[1]
@@ -69,17 +69,9 @@ class GrokParserTest < ::Test::Unit::TestCase
69
69
  end
70
70
 
71
71
  def test_call_for_custom_pattern
72
- pattern_file = File.new(File.expand_path("../my_pattern", __FILE__), "w")
73
- pattern_file.write("MY_AWESOME_PATTERN %{GREEDYDATA:message}\n")
74
- pattern_file.close
75
- begin
76
- internal_test_grok_pattern("%{MY_AWESOME_PATTERN:message}", "this is awesome",
77
- nil, {"message" => "this is awesome"},
78
- "custom_pattern_path" => pattern_file.path
79
- )
80
- ensure
81
- File.delete(pattern_file.path)
82
- end
72
+ internal_test_grok_pattern("%{MY_AWESOME_PATTERN:message}", "this is awesome",
73
+ nil, {"message" => "this is awesome"},
74
+ "custom_pattern_path" => fixtures("my_pattern").to_s)
83
75
  end
84
76
 
85
77
  class OptionalType < self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-grok-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kiyoto
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-03 00:00:00.000000000 Z
12
+ date: 2018-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - LICENSE
82
82
  - README.md
83
83
  - Rakefile
84
+ - appveyor.yml
84
85
  - fluent-plugin-grok-parser.gemspec
85
86
  - lib/fluent/plugin/grok.rb
86
87
  - lib/fluent/plugin/parser_grok.rb
@@ -107,6 +108,7 @@ files:
107
108
  - patterns/redis
108
109
  - patterns/ruby
109
110
  - patterns/squid
111
+ - test/fixtures/my_pattern
110
112
  - test/helper.rb
111
113
  - test/test_grok_parser.rb
112
114
  - test/test_grok_parser_in_tcp.rb
@@ -131,11 +133,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
133
  version: '0'
132
134
  requirements: []
133
135
  rubyforge_project:
134
- rubygems_version: 2.6.4
136
+ rubygems_version: 2.7.4
135
137
  signing_key:
136
138
  specification_version: 4
137
139
  summary: Fluentd plugin to support Logstash-inspired Grok format for parsing logs
138
140
  test_files:
141
+ - test/fixtures/my_pattern
139
142
  - test/helper.rb
140
143
  - test/test_grok_parser.rb
141
144
  - test/test_grok_parser_in_tcp.rb