Skip to content

Commit 1984046

Browse files
authored
Merge pull request #23 from wpoely86/httpd
Enable parsing of apache logs AB#22713
2 parents a88f583 + 9364910 commit 1984046

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

files/apache

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
APACHE_CUSTOM %{IPORHOST:clientip} %{HTTPDUSER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] (?:%{NOTSPACE:ssl_protocol} )?(?:%{NOTSPACE:ssl_cipher} )?"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent}
2+
3+
MY_HTTPD24_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{WORD:module}:%{LOGLEVEL:loglevel}\] \[pid %{POSINT:pid}:tid %{NUMBER:tid}\]( \(%{POSINT:proxy_errorcode}\)%{DATA:proxy_errormessage}:)?( \[client %{IPORHOST:client}:%{POSINT:clientport}\])? %{DATA:errorcode}: %{GREEDYDATA:error_message}
4+
5+
APACHE_MSG %{APACHE_CUSTOM}|%{COMBINEDAPACHELOG}|%{COMMONAPACHELOG}|%{MY_HTTPD24_ERRORLOG}

tests/data/apache

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
data = [
2+
{
3+
"raw": '<14>1 2024-07-12T13:08:02.121560+02:00 aii01 httpd: hyp202.horus.os - - [12/Jul/2024:13:08:02 +0200] TLSv1.3 TLS_AES_256_GCM_SHA384 "GET /profiles/hyp202.horus.os.json.gz HTTP/1.1" 304 - "-" "libwww-perl/6.34"',
4+
"expected": {
5+
'@source_host': 'aii01',
6+
'ssl_protocol': 'TLSv1.3',
7+
'agent': '"libwww-perl/6.34"',
8+
'auth': '-',
9+
'clientip': 'hyp202.horus.os',
10+
'ssl_cipher': 'TLS_AES_256_GCM_SHA384',
11+
'httpversion': '1.1',
12+
'ident': '-',
13+
'program': 'httpd',
14+
'referrer': '"-"',
15+
'request': '/profiles/hyp202.horus.os.json.gz',
16+
'response': '304',
17+
'timestamp': '12/Jul/2024:13:08:02 +0200',
18+
'verb': 'GET',
19+
}
20+
},
21+
{
22+
"raw": '2024-07-12T09:51:06.455130+02:00 aii01 httpd: 10.141.1.36 - - [12/Jul/2024:09:51:06 +0200] - - "GET /scripts/autorun0 HTTP/1.1" 200 1969 "-" "curl/7.61.1"',
23+
"expected": {
24+
'@source_host': 'aii01',
25+
'ssl_protocol': '-',
26+
'ssl_cipher': '-',
27+
'agent': '"curl/7.61.1"',
28+
'auth': '-',
29+
'clientip': '10.141.1.36',
30+
'httpversion': '1.1',
31+
'ident': '-',
32+
'program': 'httpd',
33+
'referrer': '"-"',
34+
'request': '/scripts/autorun0',
35+
'response': '200',
36+
'timestamp': '12/Jul/2024:09:51:06 +0200',
37+
'bytes': '1969',
38+
'verb': 'GET',
39+
}
40+
},
41+
{
42+
"raw": "2024-07-12T13:32:01.648735+02:00 aii01 httpd: [Fri Jul 12 13:32:01.648657 2024] [ssl:error] [pid 1162526:tid 139673653462784] [client 10.141.15.7:56040] AH: verifyclientposthandshake",
43+
"expected": {
44+
"@source_host": "aii01",
45+
"loglevel": "error",
46+
"tid": "139673653462784",
47+
"errorcode": "AH",
48+
"module": "ssl",
49+
"program" :"httpd",
50+
"client": "10.141.15.7",
51+
"clientport": "56040",
52+
"error_message": "verifyclientposthandshake",
53+
}
54+
},
55+
{
56+
"raw": "<179>1 2024-07-16T10:42:21.320640+02:00 storctrl02 httpd: - httpd: [Tue Jul 16 10:42:21.316462 2024] [ssl:info] [pid 2423674:tid 140063287461632] [client 10.127.15.3:50670] AH01964: Connection to child 151 established (server storctrl02.hpc.vub.be:443)",
57+
"expected": {
58+
"@source_host": "storctrl02",
59+
"loglevel": "info",
60+
"tid": "140063287461632",
61+
"errorcode": "AH01964",
62+
"module": "ssl",
63+
"program" :"httpd",
64+
"client": "10.127.15.3",
65+
"error_message": "Connection to child 151 established (server storctrl02.hpc.vub.be:443)",
66+
}
67+
},
68+
]

