logstash-filter-varnishlog 0.1.7 → 0.2.2

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: b5bad4a2635a7e8d23f99156c2bb9d7dda5ab37b
4
- data.tar.gz: 3336e14b86616bf2ea870769eecc06851f26ed4f
2
+ SHA256:
3
+ metadata.gz: aab6611b3c969096dc49e9e27731f8058e81bda20087fc113d4949c6c0700fda
4
+ data.tar.gz: bef79f350873bbe4308c46bc6531e548bc93f030c4f58ef575ef0eb9344d6e45
5
5
  SHA512:
6
- metadata.gz: 92d81615cc6f94db12c8dbf769922a0b9ab6f21c7d4f7d29169ea3395c6151caf6bbfdb921c819541050da4504bcb4675f7240c9eeb175fc319c5f490d1b0baf
7
- data.tar.gz: 685985a711e67a5d8e1686493731b26e964f939840110d168cebbc620c6609dc8e2b278d4ab2879df9530bbf95e67a86664254f3984c3a1cd3292e983651f694
6
+ metadata.gz: 958ce2506c3154fa5ca4c1773e72e7f9e84732c110c4c7731049a9eebbd5f72fef15cce140c88ddb1a429887337692b5a12e5ae6025b8783b3344808d64a579a
7
+ data.tar.gz: ecf5c95d35d200ef55926cb338d97751bb130eb3f311939606169340be3921674ff1ca96ee2faeacb14ae28d12d282cb84718a1fd232e24ba6b0392ce9c8e588
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.2.2
2
+ - Fix Header detection to match only valid Header names regex:[\w-], instead all .+ characters
3
+ ## 0.2.1
4
+ - Add xid and begin line
5
+ - regex performance
6
+ ## 0.2.0
7
+ - Make better RegEx Patterns
8
+ ## 0.1.9
9
+ - Add Raw Timestamps
10
+ ## 0.1.8
11
+ - Fix Acct
12
+ - Add Fetch Error
1
13
  ## 0.1.7
2
14
  - Refactor regex parser
3
15
  ## 0.1.6
@@ -39,9 +39,16 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
39
39
  public
40
40
  def filter(event)
41
41
  items = event.get("[message]").split("\n")
42
- if request=/\*+\s+<<\s+(?<type>\w+)\s+>>\s+/.match(items[0])
42
+ if request=/\*+\s+<<\s+(?<type>\w+)\s+>>\s+(?<xid>\d+)/.match(items[0])
43
43
  event.set("type", request['type'].downcase)
44
+ event.set("xid", request['xid'])
44
45
  end
46
+
47
+ ##Begin
48
+ if first=/-+\s+Begin\s+(?<id>\w+\s\d+\s\w+)/.match(items[1])
49
+ event.set("begin", first['id'])
50
+ end
51
+
45
52
  ##Remove Blacklisted items from items hash
46
53
  items = items.grepv(blacklist_sections.join("|")) if blacklist_sections.any?
47
54
  ##
@@ -49,15 +56,16 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
49
56
  ##timestamps
50
57
  timestamps = items.grep(/Timestamp/)
51
58
  timestamps.each do |timestamp|
52
- if match = /-\s+Timestamp\s+(?<step>.*): (?<time_a>.*) (?<time_b>.*) (?<time_c>.*)/.match(timestamp)
59
+ if match = /-{1,2}\s+Timestamp\s+(?<step>\w{3,10}): (?<time_a>\d{10}\.\d{6}) (?<time_b>(0|\d+)\.\d{6}) (?<time_c>(0|\d+)\.\d{6})/.match(timestamp)
53
60
  event.set(normalize_fields("timestamp_" + match['step'] ), match['time_a'])
61
+ event.set(normalize_fields("timestamp_" + match['step'] + "_raw"), match['time_a'] + " " + match['time_b'] + " " + match['time_c'])
54
62
  end
55
63
  end
56
64
 
57
65
  ##Acct
58
66
  account = items.grep(/(Be|Req)Acct/)
59
67
  account.each do |acct|
60
- if acct_match = /-\s+(Be|Req)Acct\s+(?<size_a>\d)\s+(?<size_b>\d)\s+(?<size_c>\d)\s+(?<size_d>\d)\s+(?<size_e>\d)\s+(?<size_f>\d)\s+/.match(acct)
68
+ if acct_match = /-\s+(Be|Req)Acct\s+(?<size_a>\d+)\s+(?<size_b>\d+)\s+(?<size_c>\d+)\s+(?<size_d>\d+)\s+(?<size_e>\d+)\s+(?<size_f>\d+)/.match(acct)
61
69
  event.set("bytes", acct_match['size_e'])
62
70
  end
63
71
  end
@@ -65,7 +73,7 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
65
73
  vcl_log = items.grep(/VCL_Log/)
66
74
  log_lines = []
67
75
  vcl_log.each_with_index do |log, index|
