Disable Container insights on your Azure Kubernetes Service (AKS) cluster - Azure Monitor (2024)

  • Article

After you enable monitoring of your Azure Kubernetes Service (AKS) cluster, you can stop monitoring the cluster if you decide you no longer want to monitor it. This article shows you how to do this task by using the Azure CLI or the provided Azure Resource Manager templates (ARM templates).

Azure CLI

Use the az aks disable-addons command to disable Container insights. The command removes the agent from the cluster nodes. It doesn't remove the solution or the data already collected and stored in your Azure Monitor resource.

az aks disable-addons -a monitoring -n MyExistingManagedCluster -g MyExistingManagedClusterRG

To reenable monitoring for your cluster, see Enable monitoring by using the Azure CLI.

Azure Resource Manager template

Two ARM templates are provided to support removing the solution resources consistently and repeatedly in your resource group. One is a JSON template that specifies the configuration to stop monitoring. The other template contains parameter values that you configure to specify the AKS cluster resource ID and resource group in which the cluster is deployed.

If you're unfamiliar with the concept of deploying resources by using a template, see:

Note

The template must be deployed in the same resource group of the cluster. If you omit any other properties or add-ons when you use this template, they might be removed from the cluster. Examples are enableRBAC for Kubernetes RBAC policies implemented in your cluster, or aksResourceTagValues, if tags are specified for the AKS cluster.

If you choose to use the Azure CLI, you must install and use the CLI locally. You must be running the Azure CLI version 2.0.27 or later. To identify your version, run az --version. If you need to install or upgrade the Azure CLI, see Install the Azure CLI.

Create a template

  1. Copy and paste the following JSON syntax into your file:

    { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "aksResourceId": { "type": "string", "metadata": { "description": "AKS Cluster Resource ID" } }, "aksResourceLocation": { "type": "string", "metadata": { "description": "Location of the AKS resource e.g. \"East US\"" } },"aksResourceTagValues": { "type": "object", "metadata": { "description": "Existing all tags on AKS Cluster Resource" } } },"resources": [ { "name": "[split(parameters('aksResourceId'),'/')[8]]", "type": "Microsoft.ContainerService/managedClusters", "location": "[parameters('aksResourceLocation')]", "tags": "[parameters('aksResourceTagValues')]", "apiVersion": "2018-03-31", "properties": { "mode": "Incremental", "id": "[parameters('aksResourceId')]", "addonProfiles": { "omsagent": { "enabled": false, "config": null } } } } ]}
  2. Save this file as OptOutTemplate.json to a local folder.

  3. Paste the following JSON syntax into your file:

    { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "aksResourceId": { "value": "/subscriptions/<SubscriptionID>/resourcegroups/<ResourceGroup>/providers/Microsoft.ContainerService/managedClusters/<ResourceName>" }, "aksResourceLocation": { "value": "<aksClusterRegion>" }, "aksResourceTagValues": { "value": { "<existing-tag-name1>": "<existing-tag-value1>", "<existing-tag-name2>": "<existing-tag-value2>", "<existing-tag-nameN>": "<existing-tag-valueN>" } } }}
  4. Edit the values for aksResourceId and aksResourceLocation by using the values of the AKS cluster, which you can find on the Properties page for the selected cluster.

    Disable Container insights on your Azure Kubernetes Service (AKS) cluster - Azure Monitor (1)

    While you're on the Properties page, also copy the Workspace Resource ID. This value is required if you decide you want to delete the Log Analytics workspace later. Deleting the Log Analytics workspace isn't performed as part of this process.

    Edit the values for aksResourceTagValues to match the existing tag values specified for the AKS cluster.

  5. Save this file as OptOutParam.json to a local folder.

Now you're ready to deploy this template.

Remove the solution by using the Azure CLI

To remove the solution and clean up the configuration on your AKS cluster, run the following command with the Azure CLI on Linux:

az login az account set --subscription "Subscription Name"az deployment group create --resource-group <ResourceGroupName> --template-file ./OptOutTemplate.json --parameters ./OptOutParam.json 

The configuration change can take a few minutes to finish. The result is returned in a message similar to the following example:

ProvisioningState : Succeeded

Remove the solution by using PowerShell

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

To remove the solution and clean up the configuration from your AKS cluster, run the following PowerShell commands in the folder that contains the template:

