Management
Data collection rule
Defines which monitoring data to collect, how to transform it, and where to send it.
Naming rules
- Abbreviation
- Length
- Up to 64 (module guidance)
- Allowed characters
- See Microsoft’s resource reference.
- Uniqueness scope
- See resource reference
Azure Verified Modules naming utility v0.3.0 · AVM naming key data_collection_rule
Code examples
Adapt the examples to your environment and supply referenced resources and variables.
Terraform
Terraform documentationhcl
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
version = "~> 2.0"
}
}
}
variable "location" {
type = string
}
variable "name" {
type = string
}
variable "parent_id" {
description = "Full Azure resource ID of the parent resource or resource group."
type = string
}
resource "azapi_resource" "example" {
type = "Microsoft.Insights/dataCollectionRules@2024-03-11"
name = var.name
parent_id = var.parent_id
location = var.location
body = {
properties = {
destinations = {
azureMonitorMetrics = {
name = "metrics"
}
}
dataFlows = [
{
streams = [
"Microsoft-InsightsMetrics"
]
destinations = [
"metrics"
]
}
]
}
}
}
Bicep
Bicep documentationbicep
param location string
param name string
resource example 'Microsoft.Insights/dataCollectionRules@2024-03-11' = {
name: name
location: location
properties: {
destinations: {
azureMonitorMetrics: {
name: 'metrics'
}
}
dataFlows: [
{
streams: [
'Microsoft-InsightsMetrics'
]
destinations: [
'metrics'
]
}
]
}
}
ARM template
ARM template documentationjson
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"name": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRules",
"apiVersion": "2024-03-11",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {
"destinations": {
"azureMonitorMetrics": {
"name": "metrics"
}
},
"dataFlows": [
{
"streams": [
"Microsoft-InsightsMetrics"
],
"destinations": [
"metrics"
]
}
]
}
}
]
}