如何在azure资源模板中编写带有新警报的webtest?

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

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

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

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

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

旧的metricName是“GSMT_AvRaW”。

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

当我在可用性中添加New Test时,我可以将Alert Type Classic切换到Near-realtime。它将生成一个Alert

我无法为webtest添加新警报条件,我只能单击编辑警报按钮来编辑警报。因为在添加新警报时,不能在条件中选择度量标准类型。

azure alert azure-resource-manager
2个回答
2
投票

如果您查看资源浏览器并导航到手动创建的(近实时)警报,您应该看到如下定义的“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
        }
      }
    ]
  }
}

0
投票

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

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