如何使用PowerShell在Azure中列出指标警报 [英] How to list metric alerts in Azure with PowerShell
本文介绍了如何使用PowerShell在Azure中列出指标警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用PowerShell在Azure中列出指标警报? 我只能找到:
Is it possible to list metric alerts in Azure with PowerShell? I could only find:
Get-AzureRmAlertRule
Get-AzureRmAlertRule
但是,这只会给我经典"警报,而不会给我门户网站上的度量标准警报.
But that only gives me the "classic" alerts and not the metric alerts I have in the portal.
我可以使用对是否有可能通过PowerShell脚本获取它们有任何想法吗?
Anyone that has any idea on if it is possible to get them through a PowerShell script?
推荐答案
You could try using the generic Get-AzureRmResource
cmdlet with a resource type filter, e.g.
# 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)
这篇关于如何使用PowerShell在Azure中列出指标警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文