Skip to content

Commit

Permalink
[Modules] Update DiagnosticSettings (#3721)
Browse files Browse the repository at this point in the history
* Removed retention policy object

* Removed retention param

* Removed further references

* Added test to storage common

* Updated test

* Regenerated all bicep templates

* Regen docs

* Removed add. references
  • Loading branch information
AlexanderSehr authored Aug 27, 2023
1 parent 1c607ce commit 22f6169
Show file tree
Hide file tree
Showing 281 changed files with 429 additions and 3,109 deletions.
1 change: 0 additions & 1 deletion constructs/Compute/virtualMachinesMultiple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ This module deploys one or multiple Virtual Machines.
| `dedicatedHostId` | string | `''` | | Specifies resource ID about the dedicated host that the virtual machine resides in. |
| `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogsRetentionInDays` | int | `365` | | Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. |
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
| `diagnosticWorkspaceId` | string | `''` | | Resource ID of the diagnostic log analytics workspace. |
| `disablePasswordAuthentication` | bool | `False` | | Specifies whether password authentication should be disabled. |
Expand Down
8 changes: 1 addition & 7 deletions constructs/Compute/virtualMachinesMultiple/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,6 @@ param extensionCustomScriptProtectedSetting object = {}
@description('Optional. Location for all resources.')
param location string = resourceGroup().location

@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
@minValue(0)
@maxValue(365)
param diagnosticLogsRetentionInDays int = 365

@description('Optional. Resource ID of the diagnostic storage account.')
param diagnosticStorageAccountId string = ''

Expand Down Expand Up @@ -301,7 +296,7 @@ var vmNamesToApply = !empty(vmNames) ? vmNames : vmGeneratedNames

var enableReferencedModulesTelemetry = false

module virtualMachine '../../../modules/Compute/virtualMachines/main.bicep' = [for (vmName, index) in vmNamesToApply: {
module virtualMachine '../../../modules/compute/virtual-machine/main.bicep' = [for (vmName, index) in vmNamesToApply: {
name: '${deployment().name}-vm-${index}'
params: {
name: vmName
Expand All @@ -328,7 +323,6 @@ module virtualMachine '../../../modules/Compute/virtualMachines/main.bicep' = [f
dedicatedHostId: dedicatedHostId
diagnosticEventHubAuthorizationRuleId: diagnosticEventHubAuthorizationRuleId
diagnosticEventHubName: diagnosticEventHubName
diagnosticLogsRetentionInDays: diagnosticLogsRetentionInDays
diagnosticStorageAccountId: diagnosticStorageAccountId
diagnosticWorkspaceId: diagnosticWorkspaceId
disablePasswordAuthentication: disablePasswordAuthentication
Expand Down
16 changes: 0 additions & 16 deletions docs/wiki/The library - Module design.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ The diagnostic settings may differ slightly, from resource to resource. Most not
<summary>Details</summary>

```bicep
@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
@minValue(0)
@maxValue(365)
param diagnosticLogsRetentionInDays int = 365
@description('Optional. Resource ID of the diagnostic storage account.')
param diagnosticStorageAccountId string = ''
Expand Down Expand Up @@ -336,31 +332,19 @@ param diagnosticSettingsName string = ''
var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs' && item != ''): {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
var diagnosticsLogs = contains(diagnosticLogCategoriesToEnable, 'allLogs') ? [
{
categoryGroup: 'allLogs'
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}
] : contains(diagnosticLogCategoriesToEnable, '') ? [] : diagnosticsLogsSpecified
var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: {
category: metric
timeGrain: null
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
resource <mainResource>_diagnosticSettings 'Microsoft.Insights/diagnosticsettings@2021-05-01-preview' = if (!empty(diagnosticStorageAccountId) || !empty(diagnosticWorkspaceId) || !empty(diagnosticEventHubAuthorizationRuleId) || !empty(diagnosticEventHubName)) {
Expand Down
1 change: 0 additions & 1 deletion modules/aad/domain-service/.test/common/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ module testDeployment '../../main.bicep' = {
additionalRecipients: [
'${namePrefix}@noreply.github.com'
]
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId
diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId
diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId
Expand Down
5 changes: 0 additions & 5 deletions modules/aad/domain-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ This module deploys an Azure Active Directory Domain Services (AADDS).
| `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogCategoriesToEnable` | array | `[allLogs]` | `['', AccountLogon, AccountManagement, allLogs, DetailTracking, DirectoryServiceAccess, LogonLogoff, ObjectAccess, PolicyChange, PrivilegeUse, SystemSecurity]` | The name of logs that will be streamed. "allLogs" includes all possible logs for the resource. Set to '' to disable log collection. |
| `diagnosticLogsRetentionInDays` | int | `365` | | Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. |
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
| `diagnosticWorkspaceId` | string | `''` | | Resource ID of the diagnostic log analytics workspace. |
| `domainConfigurationType` | string | `'FullySynced'` | `[FullySynced, ResourceTrusting]` | The value is to provide domain configuration type. |
Expand Down Expand Up @@ -238,7 +237,6 @@ module domainService './aad/domain-service/main.bicep' = {
]
diagnosticEventHubAuthorizationRuleId: '<diagnosticEventHubAuthorizationRuleId>'
diagnosticEventHubName: '<diagnosticEventHubName>'
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: '<diagnosticStorageAccountId>'
diagnosticWorkspaceId: '<diagnosticWorkspaceId>'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
Expand Down Expand Up @@ -289,9 +287,6 @@ module domainService './aad/domain-service/main.bicep' = {
"diagnosticEventHubName": {
"value": "<diagnosticEventHubName>"
},
"diagnosticLogsRetentionInDays": {
"value": 7
},
"diagnosticStorageAccountId": {
"value": "<diagnosticStorageAccountId>"
},
Expand Down
13 changes: 0 additions & 13 deletions modules/aad/domain-service/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ param diagnosticEventHubName string = ''
@description('Optional. Tags of the resource.')
param tags object = {}

@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
@minValue(0)
@maxValue(365)
param diagnosticLogsRetentionInDays int = 365

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

Expand Down Expand Up @@ -170,20 +165,12 @@ param diagnosticLogCategoriesToEnable array = [
var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs' && item != ''): {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]

var diagnosticsLogs = contains(diagnosticLogCategoriesToEnable, 'allLogs') ? [
{
categoryGroup: 'allLogs'
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}
] : contains(diagnosticLogCategoriesToEnable, '') ? [] : diagnosticsLogsSpecified

Expand Down
19 changes: 3 additions & 16 deletions modules/aad/domain-service/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.20.4.51522",
"templateHash": "12721378436248791893"
"templateHash": "11963708843565725905"
},
"name": "Azure Active Directory Domain Services",
"description": "This module deploys an Azure Active Directory Domain Services (AADDS).",
Expand Down Expand Up @@ -235,15 +235,6 @@
"description": "Optional. Tags of the resource."
}
},
"diagnosticLogsRetentionInDays": {
"type": "int",
"defaultValue": 365,
"minValue": 0,
"maxValue": 365,
"metadata": {
"description": "Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely."
}
},
"enableDefaultTelemetry": {
"type": "bool",
"defaultValue": true,
Expand Down Expand Up @@ -300,15 +291,11 @@
"count": "[length(filter(parameters('diagnosticLogCategoriesToEnable'), lambda('item', and(not(equals(lambdaVariables('item'), 'allLogs')), not(equals(lambdaVariables('item'), ''))))))]",
"input": {
"category": "[filter(parameters('diagnosticLogCategoriesToEnable'), lambda('item', and(not(equals(lambdaVariables('item'), 'allLogs')), not(equals(lambdaVariables('item'), '')))))[copyIndex('diagnosticsLogsSpecified')]]",
"enabled": true,
"retentionPolicy": {
"enabled": true,
"days": "[parameters('diagnosticLogsRetentionInDays')]"
}
"enabled": true
}
}
],
"diagnosticsLogs": "[if(contains(parameters('diagnosticLogCategoriesToEnable'), 'allLogs'), createArray(createObject('categoryGroup', 'allLogs', 'enabled', true(), 'retentionPolicy', createObject('enabled', true(), 'days', parameters('diagnosticLogsRetentionInDays')))), if(contains(parameters('diagnosticLogCategoriesToEnable'), ''), createArray(), variables('diagnosticsLogsSpecified')))]"
"diagnosticsLogs": "[if(contains(parameters('diagnosticLogCategoriesToEnable'), 'allLogs'), createArray(createObject('categoryGroup', 'allLogs', 'enabled', true())), if(contains(parameters('diagnosticLogCategoriesToEnable'), ''), createArray(), variables('diagnosticsLogsSpecified')))]"
},
"resources": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ module testDeployment '../../main.bicep' = {
principalType: 'ServicePrincipal'
}
]
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId
diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId
diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId
Expand Down
1 change: 0 additions & 1 deletion modules/analysis-services/server/.test/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module testDeployment '../../main.bicep' = {
principalType: 'ServicePrincipal'
}
]
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId
diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId
diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId
Expand Down
9 changes: 0 additions & 9 deletions modules/analysis-services/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ This module deploys an Analysis Services Server.
| `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogCategoriesToEnable` | array | `[allLogs]` | `['', allLogs, Engine, Service]` | The name of logs that will be streamed. "allLogs" includes all possible logs for the resource. Set to '' to disable log collection. |
| `diagnosticLogsRetentionInDays` | int | `365` | | Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. |
| `diagnosticMetricsToEnable` | array | `[AllMetrics]` | `[AllMetrics]` | The name of metrics that will be streamed. |
| `diagnosticSettingsName` | string | `''` | | The name of the diagnostic setting, if deployed. If left empty, it defaults to "<resourceName>-diagnosticSettings". |
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
Expand Down Expand Up @@ -184,7 +183,6 @@ module server './analysis-services/server/main.bicep' = {
// Non-required parameters
diagnosticEventHubAuthorizationRuleId: '<diagnosticEventHubAuthorizationRuleId>'
diagnosticEventHubName: '<diagnosticEventHubName>'
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: '<diagnosticStorageAccountId>'
diagnosticWorkspaceId: '<diagnosticWorkspaceId>'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
Expand Down Expand Up @@ -230,9 +228,6 @@ module server './analysis-services/server/main.bicep' = {
"diagnosticEventHubName": {
"value": "<diagnosticEventHubName>"
},
"diagnosticLogsRetentionInDays": {
"value": 7
},
"diagnosticStorageAccountId": {
"value": "<diagnosticStorageAccountId>"
},
Expand Down Expand Up @@ -291,7 +286,6 @@ module server './analysis-services/server/main.bicep' = {
'Engine'
'Service'
]
diagnosticLogsRetentionInDays: 7
diagnosticMetricsToEnable: [
'AllMetrics'
]
Expand Down Expand Up @@ -353,9 +347,6 @@ module server './analysis-services/server/main.bicep' = {
"Service"
]
},
"diagnosticLogsRetentionInDays": {
"value": 7
},
"diagnosticMetricsToEnable": {
"value": [
"AllMetrics"
Expand Down
17 changes: 0 additions & 17 deletions modules/analysis-services/server/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ param firewallSettings object = {
@description('Optional. Location for all Resources.')
param location string = resourceGroup().location

@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
@minValue(0)
@maxValue(365)
param diagnosticLogsRetentionInDays int = 365

@description('Optional. Resource ID of the diagnostic storage account.')
param diagnosticStorageAccountId string = ''

Expand Down Expand Up @@ -85,31 +80,19 @@ param diagnosticSettingsName string = ''
var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs' && item != ''): {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]

var diagnosticsLogs = contains(diagnosticLogCategoriesToEnable, 'allLogs') ? [
{
categoryGroup: 'allLogs'
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}
] : contains(diagnosticLogCategoriesToEnable, '') ? [] : diagnosticsLogsSpecified

var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: {
category: metric
timeGrain: null
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
Expand Down
25 changes: 4 additions & 21 deletions modules/analysis-services/server/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.20.4.51522",
"templateHash": "430189201191579276"
"templateHash": "10064223785329368726"
},
"name": "Analysis Services Servers",
"description": "This module deploys an Analysis Services Server.",
Expand Down Expand Up @@ -55,15 +55,6 @@
"description": "Optional. Location for all Resources."
}
},
"diagnosticLogsRetentionInDays": {
"type": "int",
"defaultValue": 365,
"minValue": 0,
"maxValue": 365,
"metadata": {
"description": "Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely."
}
},
"diagnosticStorageAccountId": {
"type": "string",
"defaultValue": "",
Expand Down Expand Up @@ -167,11 +158,7 @@
"count": "[length(filter(parameters('diagnosticLogCategoriesToEnable'), lambda('item', and(not(equals(lambdaVariables('item'), 'allLogs')), not(equals(lambdaVariables('item'), ''))))))]",
"input": {
"category": "[filter(parameters('diagnosticLogCategoriesToEnable'), lambda('item', and(not(equals(lambdaVariables('item'), 'allLogs')), not(equals(lambdaVariables('item'), '')))))[copyIndex('diagnosticsLogsSpecified')]]",
"enabled": true,
"retentionPolicy": {
"enabled": true,
"days": "[parameters('diagnosticLogsRetentionInDays')]"
}
"enabled": true
}
},
{
Expand All @@ -180,15 +167,11 @@
"input": {
"category": "[parameters('diagnosticMetricsToEnable')[copyIndex('diagnosticsMetrics')]]",
"timeGrain": null,
"enabled": true,
"retentionPolicy": {
"enabled": true,
"days": "[parameters('diagnosticLogsRetentionInDays')]"
}
"enabled": true
}
}
],
"diagnosticsLogs": "[if(contains(parameters('diagnosticLogCategoriesToEnable'), 'allLogs'), createArray(createObject('categoryGroup', 'allLogs', 'enabled', true(), 'retentionPolicy', createObject('enabled', true(), 'days', parameters('diagnosticLogsRetentionInDays')))), if(contains(parameters('diagnosticLogCategoriesToEnable'), ''), createArray(), variables('diagnosticsLogsSpecified')))]"
"diagnosticsLogs": "[if(contains(parameters('diagnosticLogCategoriesToEnable'), 'allLogs'), createArray(createObject('categoryGroup', 'allLogs', 'enabled', true())), if(contains(parameters('diagnosticLogCategoriesToEnable'), ''), createArray(), variables('diagnosticsLogsSpecified')))]"
},
"resources": [
{
Expand Down
1 change: 0 additions & 1 deletion modules/api-management/service/.test/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ module testDeployment '../../main.bicep' = {
useFromLocation: 'westeurope'
}
]
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId
diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId
diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId
Expand Down
5 changes: 0 additions & 5 deletions modules/api-management/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ This module deploys an API Management Service.
| `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. |
| `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. |
| `diagnosticLogCategoriesToEnable` | array | `[allLogs]` | `['', allLogs, GatewayLogs]` | The name of logs that will be streamed. "allLogs" includes all possible logs for the resource. Set to '' to disable log collection. |
| `diagnosticLogsRetentionInDays` | int | `365` | | Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. |
| `diagnosticMetricsToEnable` | array | `[AllMetrics]` | `[AllMetrics]` | The name of metrics that will be streamed. |
| `diagnosticSettingsName` | string | `''` | | The name of the diagnostic setting, if deployed. If left empty, it defaults to "<resourceName>-diagnosticSettings". |
| `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. |
Expand Down Expand Up @@ -484,7 +483,6 @@ module service './api-management/service/main.bicep' = {
]
diagnosticEventHubAuthorizationRuleId: '<diagnosticEventHubAuthorizationRuleId>'
diagnosticEventHubName: '<diagnosticEventHubName>'
diagnosticLogsRetentionInDays: 7
diagnosticStorageAccountId: '<diagnosticStorageAccountId>'
diagnosticWorkspaceId: '<diagnosticWorkspaceId>'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
Expand Down Expand Up @@ -653,9 +651,6 @@ module service './api-management/service/main.bicep' = {
"diagnosticEventHubName": {
"value": "<diagnosticEventHubName>"
},
"diagnosticLogsRetentionInDays": {
"value": 7
},
"diagnosticStorageAccountId": {
"value": "<diagnosticStorageAccountId>"
},
Expand Down
Loading

0 comments on commit 22f6169

Please sign in to comment.