Regular Expressions 101

Community Patterns

Nginx parse error log msg

0

Regular Expression
Python

r"
^(?P<timestamp>.{19})\ \[(?P<severity>\w{4,6})\] \ \d+\#\d+:\ (\*\d+\ )? (?P<err_msg> (?:\"\S+\"\sis\snot\s)? (?P<err_type>\w+)[\s(] (?:requests,\ excess:\ (?P<err_rate>\d+\.\d+) \ by\ zone\ \"(?P<err_zone>\S+)\" |.+?) ) (?: ,\ client:\ (?P<remote_addr>\d+\.\d+\.\d+\.\d+) ,\ server:\ (?P<server>[^,\a]+) (?:,\ request:\ \"(?P<method>[A-Z]{3,4}?) \ (?P<uri>\/\S*?)(?P<uri_query>\?\S+)? \ (?P<protocol>\S+)\" )? (?:,\ upstream:\ \"(?P<upstream>.+?)\")? (?:,\ host:\ \"(?P<req_host>\S+)\")? (?:,\ referrer:\ \"(?P<referrer>\S+)\")? |) $
"
xs

Description

Loading markdown...
Submitted by diepes - 8 months ago