Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
381 stars 1.2k forks source link

az monitor metrics alert create - scope for failedLocationCount #6274

Open Gholie opened 1 year ago

Gholie commented 1 year ago

Related command

$result = az monitor metrics alert create `
            --name $AlertName `
            --subscription $SubscriptionId `
            --resource-group $ResourceGroup `
            --description $AlertDescription `
            --severity $AlertSeverity `
            --scopes $scope `
            --condition $condition `
            --evaluation-frequency $evaluationFrequency `
            --window-size $WindowSizeInMinutes `
            --auto-mitigate $true `
            @actionGroup | ConvertFrom-Json

Extension name (the extension in question)

monitor metrics alert

Description of issue (in as much detail as possible)

I am trying to create a alert for a Application Insight web test which should have failedLocationCount as trigger. Doing this in the portal gives a resource scope that looks like this:

"scopes": [
            "/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/webtests/webTestName",
            "/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/components/componentName"
        ],

Dimension in manual create:

"criteria": {
            "failedLocationCount": 2,
            "webTestId": "/subscriptions/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/webtests/webTestName",
            "componentId": "/subscriptions/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/components/componentName",
            "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"

Dimension in Az Cli: "count failedLocationCount > 2" Scope in Az Cli:

/subscriptions/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/webtests/webtestName
/subscriptions/subscriptions/SubscriptionId/resourcegroups/ResourceGroup/providers/microsoft.insights/components/componentName

When trying to replicate this with Azure Cli I get the following error: ERROR: Multiple scopes should be the same resource type.

When only doing one of the scopes I get the following: {"code":"BadRequest","message":"microsoft.insights/webtests is not a supported platform metric namespace

Or

ERROR: (BadRequest) Couldn't find a metric named failedLocationCount. Make sure the name is correct. Activity ID: <id>
Code: BadRequest

What would be the correct format for Scope?

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

Gholie commented 1 year ago

Any updates on this?

Gholie commented 1 year ago

Hi, any updates? :)

AllyW commented 10 months ago

@Gholie request error forwarded to service team