I have created a diagnostic setting for a Log Analytics Workspace.
I’d also like to create and automate a diagnostic setting for workspace-based in Application Insights.
However, I am not sure if that makes sense.
I have created a diagnostic setting as followed:
resource appDiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: appSettingName
scope: applicationInsights
properties: {
storageAccountId: storageAccountId
logs: [
{
category: 'Metrics'
enabled: true
}
{
category: 'Dependencies'
enabled: true
}
{
category: 'Exceptions'
enabled: true
}
{
category: 'PageViews'
enabled: true
}
{
category: 'PerformanceCounters'
enabled: true
}
{
category: 'Requests'
enabled: true
}
{
category: 'SystemEvents'
enabled: true
}
{
category: 'Traces'
enabled: true
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
}
]
}
}
However, I always get an error that my log categories are not valid. Is it because the data is double?
2
Answers
If you look at Azure Monitor Logs references, you will see that all log names have the
App
prefix so you should be able to do something like that:I also got the same error when I executed in my environment.
First of all, if you are trying to enable diagnostic settings(components) for any resource (Eg: Application Insights), Create a new workspace-based application insights and add that resource in the code with the
existing
keyword as shown below.Application Insights
:Refer MsDoc.
And
Verify the list of supported categories as @Thomas has also given, check the prefix and modify accordingly.
I’ve taken your code and made a few changes and enabled diagnostic settings for application insights successfully.
Deployment succeeded:
Output: