Hi Amin,

On Mon, Dec 31, 2018 at 05:23:17PM +0100, Amin Shayan wrote:
> Hi guys,
> 
> I'm trying to get clients request http version and it seems %HV which is
> the last field of %r works fine for http/0.9,1.0,1.1. However I get
> http/1.1 on logs for http2 requests.
> 
> Using HAProxy 1.8.16, Is there still below limitation?
> 
>   - no trivial way to report HTTP/2 in the logs. I'm using a sample
>     fetch function reporting the on-wire format as 1 or 2 for now. I
>     considered replacing "HTTP/1.1" with "HTTP/2.0" in the logs but
>     that's inaccurate since we really process "1.1" so it might be
>     confusing to those dealing with regex which don't seem to match,
>     and in addition "HTTP/2.0" is not the correct version string, the
>     correct one is "HTTP/2". But writing this without the dot and the
>     minor version is going to break some log processing tools. Thus I
>     was thinking about having some optional fields that are supposed
>     to be easy to use. Note that we had the same issue with SSL long
>     ago, ending with "~" after the frontend's name in the logs...
>     Better avoid this for H2. Ideas are welcome.

Yes that's true for 1.8. However there is a sample fetch function called
"fc_http_major" which returns the major protocol number on the frontend
connection (1 for 0.9-1.1, 2 for 2.0). You could thus add something like
this to your log-format :

   ... HTTP/%[fc_http_major]

Hoping this helps,
Willy

Reply via email to