Skip to content

Commit

Permalink
Workaround for diag
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Oct 27, 2023
1 parent e9f6bb9 commit 6658675
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion modules/insights/diagnostic-setting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ Location deployment metadata.
A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type.
- Required: No
- Type: string
- Allowed: `[AzureDiagnostics, Dedicated]`
- Default: `''`
- Allowed: `['', AzureDiagnostics, Dedicated]`

### Parameter: `logCategoriesAndGroups`

Expand Down
11 changes: 8 additions & 3 deletions modules/insights/diagnostic-setting/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ param logCategoriesAndGroups logCategoriesAndGroupsType
param metricCategories metricCategoriesType?

@description('Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type.')
param logAnalyticsDestinationType ('Dedicated' | 'AzureDiagnostics')?
@allowed([
''
'Dedicated'
'AzureDiagnostics'
])
param logAnalyticsDestinationType string = ''

@description('Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs.')
param marketplacePartnerResourceId string?

@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).')
param enableDefaultTelemetry bool = true

@sys.description('Optional. Location deployment metadata.')
@description('Optional. Location deployment metadata.')
param location string = deployment().location

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
Expand All @@ -59,7 +64,7 @@ resource diagnosticSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-pre
workspaceId: workspaceResourceId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleResourceId
eventHubName: eventHubName
logAnalyticsDestinationType: logAnalyticsDestinationType
logAnalyticsDestinationType: !empty(logAnalyticsDestinationType) ? logAnalyticsDestinationType : null
marketplacePartnerId: marketplacePartnerResourceId
logs: logCategoriesAndGroups ?? [
{
Expand Down
11 changes: 6 additions & 5 deletions modules/insights/diagnostic-setting/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "17656378970927023137"
"templateHash": "18398206698301331030"
},
"name": "Diagnostic Settings (Activity Logs) for Azure Subscriptions",
"description": "This module deploys a Subscription wide export of the Activity Log.",
Expand Down Expand Up @@ -111,11 +111,12 @@
},
"logAnalyticsDestinationType": {
"type": "string",
"defaultValue": "",
"allowedValues": [
"AzureDiagnostics",
"Dedicated"
"",
"Dedicated",
"AzureDiagnostics"
],
"nullable": true,
"metadata": {
"description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
}
Expand Down Expand Up @@ -167,7 +168,7 @@
"workspaceId": "[parameters('workspaceResourceId')]",
"eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleResourceId')]",
"eventHubName": "[parameters('eventHubName')]",
"logAnalyticsDestinationType": "[parameters('logAnalyticsDestinationType')]",
"logAnalyticsDestinationType": "[if(not(empty(parameters('logAnalyticsDestinationType'))), parameters('logAnalyticsDestinationType'), null())]",
"marketplacePartnerId": "[parameters('marketplacePartnerResourceId')]",
"logs": "[coalesce(parameters('logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'AllLogs', 'enabled', true())))]",
"metrics": "[coalesce(parameters('metricCategories'), createArray(createObject('category', 'AllMetrics', 'timeGrain', null(), 'enabled', true())))]"
Expand Down

0 comments on commit 6658675

Please sign in to comment.