How do I enable logging for haproxy load balancer in my RHEL-OSP environment?
Environment
- Red Hat Enterprise Linux OpenStack Platform 6.0
- Red Hat Enterprise Linux OpenStack Platform 7.0
- Red Hat OpenStack Platform 8.0
Issue
- I am running a highly available RHEL-OSP environment deployed by RHEL-OSP-INSTALLER. This uses haproxy to load balance requests to API end points and haproxy seems to drop some connections. How can I enable logging for haproxy to get more details on why this happens?
Resolution
- Remove
noticefrom the following line in your haproxy.cfg (in older versions of haproxy)
log 127.0.0.1 local3 notice
For haproxy >= 1.5 and for global logging
global
(...)
log 127.0.0.1 local3
defaults
(...)
option tcplog
Add the 'option tcplog' for detailed logging information.
Or for a specific service in haproxy >= 1.5
listen horizon
(...)
option tcplog
log 127.0.0.1 local3
(...)
Make sure that
option httplogis set to troubleshoot http(s) connections
- Enable the following lines of /etc/rsyslog.conf :
$ModLoad imudp
$UDPServerRun 514
- Create a haproxy.conf file under /etc/rsyslog.d/ :
# cat >> /etc/rsyslog.d/haproxy.conf << EOF
local3.* /var/log/haproxy.log
EOF
- Create the log file :
# touch /var/log/haproxy.log
- Restart rsyslog and haproxy
# systemctl restart rsyslog
# systemctl restart haproxy
-
You should now see things logged under haproxy.log. The following links describe the format used in more detail :
Content from cbonte.github.io is not included.http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#8.2.2
Content from cbonte.github.io is not included.http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#8.5
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.