diff --git a/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.bicep b/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.bicep new file mode 100644 index 00000000000..448161624d6 --- /dev/null +++ b/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.bicep @@ -0,0 +1,124 @@ +param location string { + default: resourceGroup().location + allowed: [ + 'australiacentral' + 'australiaeast' + 'australiasoutheast' + 'brazilsouth' + 'canadacentral' + 'centralindia' + 'centralus' + 'eastasia' + 'eastus' + 'eastus2' + 'francecentral' + 'japaneast' + 'koreacentral' + 'northcentralus' + 'northeurope' + 'southafricanorth' + 'southcentralus' + 'southeastasia' + 'switzerlandnorth' + 'switzerlandwest' + 'uksouth' + 'ukwest' + 'westcentralus' + 'westeurope' + 'westus' + 'westus2' + ] +} + +param logAnalyticsWorkspaceName string = 'la-${uniqueString(resourceGroup().id)}' + +var vmInsights = { + name: 'VMInsights(${logAnalyticsWorkspaceName})' + galleryName: 'VMInsights' +} +var containerInsights = { + name: 'ContainerInsights(${logAnalyticsWorkspaceName})' + galleryName: 'ContainerInsights' +} + +var environmentName = 'Production' +var costCenterName = 'IT' + +resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = { + name: logAnalyticsWorkspaceName + location: location + tags: { + Environment: environmentName + CostCenter: costCenterName + } + properties: { + retentionInDays: 30 + features: { + searchVersion: 1 + } + sku: { + name: 'PerGB2018' + } + } +} + +resource logAnalyticsWorkspaceDiagnostics 'Microsoft.OperationalInsights/workspaces/providers/diagnosticSettings@2017-05-01-preview' = { + name: '${logAnalyticsWorkspace.name}/Microsoft.Insights/diagnosticSettings' + properties: { + workspaceId: logAnalyticsWorkspace.id + logs: [ + { + category: 'Audit' + enabled: true + retentionPolicy: { + days: 7 + enabled: true + } + } + ] + metrics: [ + { + category: 'AllMetrics' + enabled: true + retentionPolicy: { + days: 7 + enabled: true + } + } + ] + } +} + +resource solutionsVMInsights 'Microsoft.OperationsManagement/solutions@2015-11-01-preview' = { + name: vmInsights.name + location: location + dependsOn: [ + logAnalyticsWorkspace + ] + properties: { + workspaceResourceId: logAnalyticsWorkspace.id + } + plan: { + name: vmInsights.name + publisher: 'Microsoft' + product: 'OMSGallery/${vmInsights.galleryName}' + promotionCode: '' + } +} + +resource solutionsContainerInsights 'Microsoft.OperationsManagement/solutions@2015-11-01-preview' = { + name: containerInsights.name + location: location + dependsOn: [ + logAnalyticsWorkspace + ] + properties: { + workspaceResourceId: logAnalyticsWorkspace.id + } + plan: { + name: containerInsights.name + publisher: 'Microsoft' + product: 'OMSGallery/${containerInsights.galleryName}' + promotionCode: '' + } +} diff --git a/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.json b/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.json new file mode 100644 index 00000000000..d2e972507f9 --- /dev/null +++ b/docs/examples/201/log-analytics-with-solutions-and-diagnostics/main.json @@ -0,0 +1,144 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "allowedValues": [ + "australiacentral", + "australiaeast", + "australiasoutheast", + "brazilsouth", + "canadacentral", + "centralindia", + "centralus", + "eastasia", + "eastus", + "eastus2", + "francecentral", + "japaneast", + "koreacentral", + "northcentralus", + "northeurope", + "southafricanorth", + "southcentralus", + "southeastasia", + "switzerlandnorth", + "switzerlandwest", + "uksouth", + "ukwest", + "westcentralus", + "westeurope", + "westus", + "westus2" + ] + }, + "logAnalyticsWorkspaceName": { + "type": "string", + "defaultValue": "[format('la-{0}', uniqueString(resourceGroup().id))]" + } + }, + "functions": [], + "variables": { + "vmInsights": { + "name": "[format('VMInsights({0})', parameters('logAnalyticsWorkspaceName'))]", + "galleryName": "VMInsights" + }, + "containerInsights": { + "name": "[format('ContainerInsights({0})', parameters('logAnalyticsWorkspaceName'))]", + "galleryName": "ContainerInsights" + }, + "environmentName": "Production", + "costCenterName": "IT" + }, + "resources": [ + { + "type": "Microsoft.OperationalInsights/workspaces", + "apiVersion": "2020-03-01-preview", + "name": "[parameters('logAnalyticsWorkspaceName')]", + "location": "[parameters('location')]", + "tags": { + "Environment": "[variables('environmentName')]", + "CostCenter": "[variables('costCenterName')]" + }, + "properties": { + "retentionInDays": 30, + "features": { + "searchVersion": 1 + }, + "sku": { + "name": "PerGB2018" + } + } + }, + { + "type": "Microsoft.OperationalInsights/workspaces/providers/diagnosticSettings", + "apiVersion": "2017-05-01-preview", + "name": "[format('{0}/Microsoft.Insights/diagnosticSettings', parameters('logAnalyticsWorkspaceName'))]", + "properties": { + "workspaceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]", + "logs": [ + { + "category": "Audit", + "enabled": true, + "retentionPolicy": { + "days": 7, + "enabled": true + } + } + ], + "metrics": [ + { + "category": "AllMetrics", + "enabled": true, + "retentionPolicy": { + "days": 7, + "enabled": true + } + } + ] + }, + "dependsOn": [ + "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" + ] + }, + { + "type": "Microsoft.OperationsManagement/solutions", + "apiVersion": "2015-11-01-preview", + "name": "[variables('vmInsights').name]", + "location": "[parameters('location')]", + "properties": { + "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" + }, + "plan": { + "name": "[variables('vmInsights').name]", + "publisher": "Microsoft", + "product": "[format('OMSGallery/{0}', variables('vmInsights').galleryName)]", + "promotionCode": "" + }, + "dependsOn": [ + "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" + ] + }, + { + "type": "Microsoft.OperationsManagement/solutions", + "apiVersion": "2015-11-01-preview", + "name": "[variables('containerInsights').name]", + "location": "[parameters('location')]", + "properties": { + "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" + }, + "plan": { + "name": "[variables('containerInsights').name]", + "publisher": "Microsoft", + "product": "[format('OMSGallery/{0}', variables('containerInsights').galleryName)]", + "promotionCode": "" + }, + "dependsOn": [ + "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" + ] + } + ], + "outputs": {} +} \ No newline at end of file