Azure Kubernetes Service
Observability
Container insights for AKS
Azure Monitor is Microsoft’s native solution for collecting and analyzing metrics and logs from applications, infrastructure, and Azure services. With Container Insights for Azure Kubernetes Service (AKS), you gain end-to-end visibility into your containerized workloads—helping you troubleshoot performance issues, improve availability, and optimize resource utilization.
It delivers:
- Real-time metrics and logs
- Interactive dashboards and workbooks
- Alerting and diagnostic capabilities
What Is Container Insights?
Container Insights is an Azure Monitor feature built specifically for AKS clusters. It collects performance and health data across your nodes and containers, allowing you to:
- Detect resource hotspots
- Trace application failures
- Set up proactive alerts
Container Insights aggregates two primary data types:
Data Type | Description | Examples |
---|---|---|
Metrics | Numerical values over time | CPU usage, memory consumption, network I/O |
Logs | Structured or unstructured event records | Container logs, system events, application traces |
Metrics power visualizations and alerts, while logs are stored in a Log Analytics workspace for ad-hoc querying and root-cause analysis.
Azure Monitoring Agent Architecture
Enabling the monitoring add-on on AKS deploys two Azure Monitoring Agents (AMA):
Agent Type | Deployment Method | Role |
---|---|---|
AMA ReplicaSet | ReplicaSet (1 pod) | Cluster-level failover for metrics |
AMA DaemonSet | DaemonSet (all nodes) | Node-level metrics & log collection |
Both agents send data to a dedicated Log Analytics workspace for storage and analysis.
Demo: Create an AKS Cluster with Container Insights
Follow these steps in the Azure portal to spin up an AKS cluster with Container Insights:
- Navigate to Create Kubernetes cluster.
- Under the Integration tab, enable Container Insights.
- (Optional) Enable Managed Prometheus and Managed Grafana.
- For this demo, toggle Alerting Off.
- Review and Create.
Once deployment finishes, open your AKS resource and select Monitoring > Container Insights.
Exploring Cluster Metrics
The Container Insights dashboard provides a high-level overview of your AKS environment:
- Total node count
- CPU and memory utilization over time
- Active pod count
Generating Load with a Stress Test
To observe real-time metric changes, create CPU load in a test namespace:
# Verify AMA deployments
kubectl get daemonset ama-logs -n kube-system
kubectl get replicaset ama-logs-rs -n kube-system
# Create test namespace
kubectl create namespace containerinsightstest
kubectl config set-context --current --namespace=containerinsightstest
# Start an interactive shell pod
kubectl run test-shell --rm -it --image=ubuntu -- bash
Inside the test-shell
pod:
apt update && apt install -y stress
stress --cpu 10
This generates 10 CPU workers, driving node CPU usage upward. In the portal, return to Container Insights > Cluster, enable live updates, and watch the CPU graph spike.
Viewing Node and Container Details
Within Container Insights:
- Nodes tab: Displays per-node CPU/memory metrics. The stressed node will be easily identifiable.
- Containers tab: Lists every container and its performance metrics.
Click on test-shell
to view its live status, console output, and event timeline:
4 mins ago [Pod] [test-shell] Pulling image "ubuntu"
4 mins ago [Pod] [test-shell] Pulled: Successfully pulled image "ubuntu" in 1.80s
4 mins ago [Pod] [test-shell] Created: Created container test-shell
4 mins ago [Pod] [test-shell] Started: Started container test-shell
243 secs ago [Pod] [test-shell] Scheduled: Assigned to aks-agentpool-77882287-vmss000000
Cost Considerations
Azure Monitor charges based on the volume of data ingested into Log Analytics. Enabling Managed Prometheus increases ingestion volume, and Azure Managed Grafana incurs additional per-user costs.
Note
Review your ingestion rates and retention settings in your Log Analytics workspace to optimize costs.
Integrating Prometheus and Grafana
Azure Monitor for Containers can natively scrape Prometheus endpoints—no self-hosted server needed. Expose your metrics endpoint to AMA, and configure PromQL alerts.
Component | Purpose |
---|---|
Prometheus | Pull-based metric collection and querying (PromQL) |
Grafana | Dashboarding and multi-source alerting |
If you enabled Grafana during cluster creation:
- Open the Grafana resource in the Azure portal.
- Copy the Instance URL and sign in with Azure AD.
- Browse pre-built Azure dashboards under Dashboards.
Thank you for learning how to leverage Container Insights for AKS. For more details, see Azure Monitor for Containers documentation.
Watch Video
Watch video content