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

Not able to create Metric Alert using Azure CLI

Open satheeshpayoda opened this issue 5 years ago • 7 comments

Describe the bug

I'm trying to create CPU alert for VM using Azure CLI command but failing with weird error. Even i set region using --region explicitly but same error.

Command Name az monitor metrics alert create

Errors:

BadRequestError: The following resources were not found under the region global: /subscriptions/<SUB_ID>/resourceGroups/<RG_NAME>/providers/Microsoft.Compute/virtualMachines/<VM Name>. Activity ID: xxxxxx.

To Reproduce:

Steps to reproduce the behavior.

  • az monitor metrics alert create -n {} -g {} --scopes {} --condition {} --window-size {} --evaluation-frequency {} --description {}

Expected Behavior

CPU Alert should be created for VM but it is failing with above error. I think some issue with target region.

Environment Summary

Linux-4.4.0-148-generic-x86_64-with-debian-jessie-sid
Python 3.6.10
Installer: DEB

azure-cli 2.17.1

Extensions:
aks-preview 0.4.71
application-insights 0.1.13
storage-preview 0.7.0

Additional Context

satheeshpayoda avatar Jan 13 '21 06:01 satheeshpayoda

monitor

yonzhan avatar Jan 13 '21 07:01 yonzhan

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @SameergMS, @dadunl.

Issue Details

Describe the bug

I'm trying to create CPU alert for VM using Azure CLI command but failing with weird error. Even i set region using --region explicitly but same error.

Command Name az monitor metrics alert create

Errors:

BadRequestError: The following resources were not found under the region global: /subscriptions/<SUB_ID>/resourceGroups/<RG_NAME>/providers/Microsoft.Compute/virtualMachines/<VM Name>. Activity ID: xxxxxx.

To Reproduce:

Steps to reproduce the behavior.

  • az monitor metrics alert create -n {} -g {} --scopes {} --condition {} --window-size {} --evaluation-frequency {} --description {}

Expected Behavior

CPU Alert should be created for VM but it is failing with above error. I think some issue with target region.

Environment Summary

Linux-4.4.0-148-generic-x86_64-with-debian-jessie-sid
Python 3.6.10
Installer: DEB

azure-cli 2.17.1

Extensions:
aks-preview 0.4.71
application-insights 0.1.13
storage-preview 0.7.0

Additional Context

Author: satheeshpayoda
Assignees: kairu-ms
Labels:

Monitor, Service Attention

Milestone: S182

ghost avatar Jan 14 '21 02:01 ghost

We just had the same issue. For info, running the following command used to work before the az upgrade to 2.18.0 : az monitor metrics alert create -n <Name> -g <ResourceGroup> --window-size <Value> --evaluation-frequency <Value> --condition <SomeValidCondition> --description "AnAlert!" --region <SomeRegion> --scope "/subscriptions/<SubId>/resourceGroups/<ResourceGroup>/providers/microsoft.insights/components/<AppInsightComponentId>"

Error code: BadRequestError: The following resources were not found under the region global: /subscriptions/<SubId>/resourceGroups/<ResourceGroup>/providers/microsoft.insights/components/<AppInsightComponentId>

If I retry the command shortly after I will get the following error: ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/<SubId>/resourceGroups/<ResourceGroup>/providers/Microsoft.Insights/metricAlerts/<AlertName>?api-version=2018-03-01 (Caused by ResponseError('too many 500 error responses',))

Version prior the upgrade:

az version
{
  "azure-cli": "2.15.1",
  "azure-cli-core": "2.15.1",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
  "application-insights": "0.1.11"
  }
}

Version after upgrade

az version
{
  "azure-cli": "2.18.0",
  "azure-cli-core": "2.18.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "application-insights": "0.1.13"
  }
}

951p avatar Jan 26 '21 16:01 951p

Having the same issue. Though I manage to create some alerts based on metrics. I got this error when trying to create an alert for PIP metrics Update; Seems like it is a bit more random, as I now have problems creating the same alerts as I managed to in other subscriptions.

I can create alerts through the portal though

❯ az version
{
  "azure-cli": "2.18.0",
  "azure-cli-core": "2.18.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "aks-preview": "0.4.72",
    "azure-devops": "0.18.0",
    "azure-firewall": "0.8.0",
    "db-up": "0.2.0"
  }
}

mortenlerudjordet avatar Jan 27 '21 11:01 mortenlerudjordet

Having same issue with azure cli

script -: az monitor metrics alert create -n <alertname> --region <region> -g <rg> --scopes "/subscriptions/<sbid>/resourceGroups/<Rgname>/providers/Microsoft.Insights/components/<application insight name>" --condition "count <metric name> alert >= 1" --window-size 1m --evaluation-frequency 1m --action {action id} --description "test alert" --severity 2

Error :- BadRequestError: The following resources were not found under the region global:

TanishGuleria avatar Feb 02 '21 09:02 TanishGuleria

Same here. I get the same error when trying on an App Service, but works ok on, for example, Front Door.

DannyArr avatar Feb 02 '21 14:02 DannyArr

It will be fixed in next CLI version, which will be released at 02/09/2021.

kairu-ms avatar Feb 03 '21 02:02 kairu-ms