Infrastructure-as-Code for collecting Windows Event Logs and performance metrics from Active Directory Domain Controllers and generating alerts.
- Log Analytics Workspace
- Data Collection Rule (Windows Event Logs: System, Application, Directory Service, DNS Server, Security)
- Action Group (email receivers)
- Scheduled Query Alerts (Replication errors, Failed logon spike) – TO FIX: current bicep requires schema adjustment
- Metric Alert (CPU) – placeholder
Adjust infra/main.parameters.json then deploy:
# Validate
New-AzResourceGroupDeployment -ResourceGroupName <rg> -TemplateFile .\infra\main.bicep -TemplateParameterFile .\infra\main.parameters.json -WhatIf
New-AzResourceGroupDeployment -ResourceGroupName rg-onprem -TemplateFile main.bicep -TemplateParameterFile main.parameters.json -WhatIf
# Deploy
New-AzResourceGroupDeployment -ResourceGroupName <rg> -TemplateFile .\infra\main.bicep -TemplateParameterFile .\infra\main.parameters.jsonNew-AzResourceGroupDeployment -ResourceGroupName rg-onprem -TemplateFile main.bicep -TemplateParameterFile main.parameters.json
(Or convert to az deployment group create.)
az extension add --name monitor-control-service --yes
$DcrId = az monitor data-collection rule list -g rg-onprem --query "[?name=='dcr-dc-winevents'].id | [0]" -o tsv
az monitor data-collection rule association create --name default --rule-id $DcrId --resource "/subscriptions//resourceGroups/rg-onprem/providers/Microsoft.Compute/virtualMachines/"
az monitor data-collection rule association list --resource "/subscriptions//resourceGroups/rg-spoke1/providers/Microsoft.Compute/virtualMachines/" -o table
Heartbeat | where Computer startswith "" | take 5
Event | where Source in ('Microsoft-Windows-ActiveDirectory_DomainService','DNS Server','Microsoft-Windows-Time-Service') | where TimeGenerated > ago(30m) | summarize count() by Source
- Provide exact Event IDs & thresholds.
- Supply DC VM or Arc resource IDs for
dcResourceIdsin parameters. - Replace placeholder email.
- Fix alert schemas (scheduledQueryRules & metricAlerts) to match stable API versions.
Current alerts.bicep has lint/type warnings; will be refined next iteration.