Application Insights警报。通过ARM模板设置抑制时间

时间:2019-08-28 15:06:47

标签: azure azure-application-insights arm-template azure-template

我想基于“自定义日志搜索”部署Application Insights警报,同时禁止通过ARM模板设置警报。有一个属性"throttlingInMin": 30,,但似乎没有任何作用。

这是模板:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "existingApplicationInsightsName": {
      "type": "string"
    }
  },
  "variables": {},
  "resources": [
    {
      "apiVersion": "2018-04-16",
      "type": "Microsoft.Insights/scheduledQueryRules",
      "name": "Alert1",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('existingApplicationInsightsName')))]": "Resource"
      },
      "properties": {
        "description": "Description1",
        "Enabled": "True",
        "source": {
          "query": "customMetrics | summarize AggregatedValue = count() by bin(timestamp, 15m),client_StateOrProvince",
          "dataSourceId": "[resourceId('microsoft.insights/components', parameters('existingApplicationInsightsName'))]",
          "queryType": "ResultCount"
        },
        "schedule": {
          "FrequencyInMinutes": 40,
          "TimeWindowInMinutes": 40
        },
        "action": {
          "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
          "Severity": "3",
          "aznsAction": {
            "actionGroup": [
              "/subscriptions/131c713e-23e2-4eec-b592-61e975f28e6b/resourceGroups/Alerts/providers/microsoft.insights/actiongroups/Me" 
            ],
            "throttlingInMin": 30,
            "emailSubject": null,
            "customWebhookPayload": null
          },
          "trigger": {
            "ThresholdOperator": "GreaterThan",
            "Threshold": 0
          }
        }
      }
    }
  ]
}

成功部署后。 “抑制警报”复选框仍未选中: enter image description here

1 个答案:

答案 0 :(得分:1)

throttleConsecutiveWindowCount属性旁边的0设置为throttlingInMin,如下所示

 "throttlingInMin": 30,
 "throttleConsecutiveWindowCount": 0,

然后将它们移动到action属性下,如下所示:

"action": {
  "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
  "Severity": "3",
  "aznsAction": {
    "actionGroup": [
      "/subscriptions/131c713e-23e2-4eec-b592-61e975f28e6b/resourceGroups/Alerts/providers/microsoft.insights/actiongroups/Me"
    ],
    "emailSubject": null,
    "customWebhookPayload": null
  },
  "throttlingInMin": 30,
  "throttleConsecutiveWindowCount": 0,
  "trigger": {
    "ThresholdOperator": "GreaterThan",
    "Threshold": 0
  }
}