收集診斷資訊


本文說明如何使用診斷工具收集虛擬機器 (VM) 執行個體的相關資訊。請先使用工具收集的資訊進行基本疑難排解,再與支援團隊聯絡。

這項工具會執行以下作業:

  • 只收集您指定的 VM 資訊。

  • 只會在專案中儲存資訊。

  • Cloud Storage 值區中儲存資訊 10 天,預設情況下只有您可以存取。

在與 Google 支援團隊分享收集到的資訊前,請先執行下列操作:

  1. 檢查機密資訊或個人識別資訊 (PII) 的資訊。

  2. 視需要刪除或遮蓋資訊。

從 VM 收集的診斷資訊

這個診斷工具會收集下列資訊:

如要進一步瞭解 Compute Engine 如何收集這類資訊,請參閱公開存放區

限制

  • 您只能從依據 Windows Server 建立的 VM 收集診斷資訊。

事前準備

  • 根據預設,Compute Engine 會在 v20190714 之後的 Windows Server 公開版本上安裝診斷工具。否則,如果您的 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

    1. 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.

    2. Set a default region and zone.

    REST

    To use the REST API samples on this page in a local development environment, you use the credentials you provide to the 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.

    For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

從 VM 收集診斷資訊

您可以直接在 VM 中執行診斷工具,也可以使用 Google Cloud CLI 在遠端執行。在 Windows 虛擬機器上,請在 C:\Program Files\Google\Compute Engine\diagnostics 目錄中找出診斷工具。

這項工作需要的權限

如要執行這項工作,您必須具備以下權限

  • 專案的 roles/iam.serviceAccountTokenCreator 權限

gcloud

  1. 請授予專案的 iam.serviceAccountTokenCreator 角色:

    gcloud projects add-iam-policy-binding PROJECT_ID \
        --member user:EMAIL \
        --role roles/iam.serviceAccountTokenCreator
    

    更改下列內容:

    • PROJECT_ID:專案 ID
    • EMAIL:授予 iam.serviceAccountTokenCreator 角色的電子郵件地址
  2. 將診斷資訊匯出至 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 名稱
  3. 記錄匯出程序可能需要幾分鐘才能完成。使用 gcloud compute instances get-serial-port-output 指令查看狀態

  4. Compute Engine 會將包含診斷資訊的值區名稱格式化為 diagnostic_logs_project_PROJECT_NUMBER。使用 gcloud CLI 或 Google Cloud 控制台的「Cloud Storage」頁面,查看或下載 bucket:

    前往「儲存空間」

後續步驟