Skip to content

Instantly share code, notes, and snippets.

@johndowns
Created February 1, 2019 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndowns/b6798ebc45311c6c1e6ff854c0af51c9 to your computer and use it in GitHub Desktop.
Save johndowns/b6798ebc45311c6c1e6ff854c0af51c9 to your computer and use it in GitHub Desktop.
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertEmailAddress": {
"type": "string",
"metadata": {
"description": "The email address to receive any alerts."
}
},
"cosmosDbAccountName": {
"type": "string",
"defaultValue": "[uniqueString(subscription().subscriptionId, resourceGroup().name)]",
"metadata": {
"description": "The name to use when creating the Cosmos DB account. This must be globally unique."
}
}
},
"variables": {
"actionGroupName": "MyApplicationErrors"
},
"resources": [
{
"name": "[parameters('cosmosDbAccountName')]",
"type": "Microsoft.DocumentDB/databaseAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2015-04-08",
"kind": "GlobalDocumentDB",
"properties": {
"databaseAccountOfferType": "Standard",
"consistencyPolicy": {
"defaultConsistencyLevel": "Session",
"maxIntervalInSeconds": 5,
"maxStalenessPrefix": 100
}
}
},
{
"name": "[variables('actionGroupName')]",
"type": "Microsoft.Insights/actionGroups",
"location": "global",
"apiVersion": "2018-03-01",
"properties": {
"groupShortName": "Cosmos DB",
"enabled": true,
"emailReceivers": [
{
"name": "Account Owner",
"emailAddress": "[parameters('alertEmailAddress')]"
}
]
}
},
{
"name": "ThrottledRequests",
"type": "Microsoft.Insights/metricAlerts",
"location": "global",
"apiVersion": "2018-03-01",
"properties": {
"description": "[concat('The number of throttled requests has increased beyond the specified threshold.')]",
"severity": 2,
"enabled": true,
"scopes": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName'))]"
],
"evaluationFrequency": "PT5M",
"windowSize": "PT1H",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "Throttled requests greater than 1",
"metricName": "TotalRequests",
"dimensions": [
{
"name": "StatusCode",
"operator": "Include",
"values": [
"429"
]
}
],
"operator": "GreaterThan",
"threshold": 1,
"timeAggregation": "Maximum"
}
]
},
"actions": [
{
"actionGroupId": "[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]"
}
],
"dependsOn": [
"[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]",
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName'))]"
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment