Configuring export of HAProxy events

To configure the export of HAProxy events:

  1. Check the configuration file for any syntax errors by running the following command:

    haproxy -c -V -f /etc/haproxy/haproxy.cfg

    Possible messages when checking the configuration file

  2. If the syntax check is successful, back up the original configuration file using the following command:

    sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy_backup.cfg

  3. Open the haproxy.cfg configuration file by running the following command:

    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>]]

  4. In the global section, specify the IP address of the KUMA collector:

    log <collector_IP_address>:<port>​

  5. In the global section, add the following line to add the host name to the syslog header:

    log-send-hostname <hostname>

  6. In the defaults section, add a line to use the global logging settings:

    log global

  7. In the defaults section, specify the logging format:
    • For layer 4 balancers (TCP):

      option tcplog

      Example of a defaults section with settings

    • For layer 7 balancers (HTTP):

      option httplog

      Example of a defaults section with settings

  8. If you want to enable logging of HTTP request headers, add the following line to the 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

  9. If you want to enable logging of HTTP response headers, add the following line to the 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

  10. If you want to enable logging of HTTP-cookies, add the following line to the frontend or listen section:

    capture cookie <cookie_name> len <cookie_size_in_bytes>

    Only the first cookie with the specified name is logged.

  11. Check the configuration file for syntax errors using the haproxy -c -V -f /etc/haproxy/haproxy.cfg command, as described in step 1 earlier in this article.
  12. Reload the configuration by running the following command:

    sudo systemctl reload haproxy

  13. Verify that the HAProxy load balancer has started and is operating normally by running the following command:

    sudo systemctl status haproxy

Event export from HAProxy is configured.

Page top