I want to create a Azure metrics alert for a Webtest that fires in case a number of locations has failed. I can create this manully than it shows a condition name "Whenever the average failed locations is greater than or equal to 1".
I tried to create this with azure cli command:
$aiId = "<Application Insights Azure-Id>"
$actionGroupId = "<Action Group Azure-Id>"
az monitor metrics alert create -n myAlertName -g myRgName --scopes $aiId --condition "avg availabilityResults/failedLocationCount >= 1" --action $actionGroupId --auto-mitigate true --severity 1
failing with: (BadRequest) Couldn't find a metric named availabilityResults/failedLocationCount. Make sure the name is correct.
I also tried --condition "avg failedLocationCount >= 1"`` with same result. Working is --condition "avg availabilityResults/availabilityPercentage <= 85"
but I don't want it not on percentage.
For the manual deployed alert I can show the settings via az monitor metrics alert list
saying:
"criteria": {
"additionalProperties": null,
"componentId": "/subscriptions/xxx",
"failedLocationCount": 1.0,
"odataType": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "/subscriptions/xxx"
}
My last test was to use the Webtest Azure-Id instead of the Application Insights Azure-Id with no success. (Error message: microsoft.insights/webtests is not a supported platform metric namespace)