Azure ARM: для этого оповещения нет целевого ресурса - PullRequest
0 голосов
/ 27 апреля 2018

Я пытаюсь привязать microsoft.insights/alertrules к Microsoft.Web/sites во время развертывания ARM в Azure.

Ошибка: There is no target resource for this alert CPU default-app-name-plan-ins-westeurope-default-environment

Я создал ресурсы в шаблоне, используя «сценарий автоматизации» вручную созданных ресурсов в качестве образца.

Предупреждение:

{
  "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

Полный код здесь и параметры здесь

Что я делаю не так?

1 Ответ

0 голосов
/ 01 июня 2018

У меня было то же сообщение об ошибке, но оно было устранено путем добавления свойств $type к conditions и actions и tag для ресурса, следуя примеру из этого шаблона

Так это выглядит так:

  {
  "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": []
      }
    ]
  }
}
...