Bird
Raised Fist0
Azurecloud~5 mins

AKS monitoring with Container Insights in Azure - Commands & Configuration

Choose your learning style10 modes available
Introduction
Monitoring your Azure Kubernetes Service (AKS) cluster helps you see how your apps and infrastructure are doing. Container Insights collects data about your containers and nodes so you can find and fix problems quickly.
When you want to track the health and performance of your AKS cluster in real time.
When you need to see logs and metrics from your containers to troubleshoot issues.
When you want to get alerts if your AKS cluster has problems like high CPU or memory use.
When you want to understand resource usage to optimize costs in your AKS environment.
When you want to visualize your container workloads and their status in Azure Monitor.
Commands
This command enables Container Insights monitoring addon on your AKS cluster to start collecting logs and metrics.
Terminal
az aks enable-addons --resource-group example-resource-group --name example-aks-cluster --addons monitoring
Expected OutputExpected
Addon monitoring is enabled for cluster example-aks-cluster in resource group example-resource-group.
→
--resource-group - Specifies the resource group where your AKS cluster is located.
→
--name - Specifies the name of your AKS cluster.
→
--addons - Specifies which addon to enable, here it is monitoring for Container Insights.
This command checks if the monitoring addon is enabled on your AKS cluster.
Terminal
az aks show --resource-group example-resource-group --name example-aks-cluster --query addonProfiles.omsagent.enabled
Expected OutputExpected
true
→
--query - Filters the output to show only the monitoring addon status.
This command shows details of the Log Analytics workspace where Container Insights sends monitoring data.
Terminal
az monitor log-analytics workspace show --resource-group example-resource-group --workspace-name example-workspace
Expected OutputExpected
{ "customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "location": "eastus", "name": "example-workspace", "resourceGroup": "example-resource-group", "sku": { "name": "PerGB2018" }, "type": "Microsoft.OperationalInsights/workspaces" }
→
--workspace-name - Specifies the name of the Log Analytics workspace.
This command downloads the cluster credentials so you can use kubectl to interact with your AKS cluster.
Terminal
az aks get-credentials --resource-group example-resource-group --name example-aks-cluster
Expected OutputExpected
Merged "example-aks-cluster" as current context in /home/user/.kube/config
This command lists the monitoring agent pods running in the kube-system namespace to verify Container Insights agents are active.
Terminal
kubectl get pods -n kube-system -l app=omsagent
Expected OutputExpected
NAME READY STATUS RESTARTS AGE omsagent-abcde 1/1 Running 0 10m omsagent-fghij 1/1 Running 0 10m
→
-n - Specifies the namespace to look in, here kube-system where monitoring agents run.
→
-l - Filters pods by label, here to find omsagent pods.
Key Concept

If you remember nothing else from this pattern, remember: enabling the monitoring addon on AKS automatically sets up Container Insights to collect and send your cluster's health and performance data to Azure Monitor.

Common Mistakes
Trying to enable monitoring addon on a non-existent AKS cluster.
The command fails because the cluster name or resource group is incorrect or the cluster does not exist.
Verify the AKS cluster name and resource group with 'az aks list' before enabling addons.
Not checking if the monitoring addon is enabled after running the enable command.
You might think monitoring is active but it is not, so you won't get logs or metrics.
Always run 'az aks show' with query to confirm the monitoring addon is enabled.
Not having kubectl configured with cluster credentials before checking monitoring pods.
kubectl commands will fail or show no pods if credentials are missing.
Run 'az aks get-credentials' to configure kubectl before querying pods.
Summary
Enable Container Insights monitoring addon on your AKS cluster using Azure CLI.
Verify the monitoring addon is enabled to ensure data collection is active.
Check the Log Analytics workspace where monitoring data is sent.
Download cluster credentials to use kubectl for inspecting monitoring agent pods.
Confirm monitoring agents are running in the kube-system namespace.

Practice

(1/5)
1. What is the primary purpose of enabling Container Insights on an AKS cluster?
easy
A. To increase the number of nodes in the cluster automatically
B. To deploy applications faster on AKS
C. To monitor the health and performance of the AKS cluster
D. To secure the AKS cluster with firewall rules

Solution

  1. Step 1: Understand Container Insights role

    Container Insights is designed to collect and display health and performance data for AKS clusters.
  2. Step 2: Compare options with Container Insights function

    Only monitoring health and performance matches Container Insights' purpose; other options relate to scaling, deployment, or security.
  3. Final Answer:

    To monitor the health and performance of the AKS cluster -> Option C
  4. Quick Check:

    Container Insights = Monitoring AKS health [OK]
Hint: Container Insights is about monitoring, not scaling or security [OK]
Common Mistakes:
  • Confusing monitoring with scaling features
  • Thinking it deploys apps faster
  • Assuming it manages security rules
2. Which Azure CLI command correctly enables Container Insights monitoring on an existing AKS cluster named myCluster in resource group myGroup?
easy
A. az aks update --enable-monitoring --name myCluster --resource-group myGroup
B. az aks enable-addons --addons monitoring --name myCluster --resource-group myGroup
C. az aks create --addons monitoring --name myCluster --resource-group myGroup
D. az monitor enable --resource-group myGroup --name myCluster

Solution

  1. Step 1: Identify the correct command to enable addons

    The command to enable addons on an existing AKS cluster is az aks enable-addons with the --addons monitoring flag.
  2. Step 2: Verify command syntax and parameters

    az aks enable-addons --addons monitoring --name myCluster --resource-group myGroup uses the correct command and parameters: cluster name and resource group are specified properly.
  3. Final Answer:

    az aks enable-addons --addons monitoring --name myCluster --resource-group myGroup -> Option B
  4. Quick Check:

    Enable addons command = az aks enable-addons --addons monitoring --name myCluster --resource-group myGroup [OK]
Hint: Use 'az aks enable-addons' with '--addons monitoring' [OK]
Common Mistakes:
  • Using 'az aks create' instead of enable-addons
  • Trying 'az aks update' with wrong flags
  • Confusing Azure Monitor commands with AKS commands
3. After enabling Container Insights on your AKS cluster, you run this command:
az aks show --name myCluster --resource-group myGroup --query addonProfiles

What output indicates that monitoring is enabled?
medium
A. {"omsagent": {"enabled": true}}
B. {"monitoring": {"status": "active"}}
C. {"containerInsights": {"enabled": false}}
D. {"omsagent": {"enabled": false}}

Solution

  1. Step 1: Understand addonProfiles output for monitoring

    The monitoring addon in AKS is called 'omsagent'. When enabled, its 'enabled' property is true.
  2. Step 2: Match output with enabled monitoring

    {"omsagent": {"enabled": true}} shows 'omsagent' with 'enabled': true, indicating monitoring is active.
  3. Final Answer:

    {"omsagent": {"enabled": true}} -> Option A
  4. Quick Check:

    omsagent enabled = true means monitoring active [OK]
Hint: 'omsagent' enabled true means Container Insights is on [OK]
Common Mistakes:
  • Looking for 'monitoring' or 'containerInsights' keys instead of 'omsagent'
  • Confusing enabled false as active
  • Misreading JSON structure
4. You enabled monitoring on your AKS cluster but do not see any logs or metrics in Azure Monitor. Which of the following is the most likely cause?
medium
A. Container Insights only works with Windows nodes, not Linux
B. The AKS cluster nodes are running an unsupported Kubernetes version
C. The Azure CLI command used was missing the --resource-group parameter
D. The Log Analytics workspace was not linked or created during monitoring setup

Solution

  1. Step 1: Identify key requirement for Container Insights data

    Container Insights requires a Log Analytics workspace to collect and store logs and metrics.
  2. Step 2: Analyze why no data appears

    If the workspace was not linked or created, no data will flow to Azure Monitor, causing empty logs and metrics.
  3. Final Answer:

    The Log Analytics workspace was not linked or created during monitoring setup -> Option D
  4. Quick Check:

    Missing workspace = no logs in Azure Monitor [OK]
Hint: Check Log Analytics workspace linkage if no monitoring data shows [OK]
Common Mistakes:
  • Assuming Kubernetes version blocks monitoring data
  • Thinking missing CLI parameters always cause no data
  • Believing Container Insights only supports Windows nodes
5. You want to set up alerts in Azure Monitor for your AKS cluster using Container Insights to notify you when CPU usage exceeds 80% for 5 minutes. Which steps should you follow?
hard
A. Create a Log Analytics query for CPU usage, then create an alert rule based on that query with a 5-minute evaluation period
B. Enable monitoring with az aks enable-addons, then configure alerts directly in AKS cluster settings
C. Install a custom agent on each node to send CPU metrics, then configure alerts in Azure Monitor
D. Use Azure CLI to scale the cluster automatically when CPU exceeds 80%

Solution

  1. Step 1: Use Log Analytics to query CPU metrics

    Container Insights sends metrics to Log Analytics, where you can write queries to analyze CPU usage.
  2. Step 2: Create an alert rule in Azure Monitor

    Set an alert rule using the query with a condition for CPU > 80% sustained over 5 minutes to trigger notifications.
  3. Final Answer:

    Create a Log Analytics query for CPU usage, then create an alert rule based on that query with a 5-minute evaluation period -> Option A
  4. Quick Check:

    Alerts need queries + rules in Azure Monitor [OK]
Hint: Use Log Analytics queries to create alerts in Azure Monitor [OK]
Common Mistakes:
  • Thinking alerts are configured directly in AKS without Azure Monitor
  • Assuming custom agents are needed for CPU metrics
  • Confusing scaling actions with alert setup
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard