Instantly share code, notes, and snippets.

@johndowns johndowns/smart-appinsights.json Secret
Last active Nov 28, 2018

Embed
What would you like to do?
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"applicationInsightsLocation": {
"type": "string",
"defaultValue": "westus2",
"allowedValues": [
"eastus",
"southcentralus",
"westus2",
"northeurope",
"westeurope",
"southeastasia"
],
"metadata": {
"description": "The location in which to deploy Application Insights, since it supports a subset of Azure regions."
}
},
"alertsEmailAddress": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The email address to which alerts should be sent."
}
}
},
"variables": {
"applicationInsightsName": "AppInsights",
"applicationInsightsSmartDetections": [
"slowpageloadtime",
"slowserverresponsetime",
"longdependencyduration",
"degradationinserverresponsetime",
"degradationindependencyduration"
]
},
"resources": [
{
"name": "[variables('applicationInsightsName')]",
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"location": "[parameters('applicationInsightsLocation')]",
"kind": "other",
"properties": {
"applicationId": "[variables('applicationInsightsName')]"
}
},
{
"comments": "Reconfigure Application Insights' default alerts to go to the right place",
"name": "[concat(variables('applicationInsightsName'), '/', variables('applicationInsightsSmartDetections')[copyIndex()])]",
"type": "Microsoft.Insights/components/proactiveDetectionConfigs",
"location": "[resourceGroup().location]",
"apiVersion": "2018-05-01-preview",
"copy": {
"name": "applicationInsightsSmartDetections",
"count": "[length(variables('applicationInsightsSmartDetections'))]"
},
"properties": {
"name": "[variables('applicationInsightsSmartDetections')[copyIndex()]]",
"sendEmailsToSubscriptionOwners": false,
"customEmails": [
"[parameters('alertsEmailAddress')]"
]
},
"dependsOn": [
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment