Azure ARM:此警报没有目标资源 [英] Azure ARM: There is no target resource for this alert

查看:65
本文介绍了Azure ARM:此警报没有目标资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在天蓝色的ARM部署期间将microsoft.insights/alertrules绑定到Microsoft.Web/sites.

I'm trying to tie microsoft.insights/alertrules to Microsoft.Web/sites during ARM deployment at azure.

错误是:There is no target resource for this alert CPU default-app-name-plan-ins-westeurope-default-environment

我使用手动创建的资源的自动化脚本"作为示例在模板中创建了资源.

I created the resources in the template using 'automation script' of manually created resources as sample.

警报规则:

{
  "type": "microsoft.insights/alertrules",
  "location": "[variables('location')]",
  "apiVersion": "2016-03-01",
  "name": "[concat('CPU ', variables('insightComponentName'))]",
  "dependsOn": [ "[resourceId('microsoft.insights/components', variables('insightComponentName'))]" ],
  "tags": "[parameters('tags')]",
  "properties": {
    "name": "[concat('CPU ', variables('insightComponentName'))]",
    "isEnabled": true,
    "condition": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "[resourceId('microsoft.insights/components', variables('insightComponentName'))]",
        "metricNamespace": null,
        "metricName": "performanceCounter.percentage_processor_time_normalized.value"
      },
      "operator": "GreaterThan",
      "threshold": 85,
      "windowSize": "PT5M"

    },
    "action": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
      "sendToServiceOwners": false,
      "customEmails": [
        "[parameters('alertReceiver')]"
      ]
    }
  }
},

使用New-AzureRmResourceGroupDeployment -Verbose -ResourceGroupName rg.test.ARM -TemplateFile azuredeploy.json -TemplateParameterFile azuredeploy.parameters.json -DeploymentDebugLogLevel All

完整代码位于此处和参数在此处

The full code is here and parameters are here

我在做什么错了?

推荐答案

我遇到了相同的错误消息,但是通过将$type属性添加到conditionsactions以及资源的tag来解决了该错误消息,以示例从这个模板中

I had the same error message but resolved it by adding the $type properties to conditions and actions, and a tag for the resource, following the example from this template

它看起来像:

  {
  "name": "[variables('responseAlertName')]",
  "type": "Microsoft.Insights/alertrules",
  "apiVersion": "2014-04-01",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[resourceId('Microsoft.Insights/components', variables('appInsName'))]"
  ],
  "tags": {
    "[concat('hidden-link:', resourceId('Microsoft.Insights/components', variables('appInsName')))]": "Resource"
  },
  "properties": {
    "name": "[variables('responseAlertName')]",
    "description": "response time alert",
    "isEnabled": true,
    "condition": {
      "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "[resourceId('microsoft.insights/components', variables('appInsName'))]",
        "metricName": "request.duration"
      },
      "threshold": "[parameters('responseTime')]",
      "windowSize": "PT5M"
    },
    "actions": [
      {
        "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
        "sendToServiceOwners": true,
        "customEmails": []
      }
    ]
  }
}

这篇关于Azure ARM:此警报没有目标资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