Azure / Azure/azure-cli-extensions

az monitor metrics alert create - scope for failedLocationCount

Open
#6,274 4 comments 0 reactions 1 assignee Claimed by @AllyW View on GitHub
Auto-Assign Azure CLI Team customer-reported feature-request Monitor Monitor - Metrics
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

- If the issue is to do with Azure CLI 2.0 in-particular, create an issue here at [Azure/azure-cli](https://github.com/Azure/azure-cli/issues)

### 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:
Code: BadRequest
```
What would be the correct format for Scope?
-----

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.