Last active
August 9, 2023 07:34
-
-
Save kshitijcode/399238396d43d7eaddcacc4a980b6c78 to your computer and use it in GitHub Desktop.
Kusto Query for Pod Level CPU Usage for AKS Cluster in Log Analytics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
| join | |
(Perf | |
| where ObjectName == 'K8SContainer' | |
| where CounterName == "cpuUsageNanoCores") on InstanceName | |
| project CounterValue, TimeGenerated, Name | |
| render timechart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment