An administrator is configuring diagnostics for an Azure Container Registry named acr1. Diagnostic logs are configured to send repository events to a Log Analytics workspace.
You need to write a Kusto Query Language (KQL) query to count the number of successful image pull operations (where the operation is RepositoryPull and the result is Success) initiated from IP addresses outside of the corporate subnet 192.168.0.0/16 during the last 48 hours. The results must be grouped by the repository name and the caller's IP address.
Which KQL query should you run?
- ContainerRegistryRepositoryEvents
| where TimeGenerated > ago(48h)
| where OperationName == "RepositoryPull" and Result == "Success"
| where not(ipv4_is_in_range(CallerIpAddress, "192.168.0.0/16"))
| summarize PullCount = count() by Repository, CallerIpAddressCevap - BAzureActivity
| where TimeGenerated > ago(48h)
| where OperationNameValue == "Microsoft.ContainerRegistry/registries/pull"
| where ActivityStatus == "Success"
| where not(ipv4_is_in_range(CallerIpAddress, "192.168.0.0/16"))
| summarize PullCount = count() by Resource, CallerIpAddress - CContainerRegistryRepositoryEvents
| summarize PullCount = count() by Repository, CallerIpAddress
| where TimeGenerated > ago(48h)
| where OperationName == "RepositoryPull" and Result == "Success"
| where ipv4_is_in_range(CallerIpAddress, "192.168.0.0/16") == false - DContainerRegistryRepositoryEvents
| where TimeGenerated >= ago(48h)
| where OperationName = "RepositoryPull" and Result = "Success"
| where CallerIpAddress != "192.168.0.0/16"
| group by Repository, CallerIpAddress
Cevap
The query starting with ContainerRegistryRepositoryEvents and using not(ipv4_is_in_range(CallerIpAddress, '192.168.0.0/16')) to filter the subnet is correct.
The correct query targets the ContainerRegistryRepositoryEvents table, which contains data-plane event logs for the Azure Container Registry. It applies filters for the last 48 hours using TimeGenerated > ago(48h), restricts the logs to successful pull operations, excludes the specified subnet using the not(ipv4_is_in_range()) function, and groups the count of operations using summarize PullCount = count() by Repository, CallerIpAddress.
Adım Adım Çözüm
Anahtar Kavram
Selecting correct resource diagnostic tables and performing CIDR-based IP filtering in KQL.