Skip to content

Commit c14492f

Browse files
Merge pull request #223404 from MGoedtel/bug28491
edits to address Terraform deployment bug
2 parents ae06dae + c5f7876 commit c14492f

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

articles/azure-monitor/containers/container-insights-enable-aks.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Monitor an Azure Kubernetes Service (AKS) cluster deployed
33
description: Learn how to enable monitoring of an Azure Kubernetes Service (AKS) cluster with Container insights already deployed in your subscription.
44
ms.topic: conceptual
5-
ms.date: 09/28/2022
5+
ms.date: 01/09/2023
66
ms.custom: devx-track-terraform, devx-track-azurepowershell, devx-track-azurecli, ignite-2022
77
ms.reviewer: aul
88
---
@@ -13,15 +13,15 @@ This article describes how to set up Container insights to monitor a managed Kub
1313

1414
## Prerequisites
1515

16-
If you're connecting an existing AKS cluster to a Log Analytics workspace in another subscription, the Microsoft.ContainerService resource provider must be registered in the subscription with the Log Analytics workspace. For more information, see [Register resource provider](../../azure-resource-manager/management/resource-providers-and-types.md#register-resource-provider).
16+
If you're connecting an existing AKS cluster to a Log Analytics workspace in another subscription, the *Microsoft.ContainerService* resource provider must be registered in the subscription with the Log Analytics workspace. For more information, see [Register resource provider](../../azure-resource-manager/management/resource-providers-and-types.md#register-resource-provider).
1717

1818
## New AKS cluster
1919

2020
You can enable monitoring for an AKS cluster when it's created by using any of the following methods:
2121

2222
- **Azure CLI**: Follow the steps in [Create AKS cluster](../../aks/learn/quick-kubernetes-deploy-cli.md).
2323
- **Azure Policy**: Follow the steps in [Enable AKS monitoring add-on by using Azure Policy](container-insights-enable-aks-policy.md).
24-
- **Terraform**: If you're [deploying a new AKS cluster by using Terraform](/azure/developer/terraform/create-k8s-cluster-with-tf-and-aks), you specify the arguments required in the profile [to create a Log Analytics workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) if you don't choose to specify an existing one. To add Container insights to the workspace, see [azurerm_log_analytics_solution](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_solution). Complete the profile by including the [addon_profile](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster) and specifying **oms_agent**.
24+
- **Terraform**: If you're [deploying a new AKS cluster by using Terraform](/azure/developer/terraform/create-k8s-cluster-with-tf-and-aks), specify the arguments required in the profile [to create a Log Analytics workspace](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) if you don't choose to specify an existing one. To add Container insights to the workspace, see [azurerm_log_analytics_solution](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_solution). Complete the profile by including **oms_agent** profile.
2525

2626
## Existing AKS cluster
2727

@@ -62,21 +62,30 @@ provisioningState : Succeeded
6262

6363
## [Terraform](#tab/terraform)
6464

65-
To enable monitoring by using Terraform:
65+
1. Add the **oms_agent** add-on profile to the existing [azurerm_kubernetes_cluster resource](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) depending on the version of the [Terraform AzureRM provider version](/azure/developer/terraform/provider-version-history-azurerm).
6666

67-
1. Add the **oms_agent** add-on profile to the existing [azurerm_kubernetes_cluster resource](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster).
67+
* If the Terraform AzureRM provider version is 3.0 or higher, add the following:
6868

69-
```
70-
addon_profile {
69+
```
7170
oms_agent {
72-
enabled = true
73-
log_analytics_workspace_id = "${azurerm_log_analytics_workspace.test.id}"
74-
}
75-
}
76-
```
77-
78-
1. Add the [azurerm_log_analytics_solution](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_solution) by following the steps in the Terraform documentation.
79-
1. Enable collection of custom metrics by using the guidance at [Enable custom metrics](container-insights-custom-metrics.md).
71+
log_analytics_workspace_id = "${azurerm_log_analytics_workspace.test.id}"
72+
}
73+
```
74+
75+
* If the Terraform AzureRM provider is less than version 3.0, add the following:
76+
77+
```
78+
addon_profile {
79+
oms_agent {
80+
enabled = true
81+
log_analytics_workspace_id = "${azurerm_log_analytics_workspace.test.id}"
82+
}
83+
}
84+
```
85+
86+
2. Add the [azurerm_log_analytics_solution](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_solution) by following the steps in the Terraform documentation.
87+
88+
3. Enable collection of custom metrics by following the guidance at [Enable custom metrics](container-insights-custom-metrics.md).
8089
8190
## [Azure portal](#tab/portal-azure-monitor)
8291

0 commit comments

Comments
 (0)