{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "dataCollectionRulesDCRWindowsEvents": {
            "defaultValue": "DCR_WindowsEvents",
            "type": "String"
        },
        "dataCollectionEndpointsResourceID": {
            "defaultValue": "Replace with DCE Resource ID",
            "type": "String"
        },
        "workspacesResourceID": {
            "defaultValue": "Replace with Log Analytics workspace Resource ID",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Insights/dataCollectionRules",
            "apiVersion": "2023-03-11",
            "name": "[parameters('dataCollectionRulesDCRWindowsEvents')]",
            "location": "westeurope",
            "properties": {
                "dataCollectionEndpointId": "[parameters('dataCollectionEndpointsResourceID')]",
                "streamDeclarations": {
                    "Custom-WindowsEvents-Stream-01": {
                        "columns": [
                            {
                                "name": "TimeGenerated",
                                "type": "datetime"
                            },
                            {
                                "name": "Computer",
                                "type": "string"
                            },
                            {
                                "name": "SourceModuleType",
                                "type": "string"
                            },
                            {
                                "name": "SourceModuleName",
                                "type": "string"
                            },
                            {
                                "name": "Channel",
                                "type": "string"
                            },
                            {
                                "name": "EventData",
                                "type": "dynamic"
                            },
                            {
                                "name": "EventID",
                                "type": "int"
                            },
                            {
                                "name": "EventLevel",
                                "type": "int"
                            },
                            {
                                "name": "EventLevelName",
                                "type": "string"
                            },
                            {
                                "name": "EventRecordId",
                                "type": "string"
                            },
                            {
                                "name": "Keywords",
                                "type": "string"
                            },
                            {
                                "name": "Opcode",
                                "type": "string"
                            },
                            {
                                "name": "Provider",
                                "type": "string"
                            },
                            {
                                "name": "SystemProcessId",
                                "type": "int"
                            }
                        ]
                    }
                },
                "destinations": {
                    "logAnalytics": [
                        {
                            "workspaceResourceId": "[parameters('workspacesResourceID')]",
                            "name": "myworkspace"
                        }
                    ]
                },
                "dataFlows": [
                    {
                        "streams": [
                            "Custom-WindowsEvents-Stream-01"
                        ],
                        "destinations": [
                            "myworkspace"
                        ],
                        "transformKql": "source",
                        "outputStream": "Microsoft-WindowsEvent"
                    }
                ]
            }
        }
    ]
}