AKS Container Insights survives cluster recreate (opt-in)¶
Motivation¶
A user reported that the "App Insights connection" appeared to break after deleting and recreating their AKS cluster. Investigation showed two distinct surfaces were being conflated:
- Control-plane Application Insights (api / worker / beat →
appi-elb-dashboard) was healthy — it lives on the Container App, not the cluster, and telemetry kept flowing (verified via thelog-elb-dashboardLog Analytics workspace: hundreds ofAppRequests/AppTraceson the day of the report). TheDEPLOYMENT · IDLEbadge in Settings → Telemetry is just the browser telemetry toggle being off, not a broken connection. - AKS Container Insights (the
omsagentaddon) genuinely does not survive a cluster delete + recreate. The addon lives on the cluster resource, so a recreated cluster comes up with cluster observability off. Neither the dashboard's provision task norelastic-blast submitre-enabled it, so all live ElasticBLAST clusters were observed withomsagentdisabled.
User-facing change¶
- The AKS provision task (
api.tasks.azure.provision_aks) can now re-enable Container Insights on a freshly provisioned/recreated cluster, off by default. Operators opt in by settingAKS_PROVISION_ENABLE_CONTAINER_INSIGHTS=trueon the api / worker sidecars. When enabled, the task enqueues the existingapi.tasks.azure.enable_aks_container_insightstask (which carries the LinkedAuthorizationFailed self-heal + workspace-RG RBAC retry) against the platform Log Analytics workspace. - Default behaviour is unchanged: with the flag unset, provisioning never
touches the
omsagentaddon, and clusters are re-enabled only via the manual Settings → AKS Observability flow (unchanged). - Off-by-default is deliberate: Container Insights ships node/pod telemetry to
the same
log-elb-dashboardworkspace the control plane uses (capped at 1 GiB/day), so auto-enabling it on a busy BLAST cluster could exhaust the quota and starve the dashboard's own traces.
API / IaC diff summary¶
api/tasks/azure/provision.py: added_container_insights_reenable_enabled()and_maybe_enqueue_container_insights(); the provision task calls the latter (best-effort, never raises) after the cluster + RBAC are ready and returns the new optionalcontainer_insights_task_idfield.infra/modules/containerAppControl.bicep: newlogAnalyticsWorkspaceResourceIdparam; newLOG_ANALYTICS_WORKSPACE_RESOURCE_IDandAKS_PROVISION_ENABLE_CONTAINER_INSIGHTS(default'false') env vars on the api and worker containers. RecompiledcontainerAppControl.json/main.json.infra/main.bicep: passesmonitoring.outputs.workspaceResourceIdinto the control-app module.scripts/dev/postprovision.sh: resolves the workspace ARM resource id and passes it aslogAnalyticsWorkspaceResourceIdto the six-sidecar swap deploy.
Validation evidence¶
uv run pytest -q api/tests/test_azure_provision_aks.py— 34 passed (8 new cases covering the flag parser and the enqueue helper: default-OFF no-op, opted-in-but-no-workspace no-op, opted-in enqueue kwargs, and swallowed enqueue error).az bicep buildforinfra/main.bicepandinfra/modules/containerAppControl.bicep— rc 0; new tokens present in the recompiled JSON.- Live diagnosis: control-plane App Insights confirmed flowing via the
log-elb-dashboardworkspace; all ElasticBLAST clusters confirmed withomsagentdisabled (the broken surface). - Not redeployed — activation requires a deploy (to inject the workspace ARM id env) plus flipping the opt-in flag.