本文說明如何使用診斷工具收集虛擬機器 (VM) 執行個體的相關資訊。使用工具收集的資訊進行基本疑難排解,然後再與支援團隊聯絡。
這項工具會執行下列作業:
只會收集您指定的 VM 資訊。
只將資訊儲存在專案中。
將資訊儲存在 Cloud Storage 值區 10 天,預設只有您能存取。
與 Google 支援團隊分享收集到的資訊前,請先完成下列步驟:
查看機密或個人識別資訊 (PII) 的相關資訊。
視需要刪除或遮蓋資訊。
從 VM 收集的診斷資訊
這項診斷工具會收集下列資訊:
磁碟:
活動:
- Windows 事件,包括應用程式事件和系統事件
電視網:
計畫:
- 有關程序、排程工作、服務和 Google Kubernetes Engine (GKE) 的 WMI 物件資訊
系統:
- 有關使用者的 WMI 物件資訊、使用這個指令碼的遠端桌面通訊協定 (RDP) 設定,以及 bcdedit、driverquery、msinfo32、pnputil 和 systeminfo 的輸出內容,以及記憶體傾印記錄
如要詳細瞭解 Compute Engine 如何收集這項資訊,請參閱公開存放區。
限制
- 您只能從依據 Windows Server 建立的 VM 收集診斷資訊。
事前準備
-
對於
v20190714
之後的 Windows Server 映像檔公開版本,Compute Engine 預設會安裝診斷工具。否則,如果 Windows Server 映像檔版本早於v20190714
,或是使用自訂映像檔,請使用googet install google-compute-engine-diagnostics
指令安裝工具。 -
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
專案的
roles/iam.serviceAccountTokenCreator
權限 授予專案的
iam.serviceAccountTokenCreator
角色:gcloud projects add-iam-policy-binding PROJECT_ID \ --member user:EMAIL \ --role roles/iam.serviceAccountTokenCreator
更改下列內容:
PROJECT_ID
:專案 IDEMAIL
:要授予「iam.serviceAccountTokenCreator
」角色的電子郵件地址
將診斷資訊匯出為物件至 Cloud Storage 值區。
gcloud compute diagnose export-logs VM_NAME \ [--collect-process-traces]
選用的
--collect-process-traces
旗標會指定診斷工具是否要收集執行中系統的 10 分鐘追蹤記錄,包括 CPU、磁碟、檔案和網路活動。在 Windows VM 上,這會使用 Windows Performance Recorder。更改下列內容:
VM_NAME
:要從中收集診斷資訊的 VM 名稱
匯出記錄程序可能需要幾分鐘才能完成。使用
gcloud compute instances get-serial-port-output
指令查看狀態。Compute Engine 會將包含診斷資訊的值區名稱格式化為
diagnostic_logs_project_PROJECT_NUMBER
。使用 gcloud CLI 查看或下載 bucket,或在Google Cloud 控制台的「Cloud Storage」頁面中執行下列操作:瞭解如何擷取 VM 的螢幕截圖。
瞭解如何排解 Windows 執行個體的問題。
瞭解如何排解遠端桌面通訊協定問題。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
從 VM 收集診斷資訊
您可以直接從 VM 執行診斷工具,也可以使用 Google Cloud CLI 遠端執行。在 Windows VM 中,診斷工具位於
C:\Program Files\Google\Compute Engine\diagnostics
目錄。這項工作需要的權限
如要執行這項工作,您必須具備以下權限:
gcloud
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-09 (世界標準時間)。
-