如何在 Azure 资源模板中编写带有新警报的网络测试?

How to write a webtest with new alert in azure resource template?

随着经典警报迁移到新警报。

我在 Azure 可用性测试中有一个 ping url "Microsoft.Insights/webtest"。

旧的警报类型是 "Microsoft.Insights/alertrules"。

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

旧的 metricName 是 "GSMT_AvRaW"。

如何在 arm 中编写这个新警报(近实时)或如何在 arm 中写入 webtests?

当我在 Availability 中添加新测试时,我可以将 Alert Type Classic 切换为 Near-realtime.It 将生成一个 Alert

而且我无法为网络测试添加新警报条件,我只能单击编辑警报按钮来编辑警报。因为我添加新的Alert时Condition里面不能选择Metric Type

使用此 "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" 可以与旧的可用性测试类似。

如果您查看 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
        }
      }
    ]
  }
}