@@ -168,28 +168,41 @@ filter {
168168
169169
170170 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171- # Parse out fields from Section F (response related, line 1)
171+ # Parse out server protocol/HTTP status from Section F (response related, line 1)
172172 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173173
174- # if the server responded...
175- if [rawSectionF] =~ /.+/ {
174+ # response section (NO headers)
175+ if [rawSectionF] =~ /(.+?)\s(.+?)$/ {
176+
177+
178+ grok {
179+ singles => true
180+ match => {
181+ "rawSectionF" => "(?<serverProtocol>.+?)\s(?<responseStatus>.+)$"
182+ }
183+ patterns_dir => "./patterns/modsecurity_grok_patterns"
184+ }
176185
186+ # response section (WITH headers)
187+ } else if [rawSectionF] =~ /(.+?)\s(.+)\n{1}/ {
188+
177189 grok {
178- match => {
179- "rawSectionF" => "(?<serverProtocol>.+?)\s(?<responseStatus>.+)\n{1}"
180- }
181- patterns_dir => "./patterns/logstash_modsecurity_patterns"
190+ singles => true
191+ match => {
192+ "rawSectionF" => "(?<serverProtocol>.+?)\s(?<responseStatus>.+)\n{1}"
193+ }
194+ patterns_dir => "./patterns/modsecurity_grok_patterns"
182195 }
183196
184- }
197+ }
185198
186199
187200 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188- # Parse out fields from Section F (response headers)
201+ # Parse out response headers from Section F (response headers, lines 2+ )
189202 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190203
191- # only if the server responded...
192- if [rawSectionF] =~ /.+ / {
204+ # only if the server responded...WITH headers...
205+ if [rawSectionF] =~ /(.+?)\s(.+)\n{1} / {
193206
194207 grok {
195208 match => {
0 commit comments