HAProxy Enterprise Documentation 2.3r1

Overview

HAProxy Enterprise stores logs in the /var/log/hapee-2.3 directory.

It stores lb-access log files, which record information about client connections and requests, and lb-admin log files, which record load balancer events such as when a proxy starts or stops.

Enable logging

To enable logging, follow these steps:

  1. Add a log line to the global section in your configuration file.

    global
       # log all events to the local syslog UNIX socket
       log /dev/log local0
    
       # log 'notice' level events and above to a remote syslog server
       log 127.0.0.1 local1 notice

    The log directive takes the following parameters:

    • the IP address of your syslog server or the path to a local syslog UNIX socket (i.e. /dev/log)

    • an optional len <length>, which changes the default length of 1024 characters per log line

    • an optional format <format>, which you can set to rfc3164 (default), rfc5424, short, or raw

    • an optional sample <range>:<size> to capture a sample of the logs (i.e. 1 out of 3 would be sample 1:3)

    • the facility code (usually local0 or, if that is already used, local1)

    • the level of verbosity; choose one of emerg, alert, crit, err, warning, notice, info, or debug. Leave this off to record all events.

  2. In your frontend or defaults section, add a log global directive, which uses the settings you defined with the log directive in the global section.

    defaults
       log global

Default access log format

By default, HAProxy Enterprise logs a predefined set of information about each TCP connection in the access logs.

Jan 27 21:15:06 localhost hapee-lb[2901]: Connect from 192.168.50.1:61459 to 192.168.50.25:80 (fe_main/HTTP)

The information includes:

Field

Example

the PID of the HAProxy Enterprise process

hapee-lb[2901]

the text "Connect from" followed by the client's source IP address and port

Connect from 192.168.50.1:61459

the text "to" followed by the destination IP address and port

to 192.168.50.25:80

the name of the frontend that received the request and the mode (e.g. HTTP)

(fe_main/HTTP)

TCP access log format

If you are using mode tcp in your frontend and backend sections, then you can collect more detailed logs by adding option tcplog to both sections or to your defaults section, as shown below:

defaults
   mode tcp
   option tcplog

After restarting the load balancer, more detailed logs are captured.

Jan 27 21:22:53 localhost hapee-lb[3042]: 192.168.50.1:61535 [27/Jan/2021:21:22:10.944] fe_main be_servers/s1 1/0/42404 2895 cD 1/1/0/0/0 0/0

The information includes:

Field

Example

the PID of the HAProxy Enterprise process

hapee-lb[3042]

the client's source IP address and port

192.168.50.1:61535

the date that the connection was accepted

[27/Jan/2021:21:22:10.944]

the name of the frontend that received the request

fe_main

the name of the backend that received the request, followed by a slash and the name of the server

be_servers/s1

three numbers separated by slashes:

  • milliseconds the connection was queued

  • milliseconds waiting to connect to the backend server

  • milliseconds between accepting the connection and the closing it

1/0/42404

the number of bytes read

2895

the termination state, which is a two-digit letter code that describe how the connection closed

cD

five numbers separated by slashes:

  • number of concurrent connections when the session was logged

  • number of concurrent connections on the frontend when the session was logged

  • number of concurrent connections on the backend when the session was logged

  • number of concurrent connections active on the server when the session was logged

  • number of connection retries to the server

1/1/0/0/0

two numbers separated by a slash:

  • number of requests processed before this one in the server's queue (if using session persistence)

  • number of requests processed before this one in the backend's queue

0/0

HTTP access log format

If you are using mode http in your frontend and backend sections, then you can collect more detailed logs by adding option httplog to both sections or to your defaults section, as shown below:

defaults
   mode http
   option httplog

After restarting the load balancer, more detailed logs are captured.

Jan 27 21:52:56 localhost hapee-lb[3098]: 192.168.50.1:61818 [27/Jan/2021:21:52:56.086] fe_main be_servers/s1 0/0/1/1/2 200 517 - - ---- 1/1/0/0/0 0/0 "GET / HTTP/1.1"

The information includes:

Field

Example

the PID of the HAProxy Enterprise process

hapee-lb[3098]

the client's source IP address and port

192.168.50.1:61818

the date that the connection was accepted

[27/Jan/2021:21:52:56.086]

the name of the frontend that received the request

fe_main

the name of the backend that received the request, followed by a slash and the name of the server

be_servers/s1

five numbers separated by slashes:

  • milliseconds waiting for the full HTTP request to arrive from the client

  • milliseconds the connection was queued

  • milliseconds waiting to connect to the backend server

  • milliseconds waiting for the server to return a response

  • milliseconds the request was active in HAProxy Enterprise

0/0/1/1/2

HTTP status code

200

the number of bytes read

517

captured request cookie values (requires using the older http-request capture cookie directive)

-

captured response cookie values (requires using the older http-response capture cookie directive)

-

the termination state, which is a four-digit letter code that describe how the connection closed

----

five numbers separated by slashes:

  • number of concurrent connections when the session was logged

  • number of concurrent connections on the frontend when the session was logged

  • number of concurrent connections on the backend when the session was logged

  • number of concurrent connections active on the server when the session was logged

  • number of connection retries to the server

1/1/0/0/0

two numbers separated by a slash:

  • number of requests processed before this one in the server's queue (if using session persistence)

  • number of requests processed before this one in the backend's queue

0/0

the HTTP request line

"GET / HTTP/1.1"


Next up

Log Custom Data