Hello Erik Heeren,
We understand that you configured an Azure AKS Cluster, Log Analytics Workspace (LAW), and Data Collection Rule (DCR) using Terraform. The application logs were not appearing in the LAW until the user manually clicked the "enable monitoring" option in the Azure portal.
The primary reason for the failure was the lack of the Data Collection Rule Association (DCRA) and the missing Azure Monitor Agent (AMA) extension deployment.
In the Azure portal's "enable monitoring" button performs several implicit configuration steps that your Terraform code must define explicitly. While you've likely created the DCR and the Log Analytics Workspace (LAW), the vital steps to enable data flow are usually the Agent Deployment and the DCR Association.
- Logs won't flow until the Azure Monitor Agent (AMA) is running on your cluster nodes. The portal's "enable monitoring" feature installs the Container Insights extension (Microsoft.AzureMonitor.Containers), which deploys the AMA as a DaemonSet to collect and send logs/metrics.
- The DCR defines what data to collect and where to send it. However, the cluster needs an explicit instruction telling its onboarded AMA agent which DCR it should follow. This crucial link is the Data Collection Rule Association (DCRA).
- The AMA agent uses a Managed Identity to authenticate and send data. This identity requires permission to write to the Log Analytics workspace. While the oms_agent configuration often handles this implicitly, an explicit grant ensures no permission failures.
Could you please help us with the below details:
- Have you verified that the managed identity for your AKS has been granted necessary permissions (like Log Analytics Contributor) to the Log Analytics workspace?
- Can you confirm whether the diagnostic settings in your Terraform match the settings that get created when you configure them via the portal?
When you delete AKS, DCRs, and even the cluster, the workspace (or its tables) remains unless you explicitly delete it. Container logs (ContainerLogV2) are stored in the workspace, not in the cluster. By default, Log Analytics keeps data for 30 days (or longer if you configured retention). So even if the cluster is gone, the logs remain until retention expires or you purge them. Removing associations stops new ingestion, but historical data stays in the workspace. Certain Azure resources (e.g., storage accounts, workspaces) have a “soft delete” or delayed purge for recovery purposes. Deleting the resource doesn’t instantly erase its data.