Azure 監視器中 Log Analytics 工作區的 Resource Manager 範本範例
本文包含範例 Azure Resource Manager 範本 ,以在 Azure 監視器中建立及設定 Log Analytics 工作區 。 每個範例都包含範本檔案和參數檔案,其中包含要提供給範本的範例值。
注意
請參閱 Azure 監視器的 Azure Resource Manager 範例 ,以取得可用的範例清單,以及在您的 Azure 訂用帳戶中部署這些範例的指引。
必要條件
確認您的 Azure 訂用帳戶可讓您在目的地區域中建立 Log Analytics 工作區。
需要的權限
動作 | 需要的權限 |
---|---|
部署 ARM 範本。 | Microsoft.Resources/deployments/* 許可權,例如 Log Analytics 參與者內建角色 所提供的 許可權。 |
建立 Log Analytics 工作區。 | Microsoft.OperationalInsights/workspaces/write 許可權,例如 Log Analytics 參與者內建角色 所提供的 許可權。 |
設定 Log Analytics 工作區的資料收集。 | Microsoft.OperationalInsights/workspaces/write 和 Microsoft.OperationalInsights/workspaces/dataSources/write 許可權,例如 Log Analytics 參與者內建角色 所提供的 許可權。 |
範本參考
建立 Log Analytics 工作區
下列範例會建立新的空白 Log Analytics 工作區 。 工作區具有唯一的工作區識別碼和資源識別碼。 您可以在不同的 資源群組 中重複使用相同的工作區名稱。
備註
- 如果您指定免費 定價層 ,請移除 retentionInDays 元素。
範本檔案
@description('Specify the name of the workspace.')
param workspaceName string
@description('Specify the location for the workspace.')
param location string
@description('Specify the pricing tier: PerGB2018 or legacy tiers (Free, Standalone, PerNode, Standard or Premium) which are not available to all customers.')
@allowed([
'CapacityReservation'
'Free'
'LACluster'
'PerGB2018'
'PerNode'
'Premium'
'Standalone'
'Standard'
])
param sku string = 'PerGB2018'
@description('Specify the number of days to retain data.')
param retentionInDays int = 120
@description('Specify true to use resource or workspace permissions, or false to require workspace permissions.')
param resourcePermissions bool
@description('Specify the number of days to retain data in Heartbeat table.')
param heartbeatTableRetention int
resource workspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
name: workspaceName
location: location
properties: {
sku: {
name: sku
}
retentionInDays: retentionInDays
features: {
enableLogAccessUsingOnlyResourcePermissions: resourcePermissions
}
}
}
resource table 'Microsoft.OperationalInsights/workspaces/tables@2021-12-01-preview' = {
parent: workspace
name: 'Heartbeat'
properties: {
retentionInDays: heartbeatTableRetention
}
}
參數檔案
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceName": {
"value": "MyWorkspace"
},
"sku": {
"value": "PerGB2018"
},
"location": {
"value": "eastus"
},
"resourcePermissions": {
"value": true
},
"heartbeatTableRetention": {
"value": 30
}
}
}
部署範例範本
請參閱 部署範例範本 。
下一步
- 取得 Azure 監視器 的其他範例範本。
- 深入瞭解 Log Analytics 工作區 。
- 深入瞭解代理程式資料來源 。