Your organization uses an Azure Application Gateway v2 to route traffic for a web application. You enable diagnostic logging for the Application Gateway and route the logs to a Log Analytics workspace. The logs are collected in the resource-specific AGWAccessLogs table.
You need to write a Kusto Query Language (KQL) query to identify the top request URIs that experienced the highest average backend response time for requests resulting in server-side errors (HTTP status codes in the range) over the last hours.
Which of the following KQL queries will return the correct results? (Select two.)
- AGWAccessLogs
| where TimeGenerated > ago(24h)
| where toint(httpStatus) >= 500 and toint(httpStatus) < 600
| summarize AvgResponseTime = avg(backendResponseTime) by requestUri
| top 5 by AvgResponseTime descAnswer - BAGWAccessLogs
| where TimeGenerated > ago(24h)
| where httpStatus >= 500 and httpStatus < 600
| summarize AvgResponseTime = avg(backendResponseTime) by requestUri
| top 5 by AvgResponseTime desc - AGWAccessLogs
| where TimeGenerated > ago(1d)
| where httpStatus startswith "5"
| summarize AvgResponseTime = avg(backendResponseTime) by requestUri
| order by AvgResponseTime desc
| take 5Answer - DAGWAccessLogs
| where TimeGenerated > ago(24h)
| where toint(httpStatus) between (500 .. 599)
| summarize AvgResponseTime = avg(backendResponseTime)
| top 5 by AvgResponseTime desc - EAGWAccessLogs
| where TimeGenerated > ago(24h)
| where httpStatus startswith "5"
| group requestUri by avg(backendResponseTime)
| limit 5
Answer
The KQL queries that cast httpStatus to an integer before comparison or use string prefix matching with startswith, and correctly group by requestUri before sorting and taking the top records.
To retrieve the requested data, the query must account for the string data type of httpStatus in the AGWAccessLogs table. This is achieved either by casting the status code to an integer using toint() or by using the startswith operator. Furthermore, to find the slowest URIs, the query must group the average backend response time by requestUri and then sort the results in descending order, returning the top records using either top or take.
Step-by-Step Solution
Key Concept
Querying resource-specific logs using KQL, understanding column types (string vs. numerical), performing aggregations with summarize, and limiting results using top or take.