An administrator needs to analyze subscription activity logs in a Log Analytics workspace. The administrator wants to identify all resource deletion operations that failed within the last days. The results must be grouped by the user or service principal that initiated the operation (the caller) and show the count of failed deletions. Which two of the following Kusto Query Language (KQL) queries will retrieve the required information?
- AzureActivity | where TimeGenerated > ago(7d) | where OperationNameValue contains "delete" and ActivityStatusValue == "Failed" | summarize count() by CallerCevap
- AzureActivity | where TimeGenerated >= ago(7d) | where OperationNameValue has "delete" | where ActivityStatusValue =~ "failed" | summarize count() by CallerCevap
- CAzureActivity | where TimeGenerated > ago(7d) | where OperationNameValue contains "delete" and ActivityStatusValue == "Failed" | group by Caller
- DAzureActivity | filter TimeGenerated > ago(7d) | where OperationNameValue contains "delete" and ActivityStatusValue == "Failed" | summarize count() by Caller
Cevap
The queries that retrieve the correct results use the where operator to filter records from the last days, filter the operation name and status appropriately, and use the summarize operator to group the counts by caller.
The queries that use the where operator to filter by time, contains or has operators for the deletion operation, and the case-insensitive equality operator =~ or case-sensitive == to check for failed status, followed by the summarize count() by Caller clause are correct. In KQL, contains is a case-insensitive string operator, and has looks for full token matches (also case-insensitive). The =~ operator compares strings in a case-insensitive manner, making it valid for matching 'failed' regardless of its casing.
Adım Adım Çözüm
Anahtar Kavram
Writing and structure of KQL queries using Azure Activity logs