output "workspace_id" { description = "The workspace containing the audit log, for the SIEM or for saved queries made elsewhere." value = azurerm_log_analytics_workspace.audit.id } output "detections" { description = "Each detection and the query behind it." value = local.detections } output "verify" { description = "How to prove the log is kept and the detections fire." value = <<-EOT A diagnostic setting can take up to 90 minutes to start sending after the first apply. Run these drills after that. kubectl exec -it -- true # the pod-exec alert emails after the entry reaches the workspace kubectl get secret -n -o name # with full_audit on, the secret-read alert follows In the workspace: ${local.table} | where TimeGenerated > ago(1h) | summarize count() by Verb, tostring(ObjectRef.resource) Create and then delete a diagnostic setting on a test resource # ${var.cluster_name}-diagnostic-setting-written and ${var.cluster_name}-diagnostic-setting-deleted follow Remove the workspace lock with terraform destroy -target='azurerm_management_lock.alert_path["workspace"]' (module.standard. in front in Hardened), delete one rule's Log Analytics Reader assignment on the workspace, then apply again # ${var.cluster_name}-lock-deleted, then ${var.cluster_name}-rule-access-removed Each scheduled alert's description contains the query that finds its rows. The audit log starts at the first event after apply; nothing before it is kept. Check the table within the first week. Azure disables a rule whose query has failed for a week, and ${var.cluster_name}-rule-disabled reports it. EOT }