An administrator is troubleshooting a web application hosted on an Azure App Service plan. The Web Server logging feature is enabled and configured to send logs to a Log Analytics workspace. The administrator needs to identify the client IP addresses that experienced server-side errors (HTTP status codes through ) over the past hours. The results must show each client IP address and the total number of failed requests, sorted in descending order of the request count. Which Kusto Query Language (KQL) query should the administrator run?
- AppServiceHTTPLogs
| where TimeGenerated > ago(24h)
| where ScStatus >= 500 and ScStatus < 600
| summarize RequestCount = count() by CiIP
| sort by RequestCount descCevap - BAppServiceHTTPLogs
| summarize RequestCount = count() by CiIP, ScStatus
| sort by RequestCount desc
| where TimeGenerated > ago(24h) and ScStatus >= 500 and ScStatus < 600 - CAppServiceHTTPLogs
| where TimeGenerated > ago(24h) and ScStatus between (500 .. 599)
| group by CiIP
| order by count() desc - DAppServiceHTTPLogs
| where TimeGenerated > ago(24h)
| where ScStatus == "5*"
| summarize RequestCount = count() by CiIP
| sort by RequestCount desc
Cevap
The query that filters AppServiceHTTPLogs by TimeGenerated and ScStatus, summarizes by client IP, and then sorts by count in descending order.
The correct query follows the KQL pipeline structure. It first filters the AppServiceHTTPLogs table to the specified time window of hours and HTTP status range ( to ). Next, it uses the summarize operator to group by the client IP address and calculate the total count of matching logs. Finally, it sorts the results in descending order by the aggregated request count.
Adım Adım Çözüm
Anahtar Kavram
KQL Query Construction and Table Schema Filtering