Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

SQL – Log Parser Studio – IIS Logs

Posted on December 4, 2015 By David Kittell
/* Compare file sizes of the last 10 days of IIS logs */
/* Log Type: FSLog */
SELECT Path,
	Size,
	LastWriteTime
FROM '[LOGFILEPATH]'
ORDER BY LastWriteTime ASC
/* User-Agent Report */
/* Log Type: IISW3CLOG */
SELECT DISTINCT cs(User-Agent),
	count(*) AS hits
FROM '[LOGFILEPATH]'
GROUP BY cs(User-Agent)
ORDER BY hits DESC
/* Hits by IP address */
/* Log Type: IISW3CLOG */
SELECT [c-ip],
	count([c-ip]) AS requestcount
FROM '[LOGFILEPATH]'
WHERE [cs-uri-stem] LIKE '%/%'
GROUP BY [c-ip]
ORDER BY count([c-ip]) DESC
/* All 500 errors to any IIS/.NET Web Service */
/* Log Type: IISW3CLOG */
SELECT [cs-uri-stem] AS Uri,
	[sc-status] AS HttpStatus,
	[sc-substatus] AS SubStatus,
	[sc-win32-status] AS Win32Status,
	COUNT(*) AS Total
FROM '[LOGFILEPATH]'
WHERE ([sc-status] = 500)
	AND ([cs-uri-stem] LIKE '%.asmx')
GROUP BY Uri,
	HttpStatus,
	SubStatus,
	Win32Status
ORDER BY Total DESC
/*  List only Win32 Error codes. Win32 Error codes are errors that 
     were returned to IIS by the OS or other application.  */
/* Log Type: IISW3CLOG */
SELECT [sc-win32-status] AS [Win32-Status],
	COUNT(*) AS Hits,
	WIN32_ERROR_DESCRIPTION([sc-win32-status]) AS Description
FROM '[LOGFILEPATH]'
WHERE [Win32-Status] <> 0
GROUP BY [Win32-Status]
ORDER BY Hits DESC
/* Count and sort all HTTP status codes */
/* Log Type: IISW3CLOG */
SELECT STRCAT(TO_STRING([sc-status]), STRCAT('.', TO_STRING([sc-substatus]))) AS STATUS,
	COUNT(*) AS Hits
FROM '[LOGFILEPATH]'
GROUP BY STATUS
ORDER BY Hits DESC
/* Requests Per Hour */
/* Log Type: IISW3CLOG */
SELECT QUANTIZE(TO_TIMESTAMP([date], [time]), 3600) AS Hour,
	COUNT(*) AS Total,
	SUM([sc-bytes]) AS TotBytesSent
FROM '[LOGFILEPATH]'
GROUP BY Hour
ORDER BY Hour
/* IIS: HTTP Method Totals with Times */
/* Log Type: IISW3CLOG */
SELECT [cs-method],
	COUNT(*) AS Total,
	MAX([time-taken]) AS MaxTime,
	AVG([time-taken]) AS AvgTime,
	MAX([sc-bytes]) AS MAXBytesSent,
	AVG([sc-bytes]) AS AvgBytesSent
FROM '[LOGFILEPATH]'
GROUP BY [cs-method]
ORDER BY Total DESC
/* Log Type: IISW3CLOG */
SELECT [cs-uri-stem],
	[cs-method],
	COUNT(*) AS Total,
	MAX([time-taken]) AS MaxTime,
	AVG([time-taken]) AS AvgTime,
	MAX([sc-bytes]) AS MaxBytes, 
	AVG([sc-bytes]) AS AvgBytes
FROM '[LOGFILEPATH]'
GROUP BY [cs-uri-stem],
	[cs-method]
ORDER BY Total DESC
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Log Parser Studio SQL

Post navigation

Previous post
Next post

Related Posts

Special Directories: Temp Directory

Posted on September 18, 2013October 26, 2015

Imports System Imports System.IO Public Class MainClass Shared Sub Main() Console.WriteLine(My.Computer.FileSystem.SpecialDirectories.Temp) End Sub End Class Originally Posted on September 18, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development)…

Read More

Android Contacts – Show Contact Names

Posted on March 2, 2014October 26, 2015

SELECT data1 AS FullName, data4 AS Prefix, data2 AS FirstName,data5 AS MiddleName, data3 AS Lastname, data6 AS Suffix FROM data INNER JOIN mimetypes ON mimetype_id = mimetypes._id WHERE mimetype LIKE "%name%" AND length(data1) > 0 and data2 <> "" and data3 <> "" ORDER BY Lastname Originally Posted on March…

Read More

OpenSSL – Extract PFX Certificate & Update SSL Certificate

Posted on May 18, 2016March 9, 2017

First this process doesn’t hack/crack the PFX you will need the password still. Scenario you have to update your SSL certificate but all you saved was your PFX file and know the password for it. openssl pkcs12 -in certname.pfx -nocerts -out key.pem -nodes You get prompted for the Import Password…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes