Reputation: 1000
We start to have a bunch of manually created alerts and for consistency I would like to maintain them with script preventing human errors.
There are different approaches which are perfect such powershell https://learn.microsoft.com/en-us/azure/application-insights/app-insights-powershell-alerts or template approach.
however, something is missing, the ability to set up webhook with these approaches
I had a look into json schema but action only supports sendToServiceOwners
and/or customEmails
(http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json)
I searched if a newer schema version exists (schema : 2014, webhook functionality : 2015), but with no luck https://github.com/Azure/azure-resource-manager-schemas/search?utf8=%E2%9C%93&q=Microsoft.Insights.json&type=Code
any suggestion ?
Upvotes: 0
Views: 828
Reputation: 1000
The initial powershell article was already a little bit outdated (not the article itself). focusing on AzureRM API I was able to find this article : https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/insights-powershell-samples
which give an example on 2 steps with
$actionWebhook = New-AzureRmAlertRuleWebhook -ServiceUri https://example.com?token=mytoken
and
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%"
Upvotes: 1