Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?P<date>[^ ]+) (?P<time>[^ ]+) (?P<process_id>[^ ]+) (?P<level>[^ ]+) (?P<db>[^ ]+) (?P<app>[^:]+): (?P<message>(?P<ip>(?:[0-9]{1,3}\.){3}[0-9]{1,3})(?: - - \[[0-9]{2}\/[A-Za-z]{3}\/[0-9]{4}\s[0-9]+:[0-9]+:[0-9]+\] ")(?P<http>(?:[A-Z]+)) (?P<path>(?:[\/a-z0-9\._]*)) .*" (?P<response>(?:\d{3})) (?:-) (?P<http_size>\d+) (?P<http_time_total>\d+\.\d+) (?P<http_time_>\d+\.\d+)|.*)$
/
gmi

Description

A regex to parse Odoo logs in Loki. If the line is from werkzeug, it will also capture the HTTP data.

Submitted by coopdevs - 2 years ago