你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Get-AzMetricAlertRuleV2
获取 V2(非经典)指标警报规则
语法
Get-AzMetricAlertRuleV2
[-ResourceGroupName <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzMetricAlertRuleV2
-ResourceGroupName <String>
-Name <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzMetricAlertRuleV2
-ResourceId <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
Get-AzMetricAlertRuleV2 cmdlet 按指标警报规则的名称或 URI 获取指标警报规则,或者从指定的资源组或订阅获取所有指标警报规则。
示例
示例 1:获取当前订阅中的所有指标警报规则
Get-AzMetricAlertRuleV2
TargetResourceId : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricResourceGroup/providers/Microsoft.KeyVault/vaults/GenevaRPKeyVault
Criteria : {Metric1}
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/sampleresourcegroup/providers/Microsoft.Insights/actiongroups/scnewactiongroup}
ResourceGroup : metricResourceGroup
Description : fdafda
Severity : 3
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricResourceGroup/providers/Microsoft.KeyVault/vaults/GenevaRPKeyVault}
EvaluationFrequency : 00:01:00
WindowSize : 00:05:00
TargetResourceType :
TargetResourceRegion :
AutoMitigate :
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricResourceGroup/providers/Microsoft.Insights/metricAlerts/Rule1
Name : Rule1
Type : Microsoft.Insights/metricAlerts
Location : global
Tags : {}
Criteria : {Metric1}
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/sampleresourcegroup/providers/Microsoft.Insights/actiongroups/scnewactiongroup}
ResourceGroup : SampleResourceGroup
Description : Testing 1 minute granuarity
Severity : 3
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo4}
EvaluationFrequency : 00:01:00
WindowSize : 00:01:00
TargetResourceType : Microsoft.Compute/virtualMachines
TargetResourceRegion : eastus
AutoMitigate : True
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Insights/metricAlerts/Rule2
Name : Rule2
Type : Microsoft.Insights/metricAlerts
Location : global
Tags : {}
此命令获取当前订阅中的所有指标警报规则。
示例 2:获取资源组中的所有指标警报规则
Get-AzMetricAlertRuleV2 -ResourceGroupName metricAlertsRG
Criteria : {Metric1}
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/pr
oviders/Microsoft.Insights/actiongroups/emails}
ResourceGroup : metricAlertsRG
Description : Test Classic VM alert - CPU Usage
Severity : 3
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertsRG/providers/Micr
osoft.ClassicCompute/virtualMachines/VM1}
EvaluationFrequency : 00:01:00
WindowSize : 00:05:00
TargetResourceType : Microsoft.ClassicCompute/virtualMachines
TargetResourceRegion : southcentralus
AutoMitigate : True
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertsRG/providers/micro
soft.insights/metricAlerts/Test%20Classic%20VM%20alert%20-%20CPU%20Usage
Name : Test Classic VM alert - CPU Usage
Type : Microsoft.Insights/metricAlerts
Location : global
Tags : {}
此命令获取名为 metricAlertsRG 的资源组中的所有指标警报规则。
示例 3:按名称获取指标警报规则
Get-AzMetricAlertRuleV2 -ResourceGroupName metricAlertsRG -Name PS3182019
Criteria : {metric1}
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/demo}
ResourceGroup : metricAlertsRG
Description : This is description
Severity : 1
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertsRG/providers/Microsoft.Compute/virtualMachines/VM1,
/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertsRG/providers/Microsoft.Compute/virtualMachines/VM2}
EvaluationFrequency : 00:05:00
WindowSize : 00:05:00
TargetResourceType : Microsoft.Compute/virtualMachines
TargetResourceRegion : eastus
AutoMitigate :
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertsRG/providers/Microsoft.Insights/metricAlerts/PS3182019
Name : PS3182019
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
此命令获取名为 metricAlertsRG 的资源组中名为PS3182019的指标警报规则。
示例 4:按 ruleID 获取指标警报规则
Get-AzMetricAlertRuleV2 -ResourceId /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Insights/metricAlerts/MyMetricAlertRule
TargetResourceId : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Insights/components/alertstestFunction
Criteria : {Metric1}
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/emails}
ResourceGroup : SampleResourceGroup
Description : Test Description
Severity : 3
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Insights/components/alertstestFunction}
EvaluationFrequency : 00:01:00
WindowSize : 00:05:00
TargetResourceType :
TargetResourceRegion :
AutoMitigate :
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/SampleResourceGroup/providers/Microsoft.Insights/metricAlerts/MyMetricAlertRule
Name : MyMetricAlertRule
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
此命令获取具有给定资源 ID 的指标警报规则。
参数
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Name
指标警报规则的名称
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ResourceGroupName
The ResourceGroupName
类型: | String |
别名: | ResourceGroup |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ResourceId
指标警报规则的规则 ID
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |