logstash-filter-varnishlog 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 132dc667645e4c0ed4ad0923d2e3c663e0b43c1e
4
- data.tar.gz: d89076af90343002b99b42d7326ffe5e4be15647
3
+ metadata.gz: b5bad4a2635a7e8d23f99156c2bb9d7dda5ab37b
4
+ data.tar.gz: 3336e14b86616bf2ea870769eecc06851f26ed4f
5
5
  SHA512:
6
- metadata.gz: 62741d02b6fcc571b679fd0affb71806c2e5dffea3a2f29c795ea97ec68658089763c676426a96391ec2c4e1e62e34df25c9bcd2863b55619822aa78b8f34b40
7
- data.tar.gz: cff06e7c4f7b91c6a95b2e4dd8398a5d38b2d5c7f17b72313198f5ca19b3dfd9c73ed77f915ec6cb6b95d3560645f6652b9de7e991973b8bca7f2e76abdc5235
6
+ metadata.gz: 92d81615cc6f94db12c8dbf769922a0b9ab6f21c7d4f7d29169ea3395c6151caf6bbfdb921c819541050da4504bcb4675f7240c9eeb175fc319c5f490d1b0baf
7
+ data.tar.gz: 685985a711e67a5d8e1686493731b26e964f939840110d168cebbc620c6609dc8e2b278d4ab2879df9530bbf95e67a86664254f3984c3a1cd3292e983651f694
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## 0.1.7
2
+ - Refactor regex parser
1
3
  ## 0.1.6
2
4
  - Make Blacklist Case-Insentive
3
5
  - Add normalize_fieldnames option
@@ -39,6 +39,9 @@ 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])
43
+ event.set("type", request['type'].downcase)
44
+ end
42
45
  ##Remove Blacklisted items from items hash
43
46
  items = items.grepv(blacklist_sections.join("|")) if blacklist_sections.any?
44
47
  ##
@@ -50,6 +53,14 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
50
53
  event.set(normalize_fields("timestamp_" + match['step'] ), match['time_a'])
51
54
  end
52
55
  end
56
+
57
+ ##Acct
58
+ account = items.grep(/(Be|Req)Acct/)
59
+ 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)
61
+ event.set("bytes", acct_match['size_e'])
62
+ end
63
+ end
53
64
  ## VCL Log
54
65
  vcl_log = items.grep(/VCL_Log/)
55
66
  log_lines = []
@@ -64,57 +75,45 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
64
75
 
65
76
  # Requests
66
77
  ## Request headers.
67
- request_headers = items.grep(/ReqHeader/)
78
+ request_headers = items.grep(/(Be)?([rR]eq|[rR]esp)Header/)
68
79
  request_headers.each do |header|
69
- if match = /-+\s+ReqHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
80
+ if match = /-+\s+(Be)?([rR]eq|[rR]esp)Header\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
70
81
  event.set(normalize_fields(match['header_name']), match['header_value'])
71
82
  end
72
83
  end
73
84
  ## Match ReqMethod.
74
- if method_match = /-+\s+ReqMethod\s+(?<method>.*)/.match(items.grep(/ReqMethod/)[0])
75
- event.set("ReqMethod", method_match['method'])
85
+ if method_match = /-+\s+(Be)?([rR]eq|[rR]esp)Method\s+(?<method>.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)Method/)[0])
86
+ event.set("http_method", method_match['method'])
76
87
  end
77
88
  ## Match ReqURL.
78
- if url_match = /-+\s+ReqURL\s+(?<url>\/.*)/.match(items.grep(/ReqURL/)[0])
79
- event.set("ReqUrl", url_match['url'])
89
+ if url_match = /-+\s+(Be)?([rR]eq|[rR]esp)URL\s+(?<url>\/.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)URL/)[0])
90
+ event.set("url", url_match['url'])
80
91
  end
81
92
  ## Match ReqProtocol.
82
- if protocol_match = /-+\s+ReqProtocol\s+(?<protocol>.*)/.match(items.grep(/ReqProtocol/)[0])
83
- event.set("ReqProtocol", protocol_match['protocol'])
93
+ if protocol_match = /-+\s+(Be)?([rR]eq|[rR]esp)Protocol\s+(?<protocol>.*)/.match(items.grep(/(Be)?([rR]eq|[rR]esp)Protocol/)[0])
94
+ event.set("protocol", protocol_match['protocol'])
84
95
  end
85
96
 
86
- # Response
87
- ## Response headers.
88
- response_headers = items.grep(/RespHeader/)
89
- response_headers.each do |header|
90
- if match = /-+\s+RespHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
91
- event.set(normalize_fields(match['header_name']), match['header_value'])
92
- end
93
- end
94
- ## Match RespProtocol
95
- if protocol_match = /-+\s+RespProtocol\s+(?<protocol>.*)/.match(items.grep(/RespProtocol/)[0])
96
- event.set("RespProtocol", protocol_match['protocol'])
97
- end
98
97
  ## Match RespStatus
99
- status_match = items.grep(/RespStatus/)
98
+ status_match = items.grep(/(Be)?([rR]eq|[rR]esp)Status/)
100
99
  states = []
101
100
  status_match.each_with_index do |status, index|
102
- if match = /-+\s+RespStatus\s+(?<status>.*)/.match(status)
101
+ if match = /-+\s+(Be)?([rR]eq|[rR]esp)Status\s+(?<status>.*)/.match(status)
103
102
  states.push(match['status'].to_i)
104
103
  end
105
104
  if index == status_match.size - 1
106
- event.set("RespStatus", states)
105
+ event.set("http-rc", states)
107
106
  end
108
107
  end
109
108
  ## Match RespReason
110
- response_reason = items.grep(/RespReason/)
109
+ response_reason = items.grep(/(Be)?([rR]eq|[rR]esp)Reason/)
111
110
  reasons = []
112
111
  response_reason.each_with_index do |reason, index|
113
- if match = /-+\s+RespReason\s+(?<reason>.*)/.match(reason)
112
+ if match = /-+\s+(Be)?([rR]eq|[rR]esp)Reason\s+(?<reason>.*)/.match(reason)
114
113
  reasons.push(match['reason'])
115
114
  end
116
115
  if index == response_reason.size - 1
117
- event.set("RespReason", reasons)
116
+ event.set("reason", reasons)
118
117
  end
119
118
  end
120
119
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-varnishlog'
3
- s.version = '0.1.6'
3
+ s.version = '0.1.7'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-varnishlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
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-03-20 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement