Queries for the KubePodInventory table

For information on using these queries in the Azure portal, see Log Analytics tutorial. For the REST API, see Query.

Pods in crash loop

Determines whether Pods/Containers has Crash-Loop phase.

//Determines whether Pods/Containers has Crash-Loop phase
KubePodInventory
| where ContainerStatus  == 'waiting' 
| where ContainerStatusReason == 'CrashLoopBackOff' or ContainerStatusReason == 'Error'
| extend ContainerLastStatus=todynamic(ContainerLastStatus)
| summarize RestartCount = arg_max(ContainerRestartCount, Computer, Namespace, ContainerLastStatus.reason) by Name

Pods in pending state

Check Pods that cannot be started and their pending time.

//Check Pods that cannot be started and its pending time
KubePodInventory
| where PodStatus == 'Pending'
| project PodCreationTimeStamp, Namespace, PodStartTime, PodStatus, Name, ContainerStatus
| summarize Start = any(PodCreationTimeStamp), arg_max(PodStartTime, Namespace) by Name
| extend PodStartTime = iff(isnull(PodStartTime), now(), PodStartTime)
| extend PendingTime = PodStartTime - Start
| project Name, Namespace ,PendingTime

Find In KubePodInventory

Find in KubePodInventory to search for a specific value in the KubePodInventory table./nNote that this query requires updating the <SeachValue> parameter to produce results

// This query requires a parameter to run. Enter value in SearchValue to find in table.
let SearchValue =  "<SearchValue>";//Please update term you would like to find in the table.
KubePodInventory
| where * contains tostring(SearchValue)
| take 1000