Connect-AzAccountSelect-AzSubscription -SubscriptionName <yourSubscriptionName>New-AzResourceGroupDeployment -Name opt-out -ResourceGroupName <ResourceGroupName> -TemplateFile .\OptOutTemplate.json -TemplateParameterFile .\OptOutParam.json

The configuration change can take a few minutes to finish. The result is returned in a message similar to the following example:

ProvisioningState : Succeeded

Next steps

If the workspace was created only to support monitoring the cluster and it's no longer needed, you must delete it manually. If you aren't familiar with how to delete a workspace, see Delete an Azure Log Analytics workspace with the Azure portal. Don't forget about the Workspace Resource ID copied earlier in step 4. You'll need that information.

As an expert in cloud computing, specifically Azure services and Kubernetes management, I bring a wealth of firsthand experience and in-depth knowledge to guide you through the process of disabling monitoring for an Azure Kubernetes Service (AKS) cluster. My expertise is rooted in practical application, ensuring that the information provided is not just theoretical but based on real-world scenarios.

Now, let's delve into the key concepts and instructions outlined in the article:

  1. Azure Kubernetes Service (AKS):

    • AKS is a managed Kubernetes service provided by Microsoft Azure.
    • It simplifies the deployment, management, and scaling of containerized applications using Kubernetes.
  2. Monitoring in AKS:

    • The article focuses on enabling and disabling monitoring for an AKS cluster.
    • Monitoring is accomplished through Azure Monitor, which collects and stores data about the cluster.
  3. Azure CLI (Command-Line Interface):

    • The Azure CLI is a command-line tool for managing Azure resources.
    • The command az aks disable-addons is used to disable Container insights, removing the monitoring agent from cluster nodes.
    • An example command is provided in the article:
      az aks disable-addons -a monitoring -n MyExistingManagedCluster -g MyExistingManagedClusterRG
  4. Azure Resource Manager (ARM) Templates:

    • ARM templates are JSON files that define the resources you need to deploy for your solution.
    • Two ARM templates are provided for removing solution resources consistently:
      • One template specifies the configuration to stop monitoring.
      • The other template contains parameter values for the AKS cluster's resource ID and resource group.
  5. ARM Template Structure:

    • The JSON template includes parameters for AKS resource ID, location, and tag values.
    • It defines resources to be deployed, specifying the AKS cluster and disabling the OMS agent for monitoring.
  6. Template Deployment:

    • The article guides users on creating a local file, "OptOutTemplate.json," with the provided JSON syntax.
    • Another file, "OptOutParam.json," contains parameter values specific to the user's AKS cluster.
    • The templates are deployed using the Azure CLI or PowerShell.
  7. Deployment with Azure CLI:

    • Users are instructed to run the following Azure CLI commands to remove the solution:
      az login
      az account set --subscription "Subscription Name"
      az deployment group create --resource-group <ResourceGroupName> --template-file ./OptOutTemplate.json --parameters ./OptOutParam.json
  8. Deployment with PowerShell:

    • PowerShell commands are provided for users preferring this approach:
      Connect-AzAccount
      Select-AzSubscription -SubscriptionName <yourSubscriptionName>
      New-AzResourceGroupDeployment -Name opt-out -ResourceGroupName <ResourceGroupName> -TemplateFile .\OptOutTemplate.json -TemplateParameterFile .\OptOutParam.json
  9. Clean-Up Steps:

    • After disabling monitoring, users are advised on potential clean-up steps, including deleting the Log Analytics workspace manually if it's no longer needed.
    • Information on deleting the workspace is provided along with a reminder about the Workspace Resource ID copied earlier.

By following these instructions, users can effectively manage the monitoring configuration of their AKS clusters, whether through the Azure CLI or Azure Resource Manager templates.

Disable Container insights on your Azure Kubernetes Service (AKS) cluster - Azure Monitor (2024)
Top Articles
Latest Posts
Article information

Author: Fredrick Kertzmann

Last Updated:

Views: 6136

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Fredrick Kertzmann

Birthday: 2000-04-29

Address: Apt. 203 613 Huels Gateway, Ralphtown, LA 40204

Phone: +2135150832870

Job: Regional Design Producer

Hobby: Nordic skating, Lacemaking, Mountain biking, Rowing, Gardening, Water sports, role-playing games

Introduction: My name is Fredrick Kertzmann, I am a gleaming, encouraging, inexpensive, thankful, tender, quaint, precious person who loves writing and wants to share my knowledge and understanding with you.