Log Parser script: Percent of status codes across all hits/requests
Note: This article was written using Log Parser 2.2. Therefore, while it may work for a different version, it may not.
The following SQL can be used by Log Parser to generate a chart with the total requests (for a day, month, or year) and what percent each status code is of those requests. An example chart can be found at the end of this article.
First, I assume that the below is put in the same directory as the logs you would like to parse.
SELECT sc-status AS [HTTP Status Code], count(*) AS Requests
GROUP BY [HTTP Status Code]
ORDER BY Requests DESC
Once you've saved this, you can call the script like such, so long as you're already in the directory you saved the SQL file.
logparser file:http_status_percent_graph.sql?date=0710 -o:chart -chartType:Pie -chartTitle:"Status as Percent of Requests"
If you just want the numbers, you can use the following SQL.
SELECT sc-status, count(*)
GROUP BY sc-status
ORDER BY sc-status
It too can be called via the command line (again, assuming you save the SQL file and run the following in the same directory as your log files).
logparser -rtp:-1 file:http_status_codes.sql?date=0710
Feel free to modify the scripts to your own need.
Example of the status code chart
Links of Note
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.