管理專案的事件

本文說明如何使用 Service Health API,管理影響單一專案的事件。

事前準備

確認 Google Cloud 專案已啟用計費功能。

  1. 為要管理事件的專案啟用 Service Health API。
  2. 設定存取 Service Health API 的權限。

參考資料

請參閱 Events API 參考資料 (v1、v1beta),瞭解可用的方法和回應中欄位的意義。在 API 回應中,impact 清單中的每個項目都包含受影響產品和位置的精細中斷 state (AFFECTED 或 RESOLVED)、startTime 和 endTime (解決時)。

設定產品或位置時,請使用 Google Cloud products 和 locations 中的值。

列出專案的所有進行中事件

請參閱快速入門導覽課程。

取得事件詳細資料

您可以使用 Get API 查看事件的詳細資訊。

使用任何要求資料之前,請先修改下列項目的值:

  • API_VERSION:要使用的 API 版本。使用 v1 或 v1beta。
  • PROJECT_ID:您的 Google Cloud 專案 ID。
  • EVENT_ID:事件 ID。

HTTP 方法和網址:

GET https://servicehealth.googleapis.com/API VERSION/projects/PROJECT_ID/locations/global/events/EVENT_ID

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:

{
  "name": "projects/PROJECT_ID/locations/global/events/EVENT_ID",
      "title": "We are experiencing a connectivity issue affecting Google Cloud SQL in us-east1, australia-southeast2.",
      "description": "The issue with Google Cloud SQL has been resolved for all affected projects as of Tuesday, 2022-10-18 11:00 US/Pacific. We thank you for your patience while we worked on resolving the issue.",
      "category": "INCIDENT",
      "detailedCategory": "CONFIRMED_INCIDENT",
      "state": "CLOSED",
      "detailedState": "RESOLVED",
      "artifacts": [
        {
          "artifact": "projects/PROJECT_ID/locations/global/artifacts/artifact_id",
          "artifactCategory": "ARTIFACT_CATEGORY_INCIDENT_REPORT",
        }
      ],
      "eventImpacts": [
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "us-central1",
          }
        }
      ],
      "relevance": "RELATED",
   "updates": [
    {
      "updateTime": "2022-10-18T17:41:20.112287Z",
              "title": "We are experiencing a connectivity issue affecting Google Cloud SQL in us-east1, australia-southeast2.",
      "description": "We are experiencing an intermittent issue with Google Cloud SQL. Our engineering team continues to investigate the issue.",
      "symptom": "None at this time.",
      "workaround": "None at this time."
    },
    {
      "updateTime": "2022-10-18T18:00:05.690761Z",
      "title": "We are experiencing a connectivity issue affecting Google Cloud SQL in us-east1, australia-southeast2.",
      "description": "The issue with Google Cloud SQL has been resolved for all affected projects as of Tuesday, 2022-10-18 11:00 US/Pacific.\n\nWe thank you for your patience while we worked on resolving the issue.",
      "symptom": "None at this time.",
      "workaround": "None at this time."
    }
  ],
  "updateTime": "2022-10-18T18:00:05.690761Z",
  "startTime": "2022-10-18T17:41:20.112287Z",
  "endTime":  "2022-10-18T18:00:05.690761Z",
}

如果您沒有取得事件的權限,會收到下列 PERMISSION_DENIED 錯誤。

{
  "error": {
    "code": 403,
    "message": "Permission 'servicehealth.events.get' denied on resource '//servicehealth.googleapis.com/projects/PROJECT_ID/locations/global/events/EVENT_ID' (or it may not exist).",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "IAM_PERMISSION_DENIED",
        "domain": "servicehealth.googleapis.com",
        "metadata": {
          "resource": "projects/PROJECT_ID/locations/global/events/EVENT_ID",
          "permission": "servicehealth.events.get"
        }
      }
    ]
  }
}

如要修正錯誤,請設定必要權限。

列出專案中受影響的資源

如果是支援的 Google Cloud 產品,您可以列出專案中受 Personalized Service Health 事件影響的特定 Google Cloud 資源。

如要列出受影響的資源,必須在事件開始前至少 24 小時,為專案啟用 Service Health API (servicehealth.googleapis.com),且主體必須具備 servicehealth.impacts.list 權限 (包含在 roles/servicehealth.viewer 中)。

