HAProxy community

How to capture req and response in MLB HAProxy

Hi,

Basically I’m trying to get a new log format, to achieve this I need to capture some values from front end http request and response.

  • For the log format I have added the HAPROXY_HEAD template to the Marathon config and its working fine
  • I’m not really sure how to add the below captures to the front end which is for Port 80.

declare capture request len 24
http-request capture req.hdr(X-Request-Id) id 0

Capture the user id from header for logging

declare capture request len 36
http-request capture req.hdr(VDSID) id 1

Capture the ReqAppId from header for logging

declare capture request len 36
http-request capture req.hdr(ReqAppId) id 2

Note : HAPROXY is running in a container and new services always append to the Front end automatically.

When I have tried to add the HAPROXY_HTTP_FRONTEND_HEAD, HAPROX_FRONTEND_HEAD templates but it created another front end for port 80 and services were failing sometimes.

So I want a solution that will append the captures to the existing frontend marathon_http_in??

Thanks for your help.

It’s a little bit unclear from your original message, but I get the impression that this question isn’t actually about how to configure HAProxy to do those captures, but how to configure Marathon to pass these customizations to the HAProxy it is managing?

Yes, my question is how to configure the captures for port 80 from marathon.