查看 Cloud Run 事件的稽核記錄

本指南說明如何在 Cloud 稽核記錄中,查看 Cloud Run 的二進位授權。

Cloud Logging 中的封鎖部署事件

Logs Explorer

如要在 Cloud Logging Logs Explorer 中查看遭封鎖的部署作業事件,請按照下列步驟操作:

  1. 前往 Cloud 稽核記錄的「Logs Explorer」頁面:

    前往「Logs Explorer」。

  2. 在頁面頂端的「Project Selector」(專案選取器) 中,選取執行 Cloud Run 的Google Cloud 專案 ID。

  3. 在「搜尋查詢」方塊中輸入下列查詢:

    resource.type="cloud_run_revision"
    logName:"cloudaudit.googleapis.com%2Fsystem_event"
    protoPayload.response.status.conditions.reason="ContainerImageUnauthorized"
    
  4. 在日期範圍選取器中選取日期範圍。

如要搜尋記錄項目,請按一下「Expand nested fields」(展開巢狀欄位)。

gcloud

如要使用 Google Cloud CLI,在 Cloud Logging 查看過去一週的政策違規事件,請按照下列步驟操作:

gcloud logging read --order="desc" --freshness=7d \
  'resource.type="cloud_run_revision" AND
   logName:"cloudaudit.googleapis.com%2Fsystem_event" AND
   protoPayload.response.status.conditions.reason="ContainerImageUnauthorized"'

Cloud Logging 中的急用權限事件

急用權限可讓您覆寫二進位授權政策強制執行,並部署違反政策的容器映像檔。

查詢 Cloud Logging,找出指定急用權限的修訂版本

Logs Explorer

如要在 Cloud Logging Logs Explorer 中查看急用權限事件,請按照下列步驟操作:

  1. 前往 Cloud 稽核記錄的「Logs Explorer」頁面:

    前往「Logs Explorer」。

  2. 在頁面頂端的「Project Selector」(專案選取器) 中,選取執行 Cloud Run 的專案 ID。

  3. 在「搜尋查詢」方塊中輸入下列內容:

    resource.type="cloud_run_revision"
    logName:"cloudaudit.googleapis.com%2Fsystem_event"
    "breakglass"
    

    如要進一步縮小搜尋範圍,請加入下列幾行:

    resource.labels.service_name = SERVICE_NAME
    resource.labels.location = LOCATION
    

    在 Cloud Logging 中查看急用權限部署作業

  4. 在日期範圍選取器中選取日期範圍。

如要搜尋記錄項目,請按一下「Expand nested fields」(展開巢狀欄位)。

gcloud

如要使用 gcloud CLI 在 Cloud Logging 中查看過去一週的急用權限事件,請按照下列步驟操作:

gcloud logging read --order="desc" --freshness=7d \
  'resource.type="cloud_run_revision" AND
   logName:"cloudaudit.googleapis.com%2Fsystem_event" AND
   "breakglass"'

查詢 Cloud Logging 失敗時仍開放事件

Logs Explorer

如要在 Cloud Logging Logs Explorer 中查看失敗時仍開放事件,請按照下列步驟操作:

  1. 前往 Cloud 稽核記錄的「Logs Explorer」頁面:

    前往「Logs Explorer」。

  2. 在頁面頂端的「Project Selector」(專案選取器) 中,選取執行 Cloud Run 的專案 ID。

  3. 在「搜尋查詢」方塊中輸入下列內容:

     resource.type="cloud_run_revision"
     logName:"cloudaudit.googleapis.com%2Fsystem_event"
     "encountered an error"
    
  4. 在日期範圍選取器中選取日期範圍。

如要搜尋記錄項目,請按一下「Expand nested fields」(展開巢狀欄位)。

gcloud

如要使用 gcloud CLI,在 Cloud Logging 查看過去一週的失敗時仍開放事件,請按照下列步驟操作:

gcloud logging read --order="desc" --freshness=7d \
  'resource.type="cloud_run_revision" AND
    logName:"cloudaudit.googleapis.com%2Fsystem_event" AND
    "encountered an error"'

查詢 Cloud Logging 中的模擬測試事件

Logs Explorer

如要在 Cloud Logging Logs Explorer 中查看模擬測試事件,請按照下列步驟操作:

  1. 前往 Cloud 稽核記錄的「Logs Explorer」頁面:

    前往「Logs Explorer」。

  2. 在頁面頂端的「Project Selector」(專案選取器) 中,選取執行 Cloud Run 的專案 ID。

  3. 在「搜尋查詢」方塊中輸入下列內容:

    resource.type="cloud_run_revision"
    logName:"cloudaudit.googleapis.com%2Fsystem_event"
    "dry run"
    
  4. 在日期範圍選取器中選取日期範圍。

如要搜尋記錄項目,請按一下「Expand nested fields」(展開巢狀欄位)。

gcloud

如要使用 gcloud CLI,在 Cloud Logging 中查看過去一週的模擬測試部署事件,請按照下列步驟操作:

gcloud logging read --order="desc" --freshness=7d \
  'resource.type="cloud_run_revision" AND
   logName:"cloudaudit.googleapis.com%2Fsystem_event" AND
   "dry run"'

後續步驟