共用方式為


KubePodInventory 數據表的查詢

如需在 Azure 入口網站 中使用這些查詢的相關信息,請參閱Log Analytics教學課程。 如需 REST API,請參閱 查詢

損毀迴圈中的Pod

判斷 Pod/容器是否有損毀循環階段。

//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

處於擱置狀態的Pod

檢查無法啟動的 Pod 及其擱置時間。

//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

在 KubePodInventory 中尋找

在 KubePodInventory 中尋找以搜尋 KubePodInventory 數據表中的特定值。/n請注意,此查詢需要更新 <SeachValue> 參數以產生結果

// 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