Azure中的活动日志警报

问题描述 投票:0回答:2

我在Azure中创建了一个活动日志警报,它针对Application Insights实例执行自定义日志搜索。警报正在运行,并且已通过我设置的频道通知操作组。我遇到的问题是在我们用于部署资源的arm模板中创建该警报。

查看门户网站中的自动化脚本时,警报将被忽略并且不可见。 (microsoft.insights / scheduledqueryrules)我无法在线找到有关如何在模板中编写条件的任何信息,因此它适用于自定义日志搜索。

有关如何查找条件信息或如何从门户网站中提取模板以获取这些警报的任何建议。

azure azure-resource-manager arm-template
2个回答
2
投票

这是一个ARM模板部件,用于创建带有计划查询的警报。它还添加了一系列操作组,可在触发警报时收到通知:

{
  "name": "[parameters('scheduleQueryMonitorApplicationError')]",
  "type": "microsoft.insights/scheduledqueryrules",
  "apiVersion": "2018-04-16",
  "location": "[resourceGroup().location]",
  "tags": {
    "[concat('hidden-link:', resourceGroup().id, '/resourceGroups/', parameters('resourceGroupName'), '/providers/microsoft.insights/components/', parameters('applicationInsightsName'))]": "Resource"
  },
  "properties": {
    "description": "[parameters('scheduleQueryMonitorApplicationError')]",
    "enabled": "true",
    "source": {
      "query": "traces | where severityLevel == 3",
      "queryType": "ResultCount",
      "dataSourceId": "[resourceId('microsoft.insights/components', parameters('applicationInsightsName'))]"
    },
    "schedule": {
      "frequencyInMinutes": 5,
      "timeWindowInMinutes": 5
    },
    "action": {
      "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
      "severity": "3",
      "aznsAction": {
        "actionGroup": "[array( resourceId('microsoft.insights/actiongroups', parameters('actionGroupName')) )]"
      },
      "trigger": {
        "threshold": 1,
        "thresholdOperator": "GreaterThan"
      }
    }
  },
  "dependsOn": [
    "[resourceId('microsoft.insights/components', parameters('applicationInsightsName'))]"
  ]
},

0
投票

请参阅this stackoverflow线程,其中提出了类似的问题。 Elfocrash提到他写了一篇关于它的博客文章,解释它是如何工作的。我尝试了他的方法,它的工作原理。

© www.soinside.com 2019 - 2024. All rights reserved.