Skip to content

Instantly share code, notes, and snippets.

@binura-g
Created July 26, 2022 02:00
Show Gist options
  • Save binura-g/b3f4820396a7dd9e45c95fa80cc09b38 to your computer and use it in GitHub Desktop.
Save binura-g/b3f4820396a7dd9e45c95fa80cc09b38 to your computer and use it in GitHub Desktop.
Kusto-AKS Pod CPU Usage Graph
let _Namespace = "Your namespace";
let _ServiceName = "Your Deployment name";
let _ContainerName = "Specific Container name"; // Only required if you have multiple containers running (eg. Sidecar)
KubePodInventory
| where isnotempty(Computer) // eliminate unscheduled pods
| where PodStatus in ('Running')
| where ServiceName has _ServiceName
| where ContainerName has _ContainerName
| where Namespace == _Namespace
| extend ContainerIdentifier=tostring(split(ContainerName, '/')[1])
| extend InstanceName=strcat(ClusterId, '/', PodUid, '/', ContainerIdentifier)
| distinct Name, InstanceName
| join kind=inner
(Perf
| where ObjectName == 'K8SContainer'
| where CounterName == "cpuUsageNanoCores")
on InstanceName
| project CpuUsage=(CounterValue / 1e+9), TimeGenerated, Name
| render timechart;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment