gpt4 book ai didi

azure - Web 测试中未启用 Azure ARM 模板中的警报规则

转载 作者:行者123 更新时间:2023-12-03 01:49:34 25 4
gpt4 key购买 nike

我正在使用 ARM 模板以编程方式创建 Application Insights Web 测试和警报规则。 ARM模板基于this article

Web 测试和警报规则均已创建,但 Web 测试的 Alerts 属性已禁用。警报规则列在警报规则边栏选项卡上,但不在Webtests部分中列出,而是在其他部分中列出,见图:

enter image description here

为了获得启用警报的网络测试,我缺少什么?

ARM 模板(WebTest 属性的值已被 SO 删除):

{  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",  "contentVersion": "1.0.0.0",  "parameters": {    "webTestName": {      "type": "string"    },    "appName": { "type": "string" }  },  "variables": {    "url": "http://www.google.com",    "testName": "[concat(parameters('webTestName'), '-', toLower(parameters('appName')))]",    "alertRuleName": "[concat(parameters('webTestName'), '-', toLower(parameters('appName')), '-', subscription().subscriptionId)]"  },  "resources": [    {      "name": "[parameters('appName')]",      "type": "Microsoft.Insights/components",      "apiVersion": "2014-04-01",      "kind": "web",      "location": "Central US",      "properties": {        "Application_Type": "web",        "Flow_Type": "Redfield",        "Request_Source": "Unknown",        "Name": "[parameters('appName')]",        "PackageId": null,        "ApplicationId": "[parameters('appName')]"      },      "tags": {        "applicationType": "web"      }    },    {      "name": "[variables('testName')]",      "apiVersion": "2014-04-01",      "type": "microsoft.insights/webtests",      "location": "Central US",      "dependsOn": [        "[resourceId('Microsoft.Insights/components', parameters('appName'))]"      ],      "tags": {        "[concat('hidden-link:', resourceId('Microsoft.Insights/components', parameters('appName')))]": "Resource"      },      "properties": {        "Name": "[parameters('webTestName')]",        "Description": "description",        "Enabled": true,        "Frequency": 300,        "Timeout": 120,        "Kind": "ping",        "RetryEnabled": true,        "Locations": [          {            "Id": "us-il-ch1-azr"          },          {            "Id": "emea-se-sto-edge"          },          {            "Id": "emea-nl-ams-azr"          }        ],        "Configuration": {          "WebTest": "[concat('                                        ')]"        },        "SyntheticMonitorId": "[variables('testName')]"      }    },    {      "name": "[variables('alertRuleName')]",      "apiVersion": "2014-04-01",      "type": "Microsoft.Insights/alertrules",      "location": "East US",      "dependsOn": [        "[resourceId('Microsoft.Insights/webtests', variables('testName'))]"      ],      "tags": {        "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appName')))]": "Resource",        "[concat('hidden-link:', resourceId('microsoft.insights/webtests', variables('testName')))]": "Resource"      },      "properties": {        "name": "[variables('alertRuleName')]",        "description": "Alert for availability test",        "isEnabled": true,        "condition": {          "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",          "odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",          "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/webtests', variables('testName'))]",            "metricName": "GSMT_AvRaW"          },          "windowSize": "PT5M",          "failedLocationCount": 2        },        "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": []          }        ]      }    }  ]}

最佳答案

事实证明,resourceUri 的值区分大小写。解决方案:

"variables": {
...
"testName": "[toLower(concat(parameters('webTestName'), '-', toLower(parameters('appName'))))]",
"alertRuleName": "[toLower(concat(parameters('webTestName'), '-', toLower(parameters('appName')), '-', subscription().subscriptionId))]"
},

关于azure - Web 测试中未启用 Azure ARM 模板中的警报规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40510260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com