Forum Discussion
ahmad_2312
Jul 09, 2011Nimbostratus
Measuring Response time based on POST and GET Parameters
HI
I am trying to measure the response time of each transaction in our website, however due to security reasons all URLs are masked and the only way to identify the page is by using a submitted form's parameter called hidActionName, the parameter is submitted in some pages using GET method and in other in POST, i tried my best and came up with this , but it didnt work ... can you help please:
when HTTP_REQUEST {
set http_request_time [clock clicks -milliseconds]
set theurl [HTTP::uri]
set theip [IP::client_addr]
set wmethod [HTTP::method]
Only check POST requests
if { [HTTP::method] eq "POST" } {
Default amount of request payload to collect (in bytes)
set collect_length 2048
Check for a non-existent Content-Length header
if {[HTTP::header Content-Length] eq ""}{
Use default collect length of 2k for POSTs without a Content-Length header
set collect_length $collect_length
} elseif {[HTTP::header Content-Length] == 0}{
Don't try collect a payload if there isn't one
unset collect_length
} elseif {[HTTP::header Content-Length] > $collect_length}{
Use default collect length
set collect_length $collect_length
} else {
Collect the actual payload length
set collect_length [HTTP::header Content-Length]
}
If the POST Content-Length isn't 0, collect (a portion of) the payload
if {[info exists collect_length]}{
Trigger collection of the request payload
HTTP::collect $collect_length
}
}
}
when HTTP_REQUEST_DATA {
set ActionName [URI::decode [URI::query "?[HTTP::payload]" hidActionName]]
}
when HTTP_RESPONSE {
set http_response_time [ clock clicks -milliseconds ]
log 10.0.10.16:514 local0. "CEF:0|XXX|XXXX|10.2|200|Response Time|2|src=$theip request=$theurl cn1=[expr $http_response_time - $http_request_time] cs1=$wmethod cs2=$ActionName"
}
- ahmad_2312Nimbostratususing the following code, i was able to get the response time based on POST and GET Parameters, however i am still getting some TCL Error in logs
when HTTP_REQUEST { set http_request_time [clock clicks -milliseconds] set theurl [HTTP::uri] set theip [IP::client_addr] set wmethod [HTTP::method] set contype [HTTP::header Content-Type] set POSTQuery "" set GETQuery "" switch [HTTP::method] { "GET" { Inspect Query String set GETQuery [string tolower [URI::query "?&[HTTP::query]" hidActionName]] } "POST" { if { [HTTP::header Content-Type] eq "application/x-www-form-urlencoded" } { HTTP::collect [HTTP::header Content-Length] } } } } when HTTP_REQUEST_DATA { set POSTQuery [string tolower [URI::query "?[HTTP::payload]" hidActionName]] } when HTTP_RESPONSE { set http_response_time [ clock clicks -milliseconds ] log 10.0.10.16:514 local0. "CEF:0|XX|XX|10.2|200|Response Time|2|src=$theip request=$theurl cn1=[expr $http_response_time - $http_request_time] cs1=$wmethod cs2=$contype cs4=$POSTQuery cs6=$GETQuery" }
- HamishCirrocumulusIs there a content-length header in the post? (Although collect will take 0 or no parameter, I'm not sure off hand what a missing header will return and pass to the collect routine).
- hooleylistCirrostratusHamish is right here. HTTP::header $header_name will return a null string if the header doesn't exist. HTTP::collect expects an integer so that's why you're getting the error.
- HamishCirrocumulus
Trigger collection for up to 1MB of data if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{ set fl_content_length [HTTP::header "Content-Length"] } else { set fl_content_length 1048576 } paranoia... Check if $content_length has been set and is not set to 0 if { [info exists fl_content_length] && $fl_content_length > 0} { if { $fl_debugFlag >= 2 } { HSL::send $hsl "$fl_logprefix collecting $fl_content_length Bytes" } HTTP::collect $fl_content_length }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects