從稽核記錄中擷取 VPC Service Controls 錯誤

本頁面說明如何使用 Cloud Logging 找出 VPC Service Controls 錯誤。

VPC Service Controls 可隔離多租戶 Trusted Cloud by S3NS 服務,協助降低資料竊取風險。詳情請參閱「VPC Service Controls 總覽」。

判斷錯誤是否由 VPC Service Controls 造成

VPC Service Controls 可以修改 Trusted Cloud by S3NS 的屬性,並在不同服務之間產生連鎖性影響。這會導致偵錯問題變得困難,尤其是在您不知道要尋找什麼的情況下。

服務範圍變更最多可能需要 30 分鐘才會生效。變更生效後,除非明確授權,否則受範圍限制的服務存取權不得跨越範圍界線。

如要判斷錯誤是否與 VPC Service Controls 有關,請檢查您是否已啟用 VPC Service Controls,並且已將其套用至您嘗試使用的專案與服務。如要確認專案和服務是否受到 VPC Service Controls 保護,請檢查該資源階層層級的 VPC Service Controls 政策。

假設您間接使用某項服務,而該服務在服務範圍內的專案中,遭到 VPC Service Controls 標記為「受限制的服務」。在這種情況下,VPC Service Controls 可能會拒絕存取要求。

服務通常會透過依附元件傳播錯誤訊息。如果您遇到以下其中一項錯誤,表示 VPC Service Controls 發生問題:

  • Cloud Storage: 403: Request violates VPC Service Controls.

  • BigQuery: 403: VPC Service Controls: Request is prohibited by organization's policy.

  • 其他服務: 403: Request is prohibited by organization's policy.

使用錯誤的專屬 ID

與 Trusted Cloud 控制台不同,gcloud 指令列工具會傳回 VPC Service Controls 錯誤的專屬 ID。如要找出其他錯誤的記錄項目,請使用中繼資料篩選記錄

VPC Service Controls 產生的錯誤會包含專屬 ID,用於識別相關稽核記錄。

如要使用唯一 ID 取得錯誤相關資訊,請按照下列步驟操作:

  1. 在 Trusted Cloud 控制台中,前往「Cloud Logging」頁面,以取得觸發錯誤的服務範圍內專案。

    前往 Cloud Logging

  2. 在搜尋篩選器欄位中,輸入錯誤的專屬 ID。

您會看到相關的記錄項目。

使用中繼資料篩選記錄

您可以使用記錄檔探索工具找出與 VPC Service Controls 相關的錯誤。您可以使用 Logging 查詢語言擷取記錄。如要瞭解如何建構查詢,請參閱「使用 Logging 查詢語言建構查詢」。

主控台

如要透過 Logging 取得過去 24 小時內發生的 VPC Service Controls 錯誤,請按照下列步驟操作:

  1. 前往 Trusted Cloud 控制台的「Cloud Logging」頁面。

    前往 Cloud Logging

  2. 確認您位於服務範圍內的專案中。

  3. 在搜尋篩選器欄位中輸入以下內容:

    protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata"
    
  4. 在「Resource」(資源) 選單中,選取「Audited Resource」(已稽核的資源)

  5. 在時間範圍選取器選單中,選取「過去 24 小時」

  6. 選用:如要找出發生在其他時間範圍內的 VPC Service Controls 錯誤,請使用時間範圍選取器選單。

gcloud

  • 如要取得過去 24 小時內發生的 VPC Service Controls 錯誤,請執行以下指令:

    gcloud logging read 'protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata"'
    

    根據預設,read 指令只能取得過去 24 小時內的資料。如要取得其他時間範圍的 VPC Service Controls 記錄,請使用以下其中一項指令:

  • 如要擷取特定時間範圍內產生的記錄檔 (從目前日期算起),請執行下列指令:

    gcloud logging read \
    'protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata"' \
      --freshness=DURATION
    

    「DURATION」DURATION是格式化的時間範圍。如要進一步瞭解格式設定,請參閱 gcloud CLI 的相對期間和時間格式

  • 如要擷取過去一週內發生的所有 VPC Service Controls 錯誤,請執行下列指令:

    gcloud logging read \
    'protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata"' \
      --freshness=7d
    
  • 如要擷取特定日期之間產生的記錄,請執行下列指令:

    gcloud logging read \
    'protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata" AND
    timestamp>="START_DATETIME" AND
    timestamp<="END_DATETIME"'
    

    START_DATETIMEEND_DATETIME 是格式化的日期和時間字串。如要進一步瞭解格式設定,請參閱 gcloud CLI 的絕對日期和時間格式

    舉例來說,如要取得發生在 2019 年 3 月 22 日到 2019 年 3 月 26 日這段期間內的所有 VPC Service Controls 錯誤,請使用以下指令:

    gcloud logging read \
    'protoPayload.metadata.@type:"type.googleapis.com/google.cloud.audit.VpcServiceControlAuditMetadata" AND
      timestamp>="2019-03-22T23:59:59Z" AND
      timestamp<="2019-03-26T00:00:00Z"'
    

後續步驟