如何列出在Azure中的度量警报使用PowerShell

问题描述 投票:1回答:1

是否有可能列出Azure的指标警报使用PowerShell?我只能找到:

GET-AzureRmAlertRule

但是,只有给我的“经典”的警报,而不是度量警报我在门户网站。

我可以通过使用metricalerts/listbyresourcegroup终点获得通过API的所有指标警报。

任何人,对于是否有可能通过PowerShell脚本,让他们任何的想法?

azure azure-powershell azureportal
1个回答
0
投票

你可以尝试使用通用Get-AzureRmResource cmdlet和资源型过滤器,例如

# Retrieve alert rule
$rule = Get-AzureRmResource -ResourceType Microsoft.Insights/alertRules -ResourceGroupName "myResourceGroup" -Name "my-rule";

# Retrieve alerts for this rule
Get-AzureRmAlertHistory -ResourceId $rule.ResourceId -StartTime (Get-Date).AddHours(-1) -EndTime (Get-Date)
© www.soinside.com 2019 - 2024. All rights reserved.