下面是我的ARM模板的精简副本(它所引用的变量很容易解释),我可以在“ Application Insights可用性”窗格中看到可用性测试成功运行,但是在“监视”区域中却从未看到触发过警报门户网站。
{
"type": "Microsoft.Insights/webtests",
"apiVersion": "2015-05-01",
"name": "[variables('pingHealthCheckWebTestName')]",
"location": "[resourceGroup().location]",
"comments": "emea-nl-ams-az is West Europe, emea-gb-db3-azr is North Europe. Notably for historical reasons emea-ru-msa-edge is suprisingly UK South and emea-se-sto-edge is UK West. In the properties.Configuration.WebTest, the documentation states we should delete the Id of the WebTest element and Guid inside the Items->Request element. It's a little nasty having the XML embedded in the JSON (n.b. JSON can't have line breaks), the alernative would be be a build step, however this is overkill as the WebTest format is being deprecated https://devblogs.microsoft.com/devops/cloud-based-load-testing-service-eol/. Notably this will not impact the Application Insights Availability Checker for the forseable future: https://github.com/MicrosoftDocs/vsts-docs/issues/3793 ",
"tags": {
"[concat('hidden-link:', resourceId('microsoft.insights/components/', variables('appInsightsName')))]": "Resource",
"[concat('hidden-link:', resourceId('Microsoft.Web/sites/', variables('webRestApplicationName')))]": "Resource"
},
"properties": {
"SyntheticMonitorId": "[variables('pingHealthCheckWebTestName')]",
"Name": "[variables('pingHealthCheckWebTestName')]",
"Enabled": true,
"Frequency": 300,
"Timeout": 120,
"Kind": "ping",
"RetryEnabled": true,
"Locations": [
{
"Id": "emea-nl-ams-azr"
},
{
"Id": "emea-gb-db3-azr"
},
{
"Id": "emea-ru-msa-edge"
},
{
"Id": "emea-se-sto-edge"
},
{
"Id": "emea-fr-pra-edge"
}
],
"Configuration": {
"WebTest": "[concat('<WebTest Name=\"', variables('pingHealthCheckWebTestName') ,'\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"120\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\"> <Items> <Request Method=\"GET\" Version=\"1.1\" Url=\"', variables('pingHealthCheckUrl') ,'\" ThinkTime=\"0\" Timeout=\"120\" ParseDependentRequests=\"False\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /> </Items> </WebTest>')]"
}
},
"dependsOn": [ "[variables('appInsightsName')]" ]
},
{
"name": "[variables('pingHealthCheckAlertName')]",
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Insights/webtests', variables('pingHealthCheckWebTestName'))]"
],
"tags": {
"[concat('hidden-link:', resourceId('microsoft.insights/components', variables('appInsightsName')))]": "Resource",
"[concat('hidden-link:', resourceId('Microsoft.Insights/webtests', variables('pingHealthCheckWebTestName')))]": "Resource"
},
"properties": {
"description": "[concat('Alert for ', variables('webRestApplicationName'), 'web availability test')]",
"severity": 1,
"enabled": "[parameters('webAvailabilityTestAlertEnabled')]",
"scopes": [
"[resourceId('Microsoft.Insights/webtests',variables('pingHealthCheckWebTestName'))]",
"[resourceId('Microsoft.Insights/components',variables('appInsightsName'))]"
],
"evaluationFrequency": "PT1M",
"windowSize": "PT15M",
"templateType": 0,
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "[resourceId('Microsoft.Insights/webtests', variables('pingHealthCheckWebTestName'))]",
"componentId": "[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]",
"failedLocationCount": 3
},
"actions": [
{
"actionGroupId": "[resourceId('Microsoft.Insights/actionGroups', variables('webAvailabilityActionGroupName'))]"
}
]
}
},
值得注意的是,我非常小心地使用导出的手臂模板,因为application insights documentation表示已弃用的警戒资源。
此外,我还小心地包括了webTestId和componentId属性,这些属性在导出的ARM模板中没有记录或 *不可见,但是如果将警报保存在监视门户中并可以看到,则可以看到拦截http流量。
*我再次遇到了一个确实见过azure monitor section of the docs中记录了webTestId的地方(而不是特定于应用程序见解的文档)。
但是,即使在所有这些调整之后,警报仍然没有触发。
我当前正在进行的尝试:
在门户网站UI中保存Web可用性检查时拦截流量后,在监视器UI中保存警报时,对资源管理器的调用令人惊讶地不同。到目前为止,我只尝试过一次,但是看起来确实有所不同:
这是截取该部分的片段:
...
"templateType": "CorrelatedEvents",
"templateSpecificParameters": null,
"criteriaSchemaId": "WebtestLocationAvailabilityCriteria",
"criteria": {
"webTestId": "[resourceId('Microsoft.Insights/webtests', variables('pingHealthCheckWebTestName'))]",
"componentId": "[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]",
"failedLocationCount": 3
},
请注意,它缺少odata声明,而是具有criteriaSchemaId,并且templateType为CorrelatedEvents而不是0。
所以在查看不同来源时,我看到了各种各样的变化...
但是,这会导致部署时发生内部服务器错误,我目前正在对此进行调查。
更新:
我注意到,与资源管理器API通话时,Web可用性测试UI使用的是有趣的版本号:“ 2017-09-01-preview”,它不是documented as a supported version for the metricsAlerts,但是尝试从ARM模板导致错误“资源响应包含空或无效内容”。所以我有点难过。
答案 0 :(得分:2)
@Alex正如Samara所提到的,导出的手臂模板一直存在问题。请使用可用的模板here。
我刚刚创建了一个部署,一切顺利。从您的问题看来,可用性测试已经存在,您只想创建一个度量标准警报。如果希望仅创建度量标准警报,请从ARM模板中删除“ Microsoft.Insights / webtests”资源类型。在将模板与上述模板进行比较时,指标警报应该可以正常工作。
x = sqrt(pow(dist_left,2) - pow(a_r, 2)) ;
另外,请确保使用正确的命令来部署模板:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string"
},
"pingURL": {
"type": "string"
},
"pingText": {
"type": "string",
"defaultValue": ""
},
"actionGroupId": {
"type": "string"
}
},
"variables": {
"pingTestName": "[concat('PingTest-', toLower(parameters('appName')))]",
"pingAlertRuleName": "[concat('PingAlert-', toLower(parameters('appName')), '-', subscription().subscriptionId)]"
},
"resources": [
{
"name": "[variables('pingAlertRuleName')]",
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"location": "global",
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Insights/components', parameters('appName')))]": "Resource",
"[concat('hidden-link:', resourceId('Microsoft.Insights/webtests', variables('pingTestName')))]": "Resource"
},
"properties": {
"description": "Alert for web test",
"severity": 1,
"enabled": true,
"scopes": [
"[resourceId('Microsoft.Insights/webtests',variables('pingTestName'))]",
"[resourceId('Microsoft.Insights/components',parameters('appName'))]"
],
"evaluationFrequency": "PT1M",
"windowSize": "PT5M",
"templateType": 0,
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "[resourceId('Microsoft.Insights/webtests', variables('pingTestName'))]",
"componentId": "[resourceId('Microsoft.Insights/components', parameters('appName'))]",
"failedLocationCount": 2
},
"actions": [
{
"actionGroupId": "[parameters('actionGroupId')]"
}
]
}
}
]
}
Application Insights现在是Azure Monitor的一部分,并且文档针对Application Insights进行了修改。在此之前,请使用Azure Monitor文档获取最新的Application Insights更新。
答案 1 :(得分:1)
当前存在一个度量指标警报模板丢失所需参数的已知问题,并且使用这些模板会导致内部服务器错误。我还正在与文档作者合作,以使您链接的模板更新为包含所有必需的属性。
您能给我发送电子邮件到azcommunity(at)microsoft.com吗?请包括您的订阅号和此线程的链接。您可以从错误中提供的任何其他调试信息也将有所帮助。这将使我能够采取其他措施来帮助您解决问题。