Last active
July 6, 2021 05:43
-
-
Save kshitijcode/7f4175ca7daeac637375e39b6c909fae to your computer and use it in GitHub Desktop.
Kusto Query for Plotting Pod Memory Usage in Grafana for Azure Kubernetes Service and 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 == "payments-ns" | |
| where $__timeFilter(TimeGenerated) | |
| extend JustContainerName=tostring(split(ContainerName, '/')[1]) | |
| extend InstanceName=strcat(ClusterId, '/', PodUid, '/', JustContainerName) | |
| summarize by bin(TimeGenerated, 1m),InstanceName, Name | |
| join ( | |
Perf | |
| where ObjectName == 'K8SContainer' | |
| where CounterName == 'memoryRssBytes' | |
| where $__timeFilter(TimeGenerated) | |
| summarize UsageValue = avg(CounterValue / (1024 * 1024)) by bin(TimeGenerated, 1m),InstanceName, CounterName | |
| project-away CounterName | |
) on InstanceName,TimeGenerated | |
| summarize MemoryUsageMB = max(UsageValue) by bin(TimeGenerated,1m), Name | |
| order by TimeGenerated asc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment