Forum Discussion

jkstraw_44238's avatar
jkstraw_44238
Icon for Nimbostratus rankNimbostratus
Apr 20, 2007

Tracking requests and responses

Hi,

 

 

I am working with an iRule provided by System Engineer at F5. The iRule was designed to give us the same information our custom apache log gives us (we are moving from Apace to F5).

 

 

Here is the Custom Apache Log:

 

 

CustomLog /opt/apache/logs/ssl_request_log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %{JSESSIONID}C %{SSL_PROTOCOL}x %{SSL_CIPHER}x %D"

 

 

and here is the iRule I was provided:

 

 

when HTTP_REQUEST {

 

set http_request_time [clock clicks -milliseconds]

 

log local0. "Client IP: [IP::remote_addr], requesting: [HTTP::method]/[HTTP::host][HTTP::uri], browser: [HTTP::header User-Agent], Referer: [HTTP::header exists Referer], HTTP version [HTTP::version], JSESSION Cookie: [HTTP::cookie exists JSESSIONID], SSL: [SSL::cipher name]/[SSL::cipher version]/[SSL::cipher bits]"

 

}

 

 

when HTTP_RESPONSE {

 

set http_response_time [ clock clicks -milliseconds ]

 

log local0. "HTTP status: [HTTP::status], Response Size: [HTTP::payload length], Duration: [expr $http_response_time - $http_request_time] "

 

}

 

 

 

The iRule seems to provide all the information - but it logs it on two separate lines with no unique identifier in each entry to correlate the data.

 

 

Does anyone know of a way to insert a unique value that would tie together the http_request and http_response lines?

 

 

Thanks

12 Replies

  • Just closing off this thread: Here is what I ended up using to get apache like custom logging:

     

     

    when HTTP_REQUEST {

     

    set http_request_time [clock clicks -milliseconds]

     

    set request_log_line "\

     

    [HTTP::request_num],\

     

    [IP::remote_addr],\

     

    [HTTP::method],\

     

    [HTTP::version],\

     

    [HTTP::host],\

     

    \"[HTTP::uri]\",\

     

    \"[HTTP::header value Referer]\",

     

    \"[HTTP::header User-Agent]\",\

     

    \"[HTTP::cookie value JSESSIONID]\",\

     

    [SSL::cipher name],\

     

    [SSL::cipher version],\

     

    [SSL::cipher bits]"

     

    }

     

     

    when HTTP_RESPONSE {

     

    set http_response_time [ clock clicks -milliseconds ]

     

    log local0. "$request_log_line,\

     

    [HTTP::status],\

     

    [HTTP::payload length],\

     

    [expr $http_response_time - $http_request_time]"

     

    }

     

     

    This gives a log in this format:

     

     

    Apr 23 15:13:29 tmm tmm[1466]: Rule My_Logging : 2, 192.168.1.222, GET, 1.1, host.domain.local, "/client_load_testing/startPointServlet", "https://client.domain.local/client_load_testing/", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3", "8962B5E85F49648F87EE71553EED3390", RC4-MD5, TLSv1, 128, 302, 0, 73

     

     

    Thank you for all the prompt and helpful responses - greatly appreciated!

     

     

    Cheers
  • will do :-)

     

     

    Posted: http://devcentral.f5.com/wiki/default.aspx/iRules/Custom_Apache_style_logging_for_Java_based_applications.html