-
-
Save vaquarkhan/640121a95a9f96e3cef0304e1aae88ab to your computer and use it in GitHub Desktop.
Python re for Nginx access_log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Modified by adding names from https://github.com/richardasaurus/nginx-access-log-parser/blob/master/main.py | |
| pat = (r'' | |
| '(?P<ip>\d+.\d+.\d+.\d+)\s-\s-\s' #IP address | |
| '\[(?P<time>.+)\]\s' #datetime | |
| '"(?P<method>GET|POST)\s(?P<uri>.+)\s(?P<ver>\w+/.+)"\s(?P<status>\d+)\s' #requested file | |
| '(?P<content_length>\d+)\s"(?P<referrer>.+)"\s' #referrer | |
| '"(?P<user_agent>.+)"' #user agent | |
| ) | |
| r = re.match(pat, logline) | |
| r.groupdict() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment