Unable to create MetricAlert using Add-AzMetricAlertRuleV2 #23100
Replies: 2 comments
-
I fixed this issue by uninstalling Az.Monitor and installing Az.Monitor 3.1.0 and went past that error. Add-AzMetricAlertRuleV2 : Exception type: ErrorResponseException, Message: Couldn't find a metric named podReadyPercentage. Make sure the name is correct. Activity ID:
But as per MS doc that is the name listed https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-custom-metrics?tabs=portal So not sure what else I am missing here. Any help anyone? |
Beta Was this translation helpful? Give feedback.
-
I am unable to create alerts for any of the preview ones.. I am using Az.Monitor ver 3.1.0 and Az ver 10.0.1, if that may help.. I needed Az.Monitor ver 3.1.0 for New-AzActionGroup cmdlet to work. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to create a MetricAlert using the following script
Set-AzContext -Subscription "f0bXXXXXXX"
$action = Get-AzActionGroup -ResourceGroupName gze-actgrp-pd-rgp-001 -Name UWDevOps_PD
$actionID = New-AzActionGroup -ActionGroupId $action.id
#Get-AzMetricDefinition -ResourceId "/subscriptions/9ca95ff2-f1fd-447d-9130-9081d2ba12be/resourcegroups/gze-pdi203-pd1-rgp-001/providers/Microsoft.ContainerService/managedClusters/gze-pdi203-pd1-aks-isostr-001"
#set alert dim to pick the right options
$dim = New-AzMetricAlertRuleV2DimensionSelection -DimensionName "Name of the nodepool" -ValuesToInclude "pdi203pd101"
$severity = 1
$RGObject = "gze-pdi203-pd1-rgp-001"
$ResourceId = "/subscriptions/9caXXXXXXX/resourcegroups/gze-pdi203-pd1-rgp-001/providers/Microsoft.ContainerService/managedClusters/gze-pdi203-pd1-aks-isostr-001"
#set alert criteria and counter % Processor Time
$criteria = New-AzMetricAlertRuleV2Criteria -MetricName "podReadyPercentage"
-DimensionSelection $dim
-TimeAggregation average
-Operator LessThan
-Threshold 50
Set-AzContext -Subscription "921XXXX" # subID of the GZ-NP-IT-203-AKSISDUWSYS
Add-AzMetricAlertRuleV2 -Name "UWS-AKS203-ISOSTR-DV1-[Sev0-Critical]-Pods-Ready-Percentage less than 50-V2-CT"
-ResourceGroupName $RGObject
-WindowSize 01:00:00
-Frequency 01:00:00
-TargetResourceId $ResourceId
-Condition $criteria
-ActionGroup $actionID `
-Severity $severity
But then it fails here $actionID = New-AzActionGroup -ActionGroupId $action.id
saying that New-AzActionGroup is not recognized.
I have Az.Monitor 4.5 ver, AZ module ver 10.0.0 and windows PS ver 5.1
On reading some more blogs, it was made clear that New-AzActionGroup was not available in Az.MOnitor 4.5 and was only until ver 3.1.0. I tried to force install 3.1.0 using
Install-Module -Name Az.Monitor -RequiredVersion 3.0.1 -Force
but that did not install 3.0.1 either..
If anyone had found a workaround over this, kindly help me,. I am stuck and unable to move further and any help from the community is highly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions