#!/bin/sh
# sample script to show last 10 minutes from haproxy log with custom logging
file=/var/log/haproxy.log;
export LANG=en_US.UTF8;
# haproxy.cfg logging configuration

#        option tcplog
#        log global
#        log-format [%t]\ %ci:%cp\ %bi:%bp\ %b/%s:%sp\ %Tw/%Tc/%Tt\ %B\ %ts\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq

##Jan  7 14:09:00 pcfreak haproxy[1585]: [07/Jan/2022:14:09:00.889] 1.14.96.240:65234 192.168.0.1:19334 http-websrv/ha1server-2:80 1/0/+0 +0 -- 7/2/2/2/0 0/0
##Jan  7 14:09:00 pcfreak haproxy[1585]: [07/Jan/2022:14:09:00.889] 1.14.96.240:65234 192.168.0.1:19334 http-websrv/ha1server-2:80 1/0/+0 +0 -- 7/2/2/2/0 0/0

logformat='%d/%b/%Y:%H:%M:%S';
#logformat='%d/%b/%Y';
awk -vDate=`date -d'now-10 minutes' +[%d/%b/%Y:%H:%M:%S` '$4 > Date {print Date, $0}' $file