68
- if match = /-\s+VCL_Log\s+(?<log_line>.*)/.match(log)
76
+ if match = /-\s+VCL_Log\s+(?<log_line>.+)/.match(log)
69
77
  log_lines.push(match['log_line'])
70
78
  end
71
79
  if index == log_lines.size - 1
@@ -75,30 +83,33 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
75
83
 
76
84
  # Requests
77
85
  ## Request headers.
78
- request_headers = items.grep(/(Be)?([rR]eq|[rR]esp)Header/)
86
+ request_headers = items.grep(/(Bereq|Req|Beresp|Resp)Header/)
79
87
  request_headers.each do |header|
80
- if match = /-+\s+(Be)?([rR]eq|[rR]esp)Header\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
88
+ if match = /-+\s+(Bereq|Req|Beresp|Resp)Header\s+(?<header_name>[\w-]+): (?<header_value>.*)/.match(header)
81
89
  event.set(normalize_fields(match['header_name']), match['header_value'])
82
90
  end
83
91
  end
84
92
  ## Match ReqMethod.
85
- if method_match = /-+\s+(Be)?([rR]eq|[rR]esp)Method\s+(?<method>.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)Method/)[0])
93
+ if method_match = /-+\s+(Bereq|Req|Beresp|Resp)Method\s+(?<method>.+)/.match(items.grep(/(Bereq|Req|Beresp|Resp)Method/)[0])
86
94
  event.set("http_method", method_match['method'])
87
95
  end
88
96
  ## Match ReqURL.
89
- if url_match = /-+\s+(Be)?([rR]eq|[rR]esp)URL\s+(?<url>\/.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)URL/)[0])
97
+ if url_match = /-+\s+(Bereq|Req|Beresp|Resp)URL\s+(?<url>\/.+)/.match(items.grep(/(Bereq|Req|Beresp|Resp)URL/)[0])
90
98
  event.set("url", url_match['url'])
91
99
  end
92
100
  ## Match ReqProtocol.
93
- if protocol_match = /-+\s+(Be)?([rR]eq|[rR]esp)Protocol\s+(?<protocol>.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)Protocol/)[0])
101
+ if protocol_match = /-+\s+(Bereq|Req|Beresp|Resp)Protocol\s+(?<protocol>.+)/.match(items.grep(/(Bereq|Req|Beresp|Resp)Protocol/)[0])
94
102
  event.set("protocol", protocol_match['protocol'])
95
103
  end
96
-
104
+ ## FetchError.
105
+ if error_match = /-+\s+FetchError\s+(?<error>.+)/.match(items.grep(/FetchError/)[0])
106
+ event.set("FetchError", error_match['error'])
107
+ end
97
108
  ## Match RespStatus
98
- status_match = items.grep(/(Be)?([rR]eq|[rR]esp)Status/)
109
+ status_match = items.grep(/(Bereq|Req|Beresp|Resp)Status/)
99
110
  states = []
100
111
  status_match.each_with_index do |status, index|
101
- if match = /-+\s+(Be)?([rR]eq|[rR]esp)Status\s+(?<status>.*)/.match(status)
112
+ if match = /-+\s+(Bereq|Req|Beresp|Resp)Status\s+(?<status>\d{3})/.match(status)
102
113
  states.push(match['status'].to_i)
103
114
  end
104
115
  if index == status_match.size - 1
@@ -106,10 +117,10 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
106
117
  end
107
118
  end
108
119
  ## Match RespReason
109
- response_reason = items.grep(/(Be)?([rR]eq|[rR]esp)Reason/)
120
+ response_reason = items.grep(/(Bereq|Req|Beresp|Resp)Reason/)
110
121
  reasons = []
111
122
  response_reason.each_with_index do |reason, index|
112
- if match = /-+\s+(Be)?([rR]eq|[rR]esp)Reason\s+(?<reason>.*)/.match(reason)
123
+ if match = /-+\s+(Bereq|Req|Beresp|Resp)Reason\s+(?<reason>.+)/.match(reason)
113
124
  reasons.push(match['reason'])
114
125
  end
115
126
  if index == response_reason.size - 1
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-varnishlog'
3
- s.version = '0.1.7'
3
+ s.version = '0.2.2'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'A logstash plugin reading varnishlog output'
6
6
  s.description = 'logstash filter plugin reading varnishlog grouped by id'
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-varnishlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Herweg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - ~>
16
+ - - "~>"
17
17
  - !ruby/object:Gem::Version
18
18
  version: '2.0'
19
19
  name: logstash-core-plugin-api
@@ -21,13 +21,13 @@ dependencies:
21
21
  type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  name: logstash-devutils
@@ -35,7 +35,7 @@ dependencies:
35
35
  type: :development
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: logstash filter plugin reading varnishlog grouped by id
@@ -80,17 +80,17 @@ require_paths:
80
80
  - lib
81
81
  required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.4.5
93
+ rubygems_version: 2.6.13
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: A logstash plugin reading varnishlog output