Skip to content

Instantly share code, notes, and snippets.

@johndowns johndowns/cosmosdb-alert.json Secret
Created Feb 1, 2019

Embed
What would you like to do?
{
"$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
You can’t perform that action at this time.