To configure the export of HAProxy events:
haproxy -c -V -f /etc/haproxy/haproxy.cfg
sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy_backup.cfg
sudo vi /etc/haproxy/haproxy.cfg
The next steps of the instructions assume that the same logging settings are applied to all groups of servers. In this case, the logging settings are specified in the global section, and in the defaults, the log global line is used.
If you need a more granular logging configuration, you need to remove the log global line from the defaults section. Because the frontend, backend, and listen sections inherit parameters from the defaults section by default, this will disable global logging. In this case, you need to specify logging settings in each section by adding a line of the following form:
log <IP_address_of_KUMA_collector> [len <length_in_bytes>] [format <syslog_message_format>] [sample <ranges>:<sample_size>] <facility> [<level> [<minimum_level>]]
global section, specify the IP address of the KUMA collector:log <collector_IP_address>:<port>
global section, add the following line to add the host name to the syslog header:log-send-hostname <hostname>
defaults section, add a line to use the global logging settings:log global
defaults section, specify the logging format:option tcplog
option httplog
frontend or listen section:capture request header <header_name> len <header_length_in_bytes>
Each header must be specified on a separate line, for example:
capture request header User-agent len 50
capture request header Host len 30
capture request header X-Forwarded-For len 15
frontend or listen section:capture response header <header_name> len <header_length_in_bytes>
Each header must be specified on a separate line, for example:
capture response header User-agent len 50
capture response header Host len 30
capture response header X-Forwarded-For len 15
frontend or listen section:capture cookie <cookie_name> len <cookie_size_in_bytes>
Only the first cookie with the specified name is logged.
haproxy -c -V -f /etc/haproxy/haproxy.cfg command, as described in step 1 earlier in this article.sudo systemctl reload haproxy
sudo systemctl status haproxy
Event export from HAProxy is configured.
Page top