IIS Log Parser - Need Query to find “total requests taking > x secs” / “Total Requests” grouped by URL

只愿长相守 提交于 2019-12-10 11:14:07

问题


I am supporting an application that is having occasional performance issues. The client wants to know how often a page is slow.

i.e. Total times a page took greater than x secs / Total number of requests for the page

I would like to write a single query to fetch the desired data.

Something like this in SQL would probably work but isn't working in IIS Log parser.

select URL, count(case when time > 100  then 1 else null end), count(*)
from   table1
group by URL

回答1:


The problem here is that you need two queries.

  • One to count the total number of requests per page regardless of time taken

    SELECT cs-uri-stem, COUNT(*) AS all-requests 
    FROM ex*.log 
    GROUP BY cs-uri-stem
    
  • One to count the number of pages where time-taken > X seconds

    SELECT cs-uri-stem, COUNT(*) as total-requests
    FROM ex*.log
    WHERE time-taken > 1000 <- time_taken is milliseconds
    GROUP BY cs-uri-stem 
    

The result you're after would require a JOIN:

SELECT a.cs-uri-stem, COUNT(*) as total-requests, b.all-requests
FROM ex*.log AS a
JOIN (
    SELECT cs-uri-stem, COUNT(*) AS all-requests 
    FROM ex*.log 
    GROUP BY cs-uri-stem
) AS b ON b.cs-uri-stem = a.cs-uri-stem
WHERE a.time-taken >1000 
GROUP BY a.cs-uri-stem 

Unfortunately there is no support for JOIN's in LogParser.

What you could do is import the results of both queries into a SQL Database and run the query there:

SELECT a.cs-uri-stem, COUNT(*) as total-requests, b.all-requests
FROM long_running_pages AS a
JOIN all_pages_grouped b ON ( a.cs-uri-stem = b.cs-uri-stem)
GROUP BY a.cs-uri-stem 


来源:https://stackoverflow.com/questions/4663262/iis-log-parser-need-query-to-find-total-requests-taking-x-secs-total-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!