A client recently asked us to measure the performance in a web service we had recently updated to improve overall performance against Microsoft’s “Office 365”:https://products.office.com/en-us/office-365-home environment. My first instinct was to write a relatively simple script to parse IIS server logs and calculate the average response time of each request made against certain API endpoints.
However, over the years I’ve learned that there are a lot of smart people out there and that one of them may have already created a tool that could solve this problem. To my pleasant surprise, I quickly discovered that Microsoft has created tool called “LogParser”:https://technet.microsoft.com/en-us/scriptcenter/dd919274.aspx. Log Parser provides the ability to query a number of text based files leveraging a variant of SQL, and it is an immensely powerful tool.
h2. The Problem
In order to show that the web service improved its responsiveness, the IIS log files would have to be evaluated in order measure each the time taken to respond to each request and average it. Moreover, the response times evaluated would need to be restricted to a particular HTTP endpoint and timespan in order get an accurate measurement.
h2. The Solution
Traditionally, this could have been solved by creating a simple script to recursively traverse IIS’s log files, match responses, measure each response time, and then average them. However, it would still require a meaningful amount of development time and would still be relatively rigid compared to Microsoft’s LogParser.
Solving this problem in LogParser is much more straightforward than creating a custom script as demonstrated below:
LogParser "SELECT date, AVG(Time-Taken) as avg_time INTO C:\AverageTime.txt FROM C:\inetpub\logs\LogFiles\*.log WHERE cs-uri-stem = '/api' AND to_timestamp(date,time) > timestamp('2015-01-05 00:00:00', 'yyyy-MM-dd hh:mm:ss') GROUP BY date" -i:IISW3C -o:CSV recurse
This is just _one_ example of how LogParser can be utilized, and there are a number of other statistics that could be gathered using LogParser’s SQL syntax. For example, it would be fairly trivial to count the total number of requests made to the API, or the average number of errors, or even what was the most common kind of request made to the API. LogParser’s builtin flexibility makes it far easier and cheaper to mine useful data out of server logs.