HAProxy community

Custom log socket bind name


#1

I’d like to log the name given to the socket with the bind “name” option.

The custom log format option %f or %ft for the frontend name don’t include the socket name, and I didn’t see any other log variable to use them.

The log lines (not customizable) used for errors do include the bind name, if defined.

I quickly browsed the source code and couldn’t find any way to access the socket listener name from session variables.

Is this only accessible in the stats page and the error logs?


#2

I tracked down the change introducing the name option almost 10 years ago, and the commit message references my use case: distinguish traffic from different origins.

There are convoluted ways around this with creating acls to identify that traffic (e.g. using the so_id sample) and setting a custom variable based on those acls, but really that shouldn’t be necessary.


#3

So a sample like so_name returning the socket name as string would fix this, right? You could then customize your log line appropriately by accessing that sample.

I think this makes sense. You may want to file a feature request on github.


#4

I guess having it as a sample would work yes.
I was originally going to open a GitHub feature request but came here first to get feedback.

Edit: https://github.com/haproxy/haproxy/issues/37