Archive

Finding number of requests and their response time in last 24 hours

New Member

Hi,

I have two log messages like this:

Log 1:

2011-09-22 14:35:21,441 [Thread-20] DEBUG NHTTPClient2 - Execute http POST request for : http://na.api.inrix.com/V3/Traffic/Inrix.ashx

Log 2:

2011-09-22 14:35:22,122 [New I/O client worker #1-1] INFO NHTTPClient2 - Http request complete status 200 OK, Url http://na.api.inrix.com/V3/Traffic/Inrix.ashx

Log 1 is the request and log 2 is the response. I want to find out how many requests were being made and their corresponding response time in the last 24 hours and for the last one week.

How to query this requirement.

Any help is much appreciated!!

Tags (2)
0 Karma

New Member

Sorry for bothering you again. The query which you have provided me is fetching the results for all the URLs but I need the results only for this URL:

http://na.api.inrix.com/V3/Traffic/Inrix.ashx

How to get that? Thanks!!

0 Karma

Builder

limit the search going into the transaction command, it'll be faster,

|rex field=_raw "(?<url>http://[A-z0-9./]+)"
|search url="http://na.api.inrix.com/V3/Traffic/Inrix.ashx"
|transaction url startswith="POST request" endswith="request complete" maxevents=2
|stats count as Total_Requests avg(duration) as Average_Response_Time
0 Karma

New Member

Hi,

I am not successful in extracting the url in this case. I am using the following query but I am not getting the expected result.

sourcetype="mysourcetype" | transaction "http://na.api.inrix.com/V3/Traffic/Inrix.ashx" startswith="POST request for : " endswith="Http request complete status 200 OK" maxevents=2 | stats count as Total_Requests avg(duration) as Average_Response_Time

Any help on this please!!

0 Karma

Builder

and then if you only care about the 200's do a search afterwards | search "status 200 OK"

so your final search would be:

|rex field=_raw "(?<url>http://[A-z0-9./]+)"
|transaction url startswith="POST request" endswith="request complete" maxevents=2
|stats count as Total_Requests avg(duration) as Average_Response_Time
0 Karma

Builder

to extract the text into a field, you either need to use a regex expression in props.conf / transforms.conf or you can use the "rex" command. In your case, assuming the url is only printed 1x on each line, use:

|rex field=_raw "(?<url>http://[A-z0-9./]+)"

then use the transaction command exactly as I have above:

|transaction url startswith="POST request" endswith="request complete" maxevents=2 | top url by duration |  sort - duration

As a side note, your endswith will only close a transaction if the response code was a 200, you may want to capture all responses as I have in mine.

0 Karma

Builder

if you extract the url from both lines, you could use the transaction command,

|transaction url startswith="POST request" endswith="request complete" maxevents=2 | stats count as Total_Requests avg(duration) as Average_Response_Time

This will show you the total requests and the average duration of each request. By using the transaction command you get the "duration" field automatically. Without doing the stats command you'll be able to see the duration of each event and search on duration. For instance you could do things like:

|transaction url startswith="POST request" endswith="request complete" maxevents=2 | top url by duration |  sort - duration

This would list the top durations and their corresponding URL's so you can see which pages take the longest to load.

or

|stats max(duration) by url

to see what was the longest amount of time taken to load any url.

State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!