logstash-filter-varnishlog 0.1.5 → 0.1.6

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: e0acfb4d454fbb5080fd7f2cbb839e8a9784572e
4
- data.tar.gz: e2ca62597cf53a52a293094a6c11a77d7b0fb13c
3
+ metadata.gz: 132dc667645e4c0ed4ad0923d2e3c663e0b43c1e
4
+ data.tar.gz: d89076af90343002b99b42d7326ffe5e4be15647
5
5
  SHA512:
6
- metadata.gz: dd086fac99e01cc90fd6683a83d55c50bf3d3e8df2f71bf2becf6b12890b7c5baddf57b6494bed55a36b4817dcbeee028621aaa5ecf00d44e70ae56bacf1251f
7
- data.tar.gz: dabe7c7ce47bd0495037c998da197c2a3c43e6af94cabf45f66c1400b1740ccc8396b09c872dafee9f776cd1123d59d829d8cc669ed092dd707dcd65427a5ff9
6
+ metadata.gz: 62741d02b6fcc571b679fd0affb71806c2e5dffea3a2f29c795ea97ec68658089763c676426a96391ec2c4e1e62e34df25c9bcd2863b55619822aa78b8f34b40
7
+ data.tar.gz: cff06e7c4f7b91c6a95b2e4dd8398a5d38b2d5c7f17b72313198f5ca19b3dfd9c73ed77f915ec6cb6b95d3560645f6652b9de7e991973b8bca7f2e76abdc5235
@@ -1,3 +1,8 @@
1
+ ## 0.1.6
2
+ - Make Blacklist Case-Insentive
3
+ - Add normalize_fieldnames option
4
+ TODO: Make Case-Match optional
5
+ Make normalize configurable
1
6
  ## 0.1.5
2
7
  - config to remove blacklisted items from items hash
3
8
  ## 0.1.4
@@ -10,7 +10,7 @@ require "logstash/namespace"
10
10
  ##Extenting array class to to an something like grep -v
11
11
  class Array
12
12
  def grepv(regex, &block)
