[英]To create the Log Analytics alerts using Azure Power Shell or Azure CLI
I'm trying to create alerts in LogAnlytics in azure portal, need to create 6 alerts for 5 db's, so have to create 30 alerts manually and is time consuming. 我正在尝试在azure门户中的LogAnlytics中创建警报,需要为5个数据库创建6个警报,因此必须手动创建30个警报,这很耗时。
Hence would require an automated approach. 因此,将需要一种自动化的方法。
Tried to create via Creating Alerts Using Azure PowerShell , but this creates the alerts in the Alerts Classic under Monitor but this is not what is required, require it to be created in Log Analytics. 尝试通过使用Azure PowerShell创建警报来创建,但这会在Monitors下的Alerts Classic中创建警报,但这不是必需的,需要在Log Analytics中创建。
Next approach was via Create a metric alert with a Resource Manager template but this was metric alert and not LogAnalytics alert 下一种方法是通过使用Resource Manager模板创建度量标准警报,但这是度量标准警报,而不是LogAnalytics警报
At last tried Create and manage alert rules in Log Analytics with REST API , but this is a tedious process need to get the search id, schedule id, threshold id and action id. 最后尝试使用REST API在Log Analytics中创建和管理警报规则 ,但这是一个繁琐的过程,需要获取搜索ID,计划ID,阈值ID和操作ID。 Even after trying to create the threshold id or action id the error I'm facing is "404 - File or directory not found." 即使尝试创建阈值ID或操作ID之后,我仍然遇到的错误是“ 404-找不到文件或目录”。 (as in the image). (如图所示)。
Could someone please suggest me on how should this be proceeded, or is there any other way to create alerts apart from the manual creation? 有人可以建议我如何进行此操作,或者除了手动创建以外,还有其他方法可以创建警报吗?
If you use the Add activity log alert
to add a rule, you will find it in the Alerts of Log Analytics in the portal. 如果使用Add activity log alert
来添加规则,则可以在门户网站的日志分析 警报中找到它。
Please refer to the Log Analytics Documentation , 请参考Log Analytics文档 ,
Alerts are created by alert rules in Azure Monitor and can automatically run saved queries or custom log searches at regular intervals. 警报是由Azure Monitor中的警报规则创建的,可以定期自动运行保存的查询或自定义日志搜索。
Update : 更新 :
Please refer to my test screenshots, I think you should check the specific resource group or other things, etc. 请参考我的测试屏幕截图,我认为您应该检查特定的资源组或其他内容,等等。
Even so, activity log alert belongs to the alerts(classic) , alerts is a new metric alert type . 即便如此,活动日志警报仍属于警报(经典) , 警报是一种新的指标警报类型 。 You could check the link new metric alert type
in this article , it points the alerts . 您可以在本文中检查链接new metric alert type
,它指向警报 。 it is not supported by powershell and CLI currently. 当前,PowerShell和CLI不支持它。
Please refer to: 请参阅:
1. Use PowerShell to create alerts for Azure services 1. 使用PowerShell为Azure服务创建警报
2. Use the cross-platform Azure CLI to create classic metric alerts in Azure Monitor for Azure services 2. 使用跨平台的Azure CLI在Azure Monitor for Azure服务中创建经典指标警报
As mentioned in the two articles: 如两篇文章所述:
This article describes how to create older classic metric alerts. 本文介绍如何创建较旧的经典指标警报。 Azure Monitor now supports newer, better metric alerts. Azure Monitor现在支持更新更好的指标警报。 These alerts can monitor multiple metrics and allow for alerting on dimensional metrics. 这些警报可以监视多个指标,并允许对维度指标进行警报。 PowerShell support for newer metric alerts is coming soon. PowerShell对较新的度量标准警报的支持即将推出。
This article describes how to create older classic metric alerts. 本文介绍如何创建较旧的经典指标警报。 Azure Monitor now supports newer, better metric alerts. Azure Monitor现在支持更新更好的指标警报。 These alerts can monitor multiple metrics and allow for alerting on dimensional metrics. 这些警报可以监视多个指标,并允许对维度指标进行警报。 Azure CLI support for newer metric alerts is coming soon. Azure CLI对较新的度量标准警报的支持即将推出。
@Shashikiran : You can use the script published in the GITHUB https://github.com/microsoft/manageability-toolkits/tree/master/Alert%20Toolkit @Shashikiran:您可以使用GITHUB中发布的脚本https://github.com/microsoft/manageability-toolkits/tree/master/Alert%20Toolkit
This can create a few sample alerts. 这可以创建一些示例警报。 For now we have included some sample core machine monitoring alerts like CPU , hardware failures , SQL , etc... Also these are only the log alerts. 目前,我们已经包括一些示例性的核心机器监视警报,例如CPU,硬件故障,SQL等等。这些仅仅是日志警报。 You can use this as a sample code and come up with your code. 您可以将其用作示例代码并提出您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.