使用Azure Power Shell或Azure CLI创建日志分析警报 [英] To create the Log Analytics alerts using Azure Power Shell or Azure CLI

查看:152
本文介绍了使用Azure Power Shell或Azure CLI创建日志分析警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在azure门户的LogAnlytics中创建警报,需要为5个数据库创建6个警报,因此必须手动创建30个警报,这很耗时.

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.

因此,将需要一种自动化的方法.

Hence would require an automated approach.

试图通过创建警报使用Azure PowerShell ,但这会在Monitor下的Alerts Classic中创建警报,但这不是必需的,需要在Log Analytics中创建.

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.

下一种方法是通过

Next approach was via Create a metric alert with a Resource Manager template but this was metric alert and not LogAnalytics alert

最后尝试创建和管理警报使用REST API的Log Analytics中的规则,但这是一个繁琐的过程,需要获取搜索ID,计划ID,阈值ID和操作ID.即使尝试创建阈值ID或操作ID之后,我仍然遇到的错误是"404-找不到文件或目录". (如图中所示).

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. Even after trying to create the threshold id or action id the error I'm facing is "404 - File or directory not found." (as in the image).

有人可以建议我如何进行此操作,或者除了手动创建以外,还有其他方法可以创建警报吗?

推荐答案

如果使用Add activity log alert添加规则,则会在 Log Analytics .

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.

请参考日志分析文档

警报是由 Azure Monitor 中的警报规则创建的,可以定期自动运行保存的查询或自定义日志搜索.

Alerts are created by alert rules in Azure Monitor and can automatically run saved queries or custom log searches at regular intervals.

更新:

请参考我的测试屏幕截图,我认为您应该检查特定的资源组或其他内容,等等.

Please refer to my test screenshots, I think you should check the specific resource group or other things, etc.

即使如此,活动日志警报也属于警报(经典)警报 new metric alert type 在此

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. it is not supported by powershell and CLI currently.

请参考:

1.使用PowerShell创建警报用于Azure服务

2.使用跨平台的Azure CLI在Azure Monitor for Azure服务中创建经典的指标警报

如两篇文章所述:

本文介绍了如何创建较旧的经典指标警报. Azure Monitor现在支持更新更好的指标警报.这些警报可以监视多个指标,并允许对维度指标进行警报. PowerShell对较新的指标警报的支持即将推出.

本文介绍了如何创建较旧的经典指标警报. Azure Monitor现在支持更新更好的指标警报.这些警报可以监视多个指标,并允许对维度指标进行警报. Azure CLI对较新的指标警报的支持即将推出.

This article describes how to create older classic metric alerts. Azure Monitor now supports newer, better metric alerts. These alerts can monitor multiple metrics and allow for alerting on dimensional metrics. Azure CLI support for newer metric alerts is coming soon.

这篇关于使用Azure Power Shell或Azure CLI创建日志分析警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