Forum Discussion

jkasbo's avatar
jkasbo
Icon for Nimbostratus rankNimbostratus
Jun 06, 2025
Solved

Request logging: some fields not recorded

Hi. I have set up a request logging profile and it seems to work fine. I have two questions, however: In the template I want to get the HTTP status code recorded by using ${HTTP_STATCODE}, but it n...
  • Injeyan_Kostas's avatar
    Jun 06, 2025

    Response status is not available in the request, only in the response

    If you use NCSA_COMMON in response settings you will get all the info, bothe request and response, in the Response Log

    If you have a unique header you might be able to use it to combine Request and Response
    you may also use irules to catch a unique value anywhere in the payload add it a temp header in HTTP_REQUEST and  HTTP_RESPONSE events
    then this header will be available for use in logging profile
    and then remove it in HTTP_REQUEST_RELEASE and HTTP_RESPONSE_RELEASE events

    or even generate a random id using irules

    for example you can use this irule

    when HTTP_REQUEST
    {
        set rand_hex [format "%08X%08X%08X%08X" [expr { int(rand() * 0xFFFFFFFF) }] [expr { int(rand() * 0xFFFFFFFF) }] [expr { int(rand() * 0xFFFFFFFF) }] [expr { int(rand() * 0xFFFFFFFF) }]]
        HTTP::header insert "X-Request-ID" $rand_hex
    }
    
    when HTTP_REQUEST_RELEASE
    {
        HTTP::header remove "X-Request-ID"
    }
    
    when HTTP_RESPONSE
    {
        HTTP::header insert "X-Request-ID" $rand_hex
    }
    
    when HTTP_RESPONSE_RELEASE
    {
        HTTP::header remove "X-Request-ID"
    }

     
    and then user X-Request-ID in logging profile