|
| 1 | +{ |
| 2 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 3 | + "contentVersion": "1.0.0.0", |
| 4 | + "parameters": { |
| 5 | + "clusterResourceId": { |
| 6 | + "type": "string", |
| 7 | + "metadata": { |
| 8 | + "description": "Resource Id of the Azure Arc Connected Cluster" |
| 9 | + } |
| 10 | + }, |
| 11 | + "clusterRegion": { |
| 12 | + "type": "string", |
| 13 | + "metadata": { |
| 14 | + "description": "Location of the Azure Arc Connected Cluster Resource e.g. \"eastus\"" |
| 15 | + } |
| 16 | + }, |
| 17 | + "workspaceResourceId": { |
| 18 | + "type": "string", |
| 19 | + "metadata": { |
| 20 | + "description": "Azure Monitor Log Analytics Resource ID" |
| 21 | + } |
| 22 | + }, |
| 23 | + "workspaceRegion": { |
| 24 | + "type": "string", |
| 25 | + "metadata": { |
| 26 | + "description": "Azure Monitor Log Analytics Workspace region e.g. \"eastus\"" |
| 27 | + } |
| 28 | + }, |
| 29 | + "resourceTagValues": { |
| 30 | + "type": "object", |
| 31 | + "metadata": { |
| 32 | + "description": "Existing or new tags to use on DCR resources" |
| 33 | + } |
| 34 | + }, |
| 35 | + "k8sNamespaces": { |
| 36 | + "type": "array", |
| 37 | + "metadata": { |
| 38 | + "description": "An array of Kubernetes namespaces for Multi-tenancy logs filtering" |
| 39 | + } |
| 40 | + }, |
| 41 | + "transformKql": { |
| 42 | + "type": "string", |
| 43 | + "metadata": { |
| 44 | + "description": "KQL filter for ingestion transformation" |
| 45 | + } |
| 46 | + } |
| 47 | + }, |
| 48 | + "variables": { |
| 49 | + "clusterSubscriptionId": "[split(parameters('clusterResourceId'),'/')[2]]", |
| 50 | + "clusterResourceGroup": "[split(parameters('clusterResourceId'),'/')[4]]", |
| 51 | + "clusterName": "[split(parameters('clusterResourceId'),'/')[8]]", |
| 52 | + "workspaceName": "[split(parameters('workspaceResourceId'),'/')[8]]", |
| 53 | + "workspaceLocation": "[replace(parameters('workspaceRegion'),' ', '')]", |
| 54 | + "dcrNameFull": "[Concat('MSCI-multi-tenancy', '-', variables('workspaceLocation'), '-', uniqueString(parameters('workspaceResourceId')))]", |
| 55 | + "dcrName": "[if(greater(length(variables('dcrNameFull')), 64), substring(variables('dcrNameFull'), 0, 64), variables('dcrNameFull'))]", |
| 56 | + "associationName": "[Concat('ContainerLogV2Extension', '-', uniqueString(parameters('workspaceResourceId')))]", |
| 57 | + "dataCollectionRuleId": "[resourceId(variables('clusterSubscriptionId'), variables('clusterResourceGroup'), 'Microsoft.Insights/dataCollectionRules', variables('dcrName'))]", |
| 58 | + "ingestionDCENameFull": "[Concat('MSCI-multi-tenancy', '-', variables('workspaceLocation'), '-', uniqueString(parameters('workspaceResourceId')))]", |
| 59 | + "ingestionDCEName": "[if(greater(length(variables('ingestionDCENameFull')), 43), substring(variables('ingestionDCENameFull'), 0, 43), variables('ingestionDCENameFull'))]", |
| 60 | + "ingestionDCE": "[if(endsWith(variables('ingestionDCEName'), '-'), substring(variables('ingestionDCEName'), 0, 42), variables('ingestionDCEName'))]", |
| 61 | + "ingestionDataCollectionEndpointId": "[resourceId(variables('clusterSubscriptionId'), variables('clusterResourceGroup'), 'Microsoft.Insights/dataCollectionEndpoints', variables('ingestionDCE'))]" |
| 62 | + }, |
| 63 | + "resources": [ |
| 64 | + { |
| 65 | + "type": "Microsoft.Insights/dataCollectionEndpoints", |
| 66 | + "apiVersion": "2022-06-01", |
| 67 | + "name": "[variables('ingestionDCE')]", |
| 68 | + "location": "[variables('workspaceLocation')]", |
| 69 | + "kind": "Linux", |
| 70 | + "tags": "[parameters('resourceTagValues')]", |
| 71 | + "properties": { |
| 72 | + "networkAcls": { |
| 73 | + "publicNetworkAccess": "Enabled" |
| 74 | + } |
| 75 | + } |
| 76 | + }, |
| 77 | + { |
| 78 | + "type": "Microsoft.Resources/deployments", |
| 79 | + "name": "[Concat('arc-k8s-monitoring-msi-dcr', '-', uniqueString(variables('dcrName')))]", |
| 80 | + "apiVersion": "2017-05-10", |
| 81 | + "subscriptionId": "[variables('clusterSubscriptionId')]", |
| 82 | + "resourceGroup": "[variables('clusterResourceGroup')]", |
| 83 | + "properties": { |
| 84 | + "mode": "Incremental", |
| 85 | + "template": { |
| 86 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 87 | + "contentVersion": "1.0.0.0", |
| 88 | + "parameters": {}, |
| 89 | + "variables": {}, |
| 90 | + "resources": [ |
| 91 | + { |
| 92 | + "type": "Microsoft.Insights/dataCollectionRules", |
| 93 | + "apiVersion": "2022-06-01", |
| 94 | + "name": "[variables('dcrName')]", |
| 95 | + "location": "[parameters('workspaceRegion')]", |
| 96 | + "kind": "Linux", |
| 97 | + "tags": "[parameters('resourceTagValues')]", |
| 98 | + "properties": { |
| 99 | + "dataSources": { |
| 100 | + "extensions": [ |
| 101 | + { |
| 102 | + "name": "ContainerLogV2Extension", |
| 103 | + "streams": [ |
| 104 | + "Microsoft-ContainerLogV2-HighScale" |
| 105 | + ], |
| 106 | + "extensionSettings": { |
| 107 | + "dataCollectionSettings": { |
| 108 | + "namespaces": "[parameters('k8sNamespaces')]" |
| 109 | + } |
| 110 | + }, |
| 111 | + "extensionName": "ContainerLogV2Extension" |
| 112 | + } |
| 113 | + ] |
| 114 | + }, |
| 115 | + "destinations": { |
| 116 | + "logAnalytics": [ |
| 117 | + { |
| 118 | + "workspaceResourceId": "[parameters('workspaceResourceId')]", |
| 119 | + "name": "ciworkspace" |
| 120 | + } |
| 121 | + ] |
| 122 | + }, |
| 123 | + "dataFlows": [ |
| 124 | + { |
| 125 | + "streams": [ |
| 126 | + "Microsoft-ContainerLogV2-HighScale" |
| 127 | + ], |
| 128 | + "destinations": [ |
| 129 | + "ciworkspace" |
| 130 | + ], |
| 131 | + "transformKql": "[if(empty(parameters('transformKql')), json('null'), parameters('transformKql'))]" |
| 132 | + } |
| 133 | + ], |
| 134 | + "dataCollectionEndpointId": "[variables('ingestionDataCollectionEndpointId')]" |
| 135 | + } |
| 136 | + } |
| 137 | + ] |
| 138 | + }, |
| 139 | + "parameters": {} |
| 140 | + } |
| 141 | + }, |
| 142 | + { |
| 143 | + "type": "Microsoft.Resources/deployments", |
| 144 | + "name": "[Concat('arc-k8s-monitoring-msi-dcra', '-', uniqueString(parameters('clusterResourceId')))]", |
| 145 | + "apiVersion": "2017-05-10", |
| 146 | + "subscriptionId": "[variables('clusterSubscriptionId')]", |
| 147 | + "resourceGroup": "[variables('clusterResourceGroup')]", |
| 148 | + "dependsOn": [ |
| 149 | + "[Concat('arc-k8s-monitoring-msi-dcr', '-', uniqueString(variables('dcrName')))]" |
| 150 | + ], |
| 151 | + "properties": { |
| 152 | + "mode": "Incremental", |
| 153 | + "template": { |
| 154 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 155 | + "contentVersion": "1.0.0.0", |
| 156 | + "parameters": {}, |
| 157 | + "variables": {}, |
| 158 | + "resources": [ |
| 159 | + { |
| 160 | + "type": "Microsoft.Kubernetes/connectedClusters/providers/dataCollectionRuleAssociations", |
| 161 | + "name": "[concat(variables('clusterName'),'/microsoft.insights/', variables('associationName'))]", |
| 162 | + "apiVersion": "2022-06-01", |
| 163 | + "properties": { |
| 164 | + "description": "Association of data collection rule for Multi-tenancy logs. Deleting this association will break the Multi-tenancy logs collection for this Arc K8s Cluster.", |
| 165 | + "dataCollectionRuleId": "[variables('dataCollectionRuleId')]" |
| 166 | + } |
| 167 | + } |
| 168 | + ] |
| 169 | + }, |
| 170 | + "parameters": {} |
| 171 | + } |
| 172 | + } |
| 173 | + ] |
| 174 | +} |
0 commit comments