RSpangler_17032
Mar 24, 2017Nimbostratus
Response time iRule error
Hello,
So I'm trying to implement code that will capture request and response times between the F5 and the backend servers. I found this spinet of code here, iRule Response time, and I'm trying to set it up to only log a certain URL as I do not need anything else that would be accosted with the pool.
Here is the code I tweeked:
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] contains "webtest")}{
set CLIENT_ADDR [IP::client_addr]
set XFF [HTTP::header X-Forwarded-For]
set ID "[TCP::local_port][expr { int(100000000 * rand()) }]"
set REQUEST_RECEIVE [clock clicks -milliseconds]
set URI "[HTTP::uri]"
}
}
when HTTP_REQUEST_SEND {
if {([string tolower [HTTP::host]] contains "webtest")}{
set REQUEST_SEND [clock clicks -milliseconds]
set REQUEST_WAIT [expr {$REQUEST_SEND - $REQUEST_RECEIVE}]
log local0. "SRC:$CLIENT_ADDR XFF:$XFF ID:$ID URI:$URI"
}
}
when HTTP_RESPONSE {
if {([string tolower [HTTP::host]] contains "webtest")}{
set RESPONSE_TIME [expr {[clock clicks -milliseconds] - $REQUEST_SEND}]
log local0. "SRC:$CLIENT_ADDR XFF:$XFF ID:$ID URI:$URI - HTTP[HTTP::status] $RESPONSE_TIME\ms/$REQUEST_WAIT\ms [LB::server addr]"
}
}
When I go to save the code I get the following error:
Exception caught in LocalLB::urn:iControl:LocalLB/Rule::modify_rule()
Exception: Common::OperationFailed
primary_error_code : 17236305 (0x01070151)
secondary_error_code : 0
error_string : 01070151:3: Rule [/Common/Responce-times] error: /Common/Responce-times:20: error: [command is not valid in current event context (HTTP_RESPONSE)][HTTP::host]
I'm not sure what I'm missing or configured wrong here. Can anyone point me in the correct direction? Thank you for your help.