Forum Discussion
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 never returns anything? When I put it in the response part of the profile, I get data, but according to this article: Configuring request logging using the Request Logging profile, it should work even from the request part of the profile.
- If I use the response part of the profile, the request and response are delivered as separate events to the log servers. Is there any generic way to connect the events? Transaction ID or something like that?
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 irulewhen 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
2 Replies
- Injeyan_Kostas
Cumulonimbus
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 irulewhen 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- jkasbo
Nimbostratus
Thank you. Worked like a charm!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com