Log parser queries for IIS logs

by dipbiswas 28. June 2010 05:08

Returns a listing of rquests, bandwidth, and last visit, by unique IP address and user agent

"C:\Program Files\Log Parser 2.2\LogParser.exe" -rtp:-1 "SELECT COUNT(*) AS [Requests], DIV(DIV(SUM(cs-bytes), 1024), 1024) AS [MBytes received], DIV(DIV(SUM(sc-bytes), 1024), 1024) AS [MBytes sent], c-ip AS [IP Address], cs(User-Agent) AS [User agent], MAX(date) AS [Last visit] INTO IpAddress.txt FROM ex100317.log GROUP BY [IP Address], [User agent] ORDER BY [Requests] DESC"

"C:\Program Files\Log Parser 2.2\LogParser.exe" -rtp:-1 "SELECT COUNT(*) AS [Requests], DIV(DIV(SUM(cs-bytes), 1024), 1024) AS [MBytes received], DIV(DIV(SUM(sc-bytes), 1024), 1024) AS [MBytes sent], c-ip AS [IP Address], cs(User-Agent) AS [User agent], MAX(date) AS [Last visit] FROM ex100317.log GROUP BY [IP Address], [User agent] ORDER BY [Requests] DESC" -O:Datagrid

"C:\Program Files\Log Parser 2.2\LogParser.exe" -rtp:-1 "SELECT COUNT(*) AS [Requests], DIV(DIV(SUM(cs-bytes), 1024), 1024) AS [MBytes received], DIV(DIV(SUM(sc-bytes), 1024), 1024) AS [MBytessent], cs-username AS [USER], MAX(date) AS [DATE], MAX(time) AS [Last visit] INTO IpAddress.txt FROM ex100317.log GROUP BY [User] ORDER BY [Requests] DESC" -o:Datagrid


Which pages are taking the longest amount of time to be served

"C:\Program Files\Log Parser 2.2\LogParser.exe" "SELECT cs-uri-stem, time-taken FROM ex100317.log ORDER BY time-taken DESC" -i:IISW3C -q:ON -o:Datagrid


Finding the number of hits to your web pages

"C:\Program Files\Log Parser 2.2\LogParser.exe" -i:IISW3C "SELECT cs-uri-stem, COUNT(*) As Hits FROM ex100317.log GROUP BY cs-uri-stem ORDER BY Hits DESC" -q:ON –o:DataGrid


Trace requests from a specific username (assuming that the request is not anonymous)

"C:\Program Files\Log Parser 2.2\LogParser.exe" "SELECT * FROM ex100317.log WHERE cs-username='IN\ruchigarg'" -i:IISW3C -q:ON –o:Datagrid
"C:\Program Files\Log Parser 2.2\LogParser.exe" "SELECT * FROM ex100317.log" -i:IISW3C -q:ON –o:Datagrid


This will find all requests that failed with a status code of HTTP 500

"C:\Program Files\Log Parser 2.2\LogParser.exe" -i:IISW3C -o:DataGrid "SELECT cs-uri-stem,  sc-status as Status FROM ex100317.log WHERE Status='500'" -q:ON


Requests by hour (using TO_STRING)

"C:\Program Files\Log Parser 2.2\LogParser.exe" -rtp:-1 "SELECT TO_STRING(time, 'hh') AS [Hour], COUNT(*) AS [Requests], MUL(PROPCOUNT(*), 100) AS [PercentOfTotal] INTO HourlyReport.txt FROM ex100628*.log GROUP BY [Hour] ORDER BY [Hour]"

Tags:

IIS Logs

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



The opinions expressed herein are personal opinions and do not represent others' view in anyway. All posts are provided AS IS with no warranties, and confers no rights.

Web Development & Design Blogs    Web design blogs   

You are visitor#