REST API (v1beta)

如要列出專案中受影響的資源,請將要求傳送至 Service Health API,並附上下列參數:

參數 值 說明
parent projects/PROJECT_ID/locations/global 這是必要旗標,要列出受影響資源的專案 ID 或專案編號。
pageSize 1 至 100 選用。每頁傳回的影響數量上限。如未指定,預設值為 10。
pageToken 字串 選用。先前 ListImpactsResponse 的權杖,用於擷取下一頁結果。
filter 字串 選用。篩選運算式,用於限定傳回的影響範圍。舉例來說,如要列出受特定事件影響的資源,請設定 filter=events:projects/PROJECT_ID/locations/global/events/EVENT_ID。

使用任何要求資料之前,請先替換以下項目:

  • PROJECT_ID:您的 Google Cloud 專案 ID 或專案編號。

HTTP 方法和網址:

GET https://servicehealth.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/impacts

如要使用 curl,請直接呼叫 GET 端點:

curl -X GET \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json; charset=utf-8" \
  "https://servicehealth.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/impacts"

gcloud

執行下列指令,列出專案中受影響的資源:

gcloud beta service-health impacts list \
    --project=PROJECT_ID \
    --location=global

如要僅列出受特定事件影響的資源,請傳遞 --filter 旗標:

gcloud beta service-health impacts list \
    --project=PROJECT_ID \
    --location=global \
    --filter="events:projects/PROJECT_ID/locations/global/events/EVENT_ID"

如果要求成功,回應主體會包含 Impact 物件清單,如下所示:

{
  "impacts": [
    {
      "name": "projects/my-project/locations/global/impacts/f9a8b7c6-d5e4-4f3a-9b2c-1d0e9f8a7b6c",
      "events": [
        "projects/my-project/locations/global/events/1234567890abcdef"
      ],
      "asset": {
        "assetName": "//cloudsql.googleapis.com/projects/9876543210/instances/prod-orders-db",
        "assetType": "sqladmin.googleapis.com/Instance"
      },
      "description": "Instance experienced elevated connection errors during regional network disruption.",
      "createTime": "2026-10-08T14:12:05.120450Z",
      "updateTime": "2026-10-08T14:12:05.120450Z"
    }
  ]
}

受影響資源的常見篩選器範例

您可以傳遞 filter 查詢參數 (或 Google Cloud CLI 中的 --filter),縮小傳回的 Impact 記錄範圍:

  • 列出特定事件受影響的資源: filter=events:projects/PROJECT_ID/locations/global/events/EVENT_ID
  • 列出特定資源類型受影響的資源 (例如 Cloud SQL 執行個體):filter=asset.assetType="sqladmin.googleapis.com/Instance"
  • 列出在特定時間戳記後更新的受影響資源: filter=updateTime>"2026-10-08T00:00:00Z"

取得受影響資源的詳細資料

您可以使用 IMPACT_ID 擷取特定 Impact 記錄。

REST API (v1beta)

如要取得特定受影響資源記錄的詳細資料,請傳送包含下列參數的要求:

參數 值 說明
name projects/PROJECT_ID/locations/global/impacts/IMPACT_ID 這是必要旗標,要擷取的Impact記錄完整資源名稱。

HTTP 方法和網址:

GET https://servicehealth.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/impacts/IMPACT_ID
curl -X GET \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json; charset=utf-8" \
  "https://servicehealth.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/impacts/IMPACT_ID"

gcloud

執行下列指令,取得受影響資源記錄的詳細資料:

gcloud beta service-health impacts describe IMPACT_ID \
    --project=PROJECT_ID \
    --location=global

如果要求成功,回應主體會包含 Impact 物件:

{
  "name": "projects/my-project/locations/global/impacts/f9a8b7c6-d5e4-4f3a-9b2c-1d0e9f8a7b6c",
  "events": [
    "projects/my-project/locations/global/events/1234567890abcdef"
  ],
  "asset": {
    "assetName": "//cloudsql.googleapis.com/projects/9876543210/instances/prod-orders-db",
    "assetType": "sqladmin.googleapis.com/Instance"
  },
  "description": "Instance experienced elevated connection errors during regional network disruption.",
  "createTime": "2026-10-08T14:12:05.120450Z",
  "updateTime": "2026-10-08T14:12:05.120450Z"
}