Before collecting usage data, determine what monitoring is available on the cluster:
bash
# 1. Check if Azure Managed Prometheus is enabledaz aks show \ --name "<CLUSTER_NAME>" --resource-group "<RESOURCE_GROUP>" \ --query "azureMonitorProfile.metrics.enabled" -o tsv# 2. Check if Container Insights (Log Analytics) is enabledaz aks show \ --name "<CLUSTER_NAME>" --resource-group "<RESOURCE_GROUP>" \ --query "addonProfiles.omsagent.enabled" -o tsv# 3. Check if Metrics Server is running (pre-installed on AKS, but may be unhealthy)kubectl get deployment metrics-server -n kube-system
Based on the result, follow the appropriate path:
State
Rightsizing Possible?
Data Source
Accuracy
Azure Managed Prometheus enabled
Yes
Prometheus metrics via Azure Monitor
Best — full P95/7-day history
Container Insights (Log Analytics) enabled
Yes
KQL queries on Perf / KubePodInventory
Good — 7-day trends
Only Metrics Server (no Azure Monitor)
Limited
kubectl top pods — live data only
Low — no historical trends
If nothing is enabled, Metrics Server is pre-installed on AKS — confirm it is healthy and use it for live rightsizing data:
bash
kubectl get deployment metrics-server -n kube-systemkubectl top pods --all-namespaces --sort-by=cpu
For historical P95 trends (more accurate rightsizing), recommend enabling Azure Managed Prometheus. Warn user this incurs cost and wait for confirmation before proceeding.
# Authenticate to clusteraz aks get-credentials --name "<CLUSTER_NAME>" --resource-group "<RESOURCE_GROUP>"# List requests/limits for ALL containers per pod (includes sidecars)# Using [*] ensures multi-container pods are not misrepresentedkubectl get pods --all-namespaces \ -o custom-columns="NAMESPACE:.metadata.namespace,POD:.metadata.name,CONTAINERS:.spec.containers[*].name,CPU_REQ:.spec.containers[*].resources.requests.cpu,MEM_REQ:.spec.containers[*].resources.requests.memory,CPU_LIM:.spec.containers[*].resources.limits.cpu,MEM_LIM:.spec.containers[*].resources.limits.memory"# Live per-container usage (shows each container individually, including sidecars)kubectl top pods --all-namespaces --containers --sort-by=cpu