你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

AppRequests 表的查询

有关在 Azure 门户中使用这些查询的信息,请参阅 Log Analytics 教程。 有关 REST API,请参阅查询

响应时间趋势

绘制过去 12 小时请求持续时间的图表。

// To create an alert for this query, click '+ New alert rule'
AppRequests
| where TimeGenerated > ago(12h) 
| summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId // use a time grain of 10 minutes
| render timechart

请求计数趋势

绘制前一天请求计数的图表。

// To create an alert for this query, click '+ New alert rule'
AppRequests
| summarize totalCount=sum(ItemCount) by bin(TimeGenerated, 30m), _ResourceId
| render timechart

响应时间桶

显示每个性能桶中的请求数。

AppRequests
| summarize requestCount=sum(ItemCount), avgDuration=avg(DurationMs) by PerformanceBucket
| order by avgDuration asc // sort by average request duration
| project-away avgDuration // no need to display avgDuration, we used it only for sorting results
| render barchart

操作性能

按操作计算请求计数和持续时间。

// To create an alert for this query, click '+ New alert rule'
AppRequests
| summarize RequestsCount=sum(ItemCount), AverageDuration=avg(DurationMs), percentiles(DurationMs, 50, 95, 99) by OperationName, _ResourceId // you can replace 'OperationName' with another value to segment by a different property
| order by RequestsCount desc // order from highest to lower (descending)

流量前 10 的国家/地区

绘制排名前 10 国家/地区的请求数的图表。

AppRequests
| summarize CountByCountry=count() by ClientCountryOrRegion
| top 10 by CountByCountry
| render piechart

失败请求数 - 前10

3 个最慢的页面是什么,它们的速度是多少?

AppRequests
| where Success == false
| summarize failedCount=sum(ItemCount) by Name
| top 10 by failedCount desc
| render barchart

失败的操作

计算操作的失败次数以及受影响的用户数。

// To create an alert for this query, click '+ New alert rule'
AppRequests
| where Success == false
| summarize failedCount=sum(ItemCount), impactedUsers=dcount(UserId) by OperationName, _ResourceId
| order by failedCount desc

导致请求失败的异常

查找过去 1 小时内哪些异常导致请求失败。

AppRequests
| where TimeGenerated > ago(1h) and Success == false
| join kind= inner (
AppExceptions
| where TimeGenerated > ago(1h)
) on OperationId
| project exceptionType = Type, failedMethod = Method, requestName = Name, requestDuration = DurationMs, _ResourceId