Skip to content

Commit 687c0d2

Browse files
committed
Add support for varnishncsa format.
It is similar to ncsa_extended but has protocol and hostname inside the request. https://varnish-cache.org/docs/7.5/reference/varnishncsa.html#notes
1 parent b91a5c5 commit 687c0d2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

import_logs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ def get(self, key):
595595
)
596596

597597

598+
_VARNISH_NCSA_LOG_FORMAT = (
599+
r'(?P<ip>[\w*.:-]+)\s+\S+\s+(?P<userid>\S+)\s+\[(?P<date>.*?)\s+(?P<timezone>.*?)\]\s+'
600+
r'"(?P<method>\S+)\s+(?P<protocol>https?)://(?P<host>[^/]+)(?P<path>.*?)\s+\S+"\s+(?P<status>\d+)\s+(?P<length>\S+)'
601+
r'\s+"(?P<referrer>.*?)"\s+"(?P<user_agent>.*?)"'
602+
)
603+
598604
_S3_LOG_FORMAT = (
599605
r'\S+\s+(?P<host>\S+)\s+\[(?P<date>.*?)\s+(?P<timezone>.*?)\]\s+(?P<ip>[\w*.:-]+)\s+'
600606
r'(?P<userid>\S+)\s+\S+\s+\S+\s+\S+\s+"(?P<method>\S+)\s+(?P<path>.*?)\s+\S+"\s+(?P<status>\d+)\s+\S+\s+(?P<length>\S+)\s+'
@@ -628,6 +634,7 @@ def get(self, key):
628634
'common_vhost': RegexFormat('common_vhost', _HOST_PREFIX + _COMMON_LOG_FORMAT),
629635
'ncsa_extended': RegexFormat('ncsa_extended', _NCSA_EXTENDED_LOG_FORMAT),
630636
'common_complete': RegexFormat('common_complete', _HOST_PREFIX + _NCSA_EXTENDED_LOG_FORMAT),
637+
'varnishncsa': RegexFormat('varnishncsa', _VARNISH_NCSA_LOG_FORMAT),
631638
'w3c_extended': W3cExtendedFormat(),
632639
'amazon_cloudfront': AmazonCloudFrontFormat(),
633640
'incapsula_w3c': IncapsulaW3CFormat(),

0 commit comments

Comments
 (0)