【问题标题】:IIS Log Parser - Need Query to find "total requests taking > x secs" / "Total Requests" grouped by URLIIS 日志解析器 - 需要查询以查找按 URL 分组的“总请求数 > x 秒”/“总请求数”
【发布时间】:2011-06-07 11:44:04
【问题描述】:
我支持偶尔出现性能问题的应用程序。客户想知道页面有多慢。
即页面花费超过 x 秒的总时间/页面的请求总数
我想编写一个查询来获取所需的数据。
这样的东西在 SQL 中可能会起作用,但在 IIS 日志解析器中不起作用。
select URL, count(case when time > 100 then 1 else null end), count(*)
from table1
group by URL
【问题讨论】:
标签:
iis
logging
logparser
【解决方案1】:
这里的问题是您需要两个查询。
-
一个计算每页的请求总数,无论花费多少时间
SELECT cs-uri-stem, COUNT(*) AS all-requests
FROM ex*.log
GROUP BY cs-uri-stem
-
一个计算耗时 > X 秒的页数
SELECT cs-uri-stem, COUNT(*) as total-requests
FROM ex*.log
WHERE time-taken > 1000 <- time_taken is milliseconds
GROUP BY cs-uri-stem
您所追求的结果需要 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
不幸的是,LogParser 中不支持 JOIN。
您可以将两个查询的结果导入 SQL 数据库并在那里运行查询:
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