2017-01-11 43 views
0

我們開始有一堆手動創建的警報,並且爲了保持一致性,我希望用防止人爲錯誤的腳本來維護它們。使用webhook以編程方式創建應用程序洞察警報

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

然而,缺少的東西,建立網絡掛接這些方法 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

最初的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%" 
爲例