azure-cli-extensions icon indicating copy to clipboard operation
azure-cli-extensions copied to clipboard

az sentinel alert-rule list command does not return the expected number of alert rules

Open calintje opened this issue 4 years ago • 4 comments

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug az sentinel alert-rule list command does not return the expected number of alert rules. From the portal, we see that we have 181 alert rules enabled, but the az command only returns 143. This is true when using the Azure REST API directly as well.

To Reproduce

  • see the number of alert-rules enabled from Microsoft Sentinel in the Azure portal.
  • request the number of alert rules via the azure cli or via the Azure REST API:
$url = "https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<rg_nam>/providers/Microsoft.OperationalInsights/workspaces/<workspace_name>/providers/Microsoft.SecurityInsights/alertRules?api-version=2020-01-01"
$method = "GET"
$token = Get-AzAccessToken -ResourceUrl "https://management.azure.com/"
$token = $token.Token
$headers = @{Authorization = "Bearer $token"}
$response = Invoke-RestMethod -Uri $url -Method $method -Headers $headers
$response.value.Count

Expected behavior The number of alert-rules should be equal.

calintje avatar Dec 07 '21 22:12 calintje

Routing to service team.

jiasli avatar Dec 08 '21 02:12 jiasli

Thank you. When can I expect an answer?

calintje avatar Dec 13 '21 13:12 calintje

Any updates on this? I tested and It looks like it's fixed in the 2021-10-01-preview of the REST API. Any idea when the preview will be merged into the stable and Azure CLI will support it?

cabneydp avatar Apr 11 '22 15:04 cabneydp

After some digging, I found that the missing alert rules are of the type 'Anomaly'. According to this article, these rules are automatically added to the Sentinel configuration:

"In public preview, all built-in anomaly rules are enabled by default in your workspace. Even though all anomaly rules are enabled, only those anomaly rules that have the required data in your workspace will fire anomalies."

However, these alert-rules are (still) not returned with the command az sentinel alert-rule list.

calintje avatar May 09 '22 11:05 calintje