tests/logstash_7.6.2.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ filter {
1616

1717
match => {
1818
# RSYSLOGCUSTOM always last (and no PREFIX)!
19-
"message" => ["%{RSYSLOGCUSTOMHEADER}%{PIXIU_ALARM}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_BASH}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_NGINX}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_TOMCAT}", "%{RSYSLOGPREFIX}%{PIXIU_APACHE}", "%{RSYSLOGPREFIX}%{SU_MSG}", "%{RSYSLOGPREFIX}%{SUDO_MSG}", "%{RSYSLOGPREFIX}%{REFRAME_MSG}", "%{RSYSLOGPREFIX}%{BASH_MSG}", "%{RSYSLOGPREFIX}%{FAIL2BAN_MSG}", "%{RSYSLOGPREFIX}%{SINGULARITY_MSG}", "%{RSYSLOGPREFIX}%{DHCPD_MSG}", "%{RSYSLOGPREFIX}%{SSH_MSG}", "%{RSYSLOGPREFIX}%{MODULECMD_MSG}", "%{RSYSLOGPREFIX}%{LMOD_MSG}", "%{RSYSLOGPREFIX}%{NFS_MSG}", "%{RSYSLOGPREFIX}%{CEPH_MSG}", "%{RSYSLOGPREFIX}%{OPENNEBULA_MSG}", "%{RSYSLOGPREFIX}%{JUBE_MSG}", "%{RSYSLOGPREFIX}%{SHOREWALL_MSG}", "%{RSYSLOGPREFIX}%{KEYVALUE_MSG}", "%{RSYSLOGPREFIX}%{QUATTOR_MSG}", "%{RSYSLOGPREFIX}%{SNOOPY_MSG}", "%{RSYSLOGCUSTOM}"]
19+
"message" => ["%{RSYSLOGCUSTOMHEADER}%{PIXIU_ALARM}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_BASH}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_NGINX}", "%{RSYSLOGCUSTOMHEADER}%{PIXIU_TOMCAT}", "%{RSYSLOGPREFIX}%{PIXIU_APACHE}", "%{RSYSLOGPREFIX}%{SU_MSG}", "%{RSYSLOGPREFIX}%{SUDO_MSG}", "%{RSYSLOGPREFIX}%{REFRAME_MSG}", "%{RSYSLOGPREFIX}%{BASH_MSG}", "%{RSYSLOGPREFIX}%{FAIL2BAN_MSG}", "%{RSYSLOGPREFIX}%{SINGULARITY_MSG}", "%{RSYSLOGPREFIX}%{DHCPD_MSG}", "%{RSYSLOGPREFIX}%{SSH_MSG}", "%{RSYSLOGPREFIX}%{MODULECMD_MSG}", "%{RSYSLOGPREFIX}%{LMOD_MSG}", "%{RSYSLOGPREFIX}%{NFS_MSG}", "%{RSYSLOGPREFIX}%{CEPH_MSG}", "%{RSYSLOGPREFIX}%{OPENNEBULA_MSG}", "%{RSYSLOGPREFIX}%{JUBE_MSG}", "%{RSYSLOGPREFIX}%{SHOREWALL_MSG}", "%{RSYSLOGPREFIX}%{KEYVALUE_MSG}", "%{RSYSLOGPREFIX}%{QUATTOR_MSG}", "%{RSYSLOGPREFIX}%{SNOOPY_MSG}", "%{RSYSLOGPREFIX}%{APACHE_MSG}", "%{RSYSLOGCUSTOM}"]
2020
}
2121
}
2222

0 commit comments

Comments
 (0)