使用webhook以编程方式创建应用程序洞察警报

时间:2017-01-11 10:19:44

标签: webhooks azure-application-insights

我们开始有一堆手动创建的警报,为了保持一致性,我希望用脚本来保护它们,防止出现人为错误。

有不同的方法是完美的这样的powershell https://docs.microsoft.com/en-us/azure/application-insights/app-insights-powershell-alerts 或模板方法。

然而,缺少某些东西,能够使用这些方法设置webhook enter image description here

我查看了json架构,但操作仅支持sendToServiceOwners和/或customEmailshttp://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json

我搜索了是否存在较新的架构版本(架构:2014,webhook功能:2015),但没有运气https://github.com/Azure/azure-resource-manager-schemas/search?utf8=%E2%9C%93&q=Microsoft.Insights.json&type=Code

任何建议?

1 个答案:

答案 0 :(得分:1)

最初的powershell文章已经过时了(不是文章本身)。专注于AzureRM API我能够找到这篇文章:https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/insights-powershell-samples

为例介绍了2个步骤
$actionWebhook = New-AzureRmAlertRuleWebhook -ServiceUri https://example.com?token=mytoken

Add-AzureRmMetricAlertRule -Name vmcpu_gt_1 -Location "East US" -ResourceGroup myrg1 -TargetResourceId /subscriptions/s1/resourceGroups/myrg1/providers/Microsoft.ClassicCompute/virtualMachines/my_vm1 -MetricName "Percentage CPU" -Operator GreaterThan -Threshold 1 -WindowSize 00:05:00 -TimeAggregationOperator Average -Actions $actionEmail, $actionWebhook -Description "alert on CPU > 1%"
相关问题