13
- self.reject { |elem| elem =~ regex }.each(&block)
13
+ self.reject { |elem| elem.match(/#{regex}/i) }.each(&block)
14
14
  end
15
15
  end
16
16
 
@@ -26,28 +26,28 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
26
26
  # }
27
27
  #
28
28
  config_name "varnishlog"
29
-
29
+
30
30
  # Replace the message with this value.
31
31
  #config :message, :validate => :string, :default => "Hello World!"
32
32
  config :blacklist_sections, :validate => :array, :default => []
33
-
33
+ config :normalize_fieldnames, :validate => :boolean, :default => false
34
34
  public
35
35
  def register
36
- # Add instance variables
36
+ # Add instance variables
37
37
  end # def register
38
38
 
39
39
  public
40
40
  def filter(event)
41
41
  items = event.get("[message]").split("\n")
42
42
  ##Remove Blacklisted items from items hash
43
- items = items.grepv(/(#{blacklist_sections.join("|")})/) if blacklist_sections.any?
43
+ items = items.grepv(blacklist_sections.join("|")) if blacklist_sections.any?
44
44
  ##
45
45
 
46
46
  ##timestamps
47
47
  timestamps = items.grep(/Timestamp/)
48
48
  timestamps.each do |timestamp|
49
49
  if match = /-\s+Timestamp\s+(?<step>.*): (?<time_a>.*) (?<time_b>.*) (?<time_c>.*)/.match(timestamp)
50
- event.set("timestamp_" + match['step'], match['time_a'])
50
+ event.set(normalize_fields("timestamp_" + match['step'] ), match['time_a'])
51
51
  end
52
52
  end
53
53
  ## VCL Log
@@ -58,7 +58,7 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
58
58
  log_lines.push(match['log_line'])
59
59
  end
60
60
  if index == log_lines.size - 1
61
- event.set("VCL_Log", log_lines)
61
+ event.set(normalize_fields("VCL_Log"), log_lines)
62
62
  end
63
63
  end
64
64
 
@@ -66,58 +66,58 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
66
66
  ## Request headers.
67
67
  request_headers = items.grep(/ReqHeader/)
68
68
  request_headers.each do |header|
69
- if match = /-\s+ReqHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
70
- event.set(match['header_name'], match['header_value'])
69
+ if match = /-+\s+ReqHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
70
+ event.set(normalize_fields(match['header_name']), match['header_value'])
71
71
  end
72
72
  end
73
73
  ## Match ReqMethod.
74
- if method_match = /-\s+ReqMethod\s+(?<method>.*)/.match(items.grep(/ReqMethod/)[0])
75
- event.set("http-method", method_match['method'])
74
+ if method_match = /-+\s+ReqMethod\s+(?<method>.*)/.match(items.grep(/ReqMethod/)[0])
75
+ event.set("ReqMethod", method_match['method'])
76
76
  end
77
77
  ## Match ReqURL.
78
- if url_match = /-\s+ReqURL\s+(?<url>\/.*)/.match(items.grep(/ReqURL/)[0])
79
- event.set("url", url_match['url'])
78
+ if url_match = /-+\s+ReqURL\s+(?<url>\/.*)/.match(items.grep(/ReqURL/)[0])
79
+ event.set("ReqUrl", url_match['url'])
80
80
  end
81
81
  ## Match ReqProtocol.
82
- if protocol_match = /-\s+ReqProtocol\s+(?<protocol>.*)/.match(items.grep(/ReqProtocol/)[0])
82
+ if protocol_match = /-+\s+ReqProtocol\s+(?<protocol>.*)/.match(items.grep(/ReqProtocol/)[0])
83
83
  event.set("ReqProtocol", protocol_match['protocol'])
84
84
  end
85
-
85
+
86
86
  # Response
87
87
  ## Response headers.
88
88
  response_headers = items.grep(/RespHeader/)
89
89
  response_headers.each do |header|
90
- if match = /-\s+RespHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
91
- event.set(match['header_name'], match['header_value'])
90
+ if match = /-+\s+RespHeader\s+(?<header_name>.*?): (?<header_value>.*)/.match(header)
91
+ event.set(normalize_fields(match['header_name']), match['header_value'])
92
92
  end
93
93
  end
94
94
  ## Match RespProtocol
95
- if protocol_match = /-\s+RespProtocol\s+(?<protocol>.*)/.match(items.grep(/RespProtocol/)[0])
95
+ if protocol_match = /-+\s+RespProtocol\s+(?<protocol>.*)/.match(items.grep(/RespProtocol/)[0])
96
96
  event.set("RespProtocol", protocol_match['protocol'])
97
97
  end
98
98
  ## Match RespStatus
99
99
  status_match = items.grep(/RespStatus/)
100
100
  states = []
101
101
  status_match.each_with_index do |status, index|
102
- if match = /-\s+RespStatus\s+(?<status>.*)/.match(status)
103
- states.push(match['status'].to_i)
102
+ if match = /-+\s+RespStatus\s+(?<status>.*)/.match(status)
103
+ states.push(match['status'].to_i)
104
104
  end
105
105
  if index == status_match.size - 1
106
- event.set("RespStatus", states)
106
+ event.set("RespStatus", states)
107
107
  end
108
108
  end
109
109
  ## Match RespReason
110
110
  response_reason = items.grep(/RespReason/)
111
111
  reasons = []
112
112
  response_reason.each_with_index do |reason, index|
113
- if match = /-\s+RespReason\s+(?<reason>.*)/.match(reason)
114
- reasons.push(match['reason'])
113
+ if match = /-+\s+RespReason\s+(?<reason>.*)/.match(reason)
114
+ reasons.push(match['reason'])
115
115
  end
116
116
  if index == response_reason.size - 1
117
117
  event.set("RespReason", reasons)
118
118
  end
119
119
  end
120
-
120
+
121
121
  if @message
122
122
  # Replace the event message with our message as configured in the
123
123
  # config file.
@@ -127,4 +127,9 @@ class LogStash::Filters::Varnishlog < LogStash::Filters::Base
127
127
  # filter_matched should go in the last line of our successful code
128
128
  filter_matched(event)
129
129
  end # def filter
130
+
131
+ private
132
+ def normalize_fields(name)
133
+ name.capitalize.gsub(/[_-](\w)/){$1.upcase} if @normalize_fieldnames
134
+ end
130
135
  end # class LogStash::Filters::Varnishlog
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-varnishlog'
3
- s.version = '0.1.5'
3
+ s.version = '0.1.6'
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.5
4
+ version: 0.1.6
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-16 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement