Forum Discussion
Issue with HTTP_RESPONSE_RELEASE and redirect
Hi everyone, I'm pretty new to F5 and I've a question, regarding the processing of iRules within the Virtual servers. Basically I have an irule that I use to log the requests and send a line into a pool:
timing on
when CLIENT_ACCEPTED {
set logging_hsl [HSL::open -proto UDP -pool logging]
}
when HTTP_REQUEST {
set requestURI "[HTTP::uri]"
set virtual_server_name [getfield [virtual name] / 3]
set domain "[HTTP::host]"
set startTime [clock clicks -milliseconds]
if {[HTTP::header "X-XXX"] ne ""} {set inXXX "[HTTP::header "X-XXX"]"} else {set inXXX "unkn"}
set ts [clock format $timeInSeconds -format "%Y-%m-%dT%T.$frac" -gmt 1]Z
when HTTP_REQUEST_DATA {
set endRequestData [clock clicks -milliseconds]
}
when HTTP_RESPONSE {
set now [clock clicks -milliseconds]
set etimeResponse [expr {($now - $startTime)}]
}
when LB_SELECTED {
set lt_lbPool [getfield [LB::server pool] / 3]
set lt_lbServer [LB::server addr]
}
when HTTP_RESPONSE_RELEASE {
if { [catch {
...
set logging "$ts $src_addr > $virtual_server_name"
HSL::send $logging_hsl $logging
}]
} {
log local0. "Match error"
}
}
The problem I'm having occurs in the HTTP_RESPONSE_RELEASE event in the case that a REDIRECT occurs, in which case it exits through the catch, logs the error but I lose logging that line in the pool. To solve part of the problem, I add a
if { [HTTP::has_responded] } { return }
block before the
if { [catch
, but I would also be missing the logging line. In addition, when you do the redirect, you no longer have access to the headers, so you don't have them cached and it fails.
Does anyone have an idea of how I could do to be able to log that request even if it comes from a redirect? I'm struggling with this and I can't find how to avoid missing logging those requests that come out by redirect.
Thanks in advance!
Cheers.
Hi catoverflow !
Welcome to the magical world of iRules!
Have you tried caching the headers in another event? Any variable you set scoped to the connection so you can grab the data you need from any event that occurrs before the HTTP_RESPONSE_RELEASE event.
Check out this chart:
https://community.f5.com/t5/codeshare/irule-event-order-flowchart/ta-p/286343Worth noting is that not all events has access to all fields, but it's easy enought to test. 🙂
Kind regards,
Patrik
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