如何在Azure资源模板中编写具有新警报的Web测试?

Hai*_*aAi 2 alert azure azure-resource-manager

从经典警报迁移到新警报。

我在Azure可用性测试中有一个ping URL“ Microsoft.Insights / webtest”。

旧的警报类型为“ Microsoft.Insights / alertrules”。

条件类型为“ Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition”。

旧的metricName是“ GSMT_AvRaW”。

如何手动编写此新警报(近实时),或如何手动编写到Webtest中?

当我在可用性中添加新测试时,可以将警报类型经典切换为近实时,它将生成警报

AddNewTestAlert

而且我无法为Webtest添加“新警报”条件,只能单击“编辑警报”按钮以编辑警报。因为添加新警报时无法在“条件”中选择“度量标准类型”。

小智 5

如果查看Resource Explorer并导航到手动创建(近实时)警报,则应该看到定义如下的“ critera”对象。这是似乎有效的资源的完整示例。为每个值创建一些变量:

{
  "type": "Microsoft.Insights/metricAlerts",
  "apiVersion": "2018-03-01",
  "name": "[variables('alertName')]",
  "location": "global",
  "dependsOn": [],
  "tags": {
    "[concat('hidden-link:', variables('applicationInsightsResourceId'))]": "Resource",
    "[concat('hidden-link:', variables('webtestResourceId'))]": "Resource"
  },
  "properties": {
    "description": "[concat('Alert for ', parameters('availibilityTestName'))]",
    "severity": 4,
    "enabled": true,
    "scopes": [
      "[variables('webtestResourceId')]",
      "[variables('applicationInsightsResourceId')]"
    ],
    "evaluationFrequency": "PT5M",
    "windowSize": "PT15M",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
      "webTestId": "[variables('webtestResourceId')]",
      "componentId": "[variables('applicationInsightsResourceId')]",
      "failedLocationCount": 3
    },
    "actions": [
      {
        "actionGroupId": "[resourceId('microsoft.insights/actiongroups', 'webhook')]",
        "webHookProperties": {
           // Some properties to send to webhook
        }
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)