# HAProxy log formats: https://docs.haproxy.org/ configuration manual, "Logging", the TCP and HTTP log formats.
# Accept date `dd/Mon/yyyy:hh:mm:ss.mmm`.
HAPROXYTIME %{HOUR:haproxy_hour}:%{MINUTE:haproxy_minute}:(?<haproxy_second>[0-5][0-9]|60)
HAPROXYDATE %{MONTHDAY:haproxy_monthday}/%{MONTH:haproxy_month}/%{YEAR:haproxy_year}:%{HAPROXYTIME:haproxy_time}\.%{INT:haproxy_milliseconds}
# The text between braces after the queue counts, one brace pair for request headers and one for response headers. Redefine these to split the headers `capture request header` lists, which are `|` separated.
HAPROXYCAPTUREDREQUESTHEADERS (?<captured_request_headers>[^}]*)
HAPROXYCAPTUREDRESPONSEHEADERS (?<captured_response_headers>[^}]*)
# httplog: `client:port [accept] frontend backend/server Tq/Tw/Tc/Tr/Ta status bytes req-cookie resp-cookie flags actconn/feconn/beconn/srvconn/retries srv_queue/backend_queue {req headers} {resp headers} "request"`.
# A request that never parsed is logged as `<BADREQ>`. A cookie or header that wasn't captured is `-`.
HAPROXYHTTPBASE %{IP:client_ip}:%{INT:client_port} \[%{HAPROXYDATE:accept_date}\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:time_request}/%{INT:time_queue}/%{INT:time_backend_connect}/%{INT:time_backend_response}/%{NOTSPACE:time_duration} %{INT:http_status_code} %{NOTSPACE:bytes_read} %{NOTSPACE:captured_request_cookie} %{NOTSPACE:captured_response_cookie} %{NOTSPACE:termination_state} %{INT:actconn}/%{INT:feconn}/%{INT:beconn}/%{INT:srvconn}/%{NOTSPACE:retries} %{INT:srv_queue}/%{INT:backend_queue} (?:\{%{HAPROXYCAPTUREDREQUESTHEADERS}\})? ?(?:\{%{HAPROXYCAPTUREDRESPONSEHEADERS}\})? ?"(?:<BADREQ>|%{WORD:http_verb} (?:%{URIPROTO:http_proto}://)?(?:%{USER:http_user}(?::[^@]*)?@)?(?:%{URIHOST:http_host})?(?:%{URIPATHPARAM:http_request})?(?: HTTP/%{NUMBER:http_version})?)?"?
HAPROXYHTTP (?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:timestamp8601}) %{IPORHOST:syslog_server} %{SYSLOGPROG}: %{HAPROXYHTTPBASE}
# tcplog: `client:port [accept] frontend backend/server Tw/Tc/Tt bytes flags actconn/feconn/beconn/srvconn/retries srv_queue/backend_queue`.
HAPROXYTCP (?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:timestamp8601}) %{IPORHOST:syslog_server} %{SYSLOGPROG}: %{IP:client_ip}:%{INT:client_port} \[%{HAPROXYDATE:accept_date}\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:time_queue}/%{INT:time_backend_connect}/%{NOTSPACE:time_duration} %{NOTSPACE:bytes_read} %{NOTSPACE:termination_state} %{INT:actconn}/%{INT:feconn}/%{INT:beconn}/%{INT:srvconn}/%{NOTSPACE:retries} %{INT:srv_queue}/%{INT:backend_queue}