Skip to content

Instantly share code, notes, and snippets.

@kshitijcode
kshitijcode / podCPUUsageKustoQueryLogAnalytics
Last active August 9, 2023 07:34
Kusto Query for Pod Level CPU Usage for AKS Cluster in Log Analytics
KubePodInventory
| where ClusterName == "prod-aks-cluster"
| where isnotempty(Computer) // eliminate unscheduled pods
| where PodStatus in ('Running')
| extend podLabels = parse_json (PodLabel)
| where podLabels[0]['app.kubernetes.io/instance'] == "payment-service"
| where Namespace == "payment-ns"
| extend ActualContainerName=tostring(split(ContainerName, '/')[1])
| extend InstanceName=strcat(ClusterId, '/', PodUid, '/', ActualContainerName)
| distinct Name, InstanceName