Skip to content

Commit d8fcd88

Browse files
committed
do not match apache access response code if empty "-"
1 parent 3059d19 commit d8fcd88

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

patterns/httpd

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ HTTPDUSER %{EMAILADDRESS}|%{USER}
22
HTTPDERROR_DATE %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{YEAR}
33

44
# Log formats
5-
HTTPD_COMMONLOG %{IPORHOST:clientip} (?:-|%{HTTPDUSER:ident}) (?:-|%{HTTPDUSER:auth}) \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-)
5+
HTTPD_COMMONLOG %{IPORHOST:clientip} (?:-|%{HTTPDUSER:ident}) (?:-|%{HTTPDUSER:auth}) \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" (?:-|%{NUMBER:response}) (?:-|%{NUMBER:bytes})
66
HTTPD_COMBINEDLOG %{HTTPD_COMMONLOG} %{QS:referrer} %{QS:agent}
77

88
# Error logs

spec/patterns/httpd_spec.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,26 @@
3434

3535
let(:message) { '10.0.0.1 - username@example.com [07/Apr/2016:18:42:24 +0000] "GET /bar/foo/users/1/username%40example.com/authenticate?token=blargh&client_id=15 HTTP/1.1" 400 75 "" "Mozilla/5.0 (iPad; CPU OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1"'}
3636

37-
it "generates the clientip field" do
37+
it "gets captured" do
3838
expect(grok).to include("auth" => "username@example.com")
3939
end
4040

4141
end
4242

43+
context 'sample OPTIONS line' do
44+
45+
let(:message) { '83.149.9.216 - a.user [11/Jan/2020:23:05:27 +0100] "OPTIONS /remote.php/ HTTP/1.1" - 7908 "-" "monitoring-client (v2.2)"' }
46+
47+
it 'matches' do
48+
expect(grok).to include("verb" => "OPTIONS", 'request' => '/remote.php/', 'httpversion' => '1.1', "bytes" => '7908')
49+
end
50+
51+
it 'does not capture optional response code' do
52+
expect(grok.keys).to_not include("response")
53+
end
54+
55+
end
56+
4357
end
4458

4559
describe "HTTPD_ERRORLOG" do

0 commit comments

Comments
 (0)