Azure Monitor のデータ収集ルールのための Resource Manager テンプレート サンプル
この記事には、データ収集ルールと Azure Monitor エージェントとの関連付けを作成するサンプル Azure Resource Manager テンプレートが含まれています。 各サンプルには、テンプレート ファイルと、テンプレートに指定するサンプル値を含むパラメーター ファイルが含まれています。
Note
利用可能なサンプルのリスト、および Azure サブスクリプションへの各サンプルのデプロイ方法については、Azure Monitor の Azure Resource Manager のサンプルに関するページを参照してください。
必要なアクセス許可
組み込みロール | スコープ | 理由 |
---|---|---|
Monitoring Contributor |
|
データ収集ルールを作成または編集するには |
|
関連付けをデプロイするには (つまり、ルールをマシンに割り当てるには) | |
アクション Microsoft.Resources/deployments/ を含む任意のロール |
|
ARM テンプレートをデプロイするには |
ルールを作成する (サンプル)
テンプレートの形式を表示します。
Azure VM との関連付けを作成する
次のサンプルによって、Azure 仮想マシンとデータ収集ルールとの間に関連付けが作成されます。
テンプレート ファイル
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this virtual machine.'
dataCollectionRuleId: dataCollectionRuleId
}
}
パラメーター ファイル
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"value": "my-azure-vm"
},
"associationName": {
"value": "my-windows-vm-my-dcr"
},
"dataCollectionRuleId": {
"value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/microsoft.insights/datacollectionrules/my-dcr"
}
}
}
Azure Arc との関連付けを作成する
次のサンプルでは、Azure Arc 対応サーバーとデータ収集ルールとの間に関連付けを作成します。
テンプレート ファイル
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.HybridCompute/machines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this Arc server.'
dataCollectionRuleId: dataCollectionRuleId
}
}
パラメーター ファイル
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"value": "my-hybrid-vm"
},
"associationName": {
"value": "my-windows-vm-my-dcr"
},
"dataCollectionRuleId": {
"value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/microsoft.insights/datacollectionrules/my-dcr"
}
}
}