Using an ARM Template I want to enable diagnostics settings for my Azure SQL Database and have that data stored in a Log Analytics workspace I created. I want to enable the errors, timeouts, blocks and wait statistics logs and the basic metric option. I was able to get this working with a web app so I took a similar approach but my template fails and throws errors saying the metrics or diagnostic categories I reference don't exist or not supported. Here's some of the resources section my template:
I'm not sure if additional settings need to be enabled or referenced in the template for this to work but I would appreciate any help, thanks!
"resources": [
{
"type": "databases",
"apiVersion": "2019-06-01-preview",
"name": "[parameters('sqlDatabase')]",
"location": "[parameters('location')]",
"tags": {},
"dependsOn": [
"[parameters('sqlServer')]"
],
"sku": {
"name": "GP_Gen5_4",
"tier": "GeneralPurpose"
},
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
}
},
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('diagnostics-name'))]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlServer'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlServer'), parameters('sqlDatabase'))]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('diagnostics-name')]",
"workspaceId": "[concat('subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('loganalytics-rg'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('workspacename'))]",
"logs": [
{
"category": "Errors",
"enabled": "true",
"retentionPolicy": {
"enabled": "true",
"days": 7
}
},
{
"category": "DatabaseWaitStatistics",
"enabled": "true",
"retentionPolicy": {
"enabled": "true",
"days": 7
}
},
{
"category": "Timeouts",
"enabled": "true",
"retentionPolicy": {
"enabled": "true",
"days": 7
}
},
{
"category": "Blocks",
"enabled": "true",
"retentionPolicy": {
"enabled": "true",
"days": 7
}
}
]
}
}
]
}
]
}