AKS container log collection is disabled

Enable AKS container log collection and verify that logs arrive.

Description

To send AKS container logs to Azure Monitor, enable the omsagent add-on and connect a Log Analytics workspace.

Potential impact

Without this add-on or another collector, you may have no container logs to investigate a workload failure.

Remediation

Set omsagent.enabled to true and configure collection rules and permissions for the managed identity. Choose a running container in a namespace you collect and find a recent log from it in the workspace. Select control plane logs separately in the cluster’s diagnostic settings.

Examples

The Bicep excerpts cover only the add-on. Supply an existing workspace’s resource ID as the logAnalyticsWorkspaceResourceId parameter. The useAADAuth setting selects managed identity authentication.

Before

bicep
param kubernetesVersion string

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2020-02-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  properties: {
    kubernetesVersion: kubernetesVersion
    addonProfiles: {
      omsagent: {
        enabled: false
      }
    }
  }
}

After

bicep
param kubernetesVersion string
param logAnalyticsWorkspaceResourceId string

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2020-02-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  properties: {
    kubernetesVersion: kubernetesVersion
    addonProfiles: {
      omsagent: {
        enabled: true
        config: {
          logAnalyticsWorkspaceResourceID: logAnalyticsWorkspaceResourceId
          useAADAuth: 'true'
        }
      }
    }
  }
}

References