haproxy: adding tcplog parameters

Slightly related to " Other options to "balance source" in haproxy", I would like to know what ports are currently pointed where.

To confirm, I'm using haproxy to distribute clients which make only a single connection at a time to a different port on the proxy, to different backend servers. Assume the protocol is ssh.

I'm using a stick-table to keep clients to one backend server until that server goes down. What's the best way to find out what the current state is?

I know I could make one frontend for each port then point them all at the same backend. The name of the frontend is then logged but i can't help but want one neat frontend with a range of ports and then dst_port logged.


My current answer/solution (mentioned in the question) is as follows.

I define a different 'listen' for each port to be bound with a recognisable name.

I then ensure option tcplog is enabled for that frontend.

The logging then provides me the two pieces of information I need. The frontend and backend used.

e.g.

haproxy[18989]: 127.0.0.1:34550 [15/Oct/2003:15:24:28.312] frontend backend/server 0/0/5007 0 cD 0/0/0/0/0 0/0

I parse that log file 'magically' and use that information to present the latest status.

option logasap helps..


Default tcplog format is equivalent to:

log-format "%ci:%cp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq"

So, you can customize it adding variables of your interest (list of defined variables), e.g frontend listening port %fp:

log-format "%ci:%cp [%t] %ft %fp %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq"