gpt4 book ai didi

azure - 如何查找 Azure 警报的自动化参数?

转载 作者:行者123 更新时间:2023-12-03 01:41:07 24 4
gpt4 key购买 nike

我已在 Azure 门户中针对平均响应时间指标设置了警报。现在我想自动化它,以便在每个新部署上设置此警报。当我转到资源组下的自动化脚本选项卡时,我可以看到警报指标已添加,但我找不到警报条件参数,有人知道它们是在哪里定义的吗?

我在 docs 中找到了此资源,我已经关注了。

这部分我可以在我的自动化脚本中看到

"resources": [
{
"comments": "Generalized from resource: '/subscriptions/XXX/resourceGroups/resourcegroup-dev-weu/providers/microsoft.insights/metricAlerts/response-time-avg'.",
"type": "microsoft.insights/metricAlerts",
"name": "[parameters('metricAlerts_response_time_avg_name')]",
"apiVersion": "2018-03-01",
"location": "global",
"tags": {},
"scale": null,
"properties": {
"description": "Alert if the response time get above 1 second on average for the last 1 minute, 1 minute intervals.",
"severity": 3,
"enabled": true,
"scopes": [
"/subscriptions/XXX/resourceGroups/resourcegroup-dev-weu/providers/Microsoft.Web/sites/webapp-dev-weu"
],
"evaluationFrequency": "PT1M",
"windowSize": "PT1M",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
},
"actions": [
{
"actionGroupId": "[parameters('metricAlerts_response_time_avg_actionGroupId')]",
"webHookProperties": {}
}
]
},
"dependsOn": []
}
]

但这部分我找不到

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"value": "New Metric Alert"
},
"alertDescription": {
"value": "New metric alert created via template"
},
"alertSeverity": {
"value":3
},
"isEnabled": {
"value": true
},
"resourceId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourceGroup-name/providers/Microsoft.Compute/virtualMachines/replace-with-resource-name"
},
"metricName": {
"value": "Percentage CPU"
},
"operator": {
"value": "GreaterThan"
},
"threshold": {
"value": "80"
},
"timeAggregation": {
"value": "Average"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-action-group"
}
}
}

当我尝试在没有定义参数的情况下运行它时,出现此错误:

New-AzureRmResourceGroupDeployment : 17:07:53 - Resource microsoft.insights/metricAlerts 'response-time-avg' failed with message '{
"Code": "BadRequest",
"Message": "Unable to find any of the requested metrics ''"
}'

最佳答案

我可以根据您提供的 DOC 为虚拟机创建警报只需替换参数文件中的resourceId 和actionGroupId 的值即可。使用PowerShell成功部署模板文件和参数文件。

enter image description here

之后,您可以在“自动化脚本”选项卡中看到资源类型 microsoft.insights/metricAlerts。创建警报后,您可以看到criteria属性和criteria参数,如下所示。

如果您想要导出特定警报模板而不是当前组中的所有资源。您可以引用以下步骤:进入资源组页面-设置下-部署-点击新创建的警报部署名称。您将在模板中找到资源和参数,然后下载即可。获取更多详细信息viewing template .

enter image description here

更新

通过与上述相同的部署,我可以使用 Azure REST API 查看更多条件参数。如下。自动化选项卡似乎没有显示所有必要的信息。获取完整自动化脚本的唯一方法是使用 Azure REST API 获取指标警报。

enter image description here

关于azure - 如何查找 Azure 警报的自动化参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53297990/

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