本文說明如何列出可能影響或已影響專案或機構中產品的服務健康狀態事件。 Google Cloud Google Cloud 您將使用 Service Health API。
事前準備
- 針對要列出事件的機構專案啟用 Service Health API。
- 
  
   
   
     
   
  
  
    Verify that billing is enabled for your Google Cloud project. 
- 設定存取 Service Health API 的權限。
- 在機構中設定身分與存取權管理 (IAM) 權限,以便使用 OrganizationEvents 和 OrganizationImpacts API 資源。 - 使用下列任何指令資料之前,請先替換以下項目: - ORGANIZATION ID:您的 Google Cloud 機構 ID。
 - 執行下列指令: - Linux、macOS 或 Cloud Shell- gcloud organizations add-iam-policy-binding ORGANIZATION_ID \ --member {USER|GROUP|SERVICE_ACCOUNT} \ --role roles/servicehealth.viewer - Windows (PowerShell)- gcloud organizations add-iam-policy-binding ORGANIZATION_ID ` --member {USER|GROUP|SERVICE_ACCOUNT} ` --role roles/servicehealth.viewer - Windows (cmd.exe)- gcloud organizations add-iam-policy-binding ORGANIZATION_ID ^ --member {USER|GROUP|SERVICE_ACCOUNT} ^ --role roles/servicehealth.viewer - 如要取得 ORGANIZATION_ID,請參閱「取得機構資源 ID」。 - 機構中所有專案都會繼承機構的 IAM 政策。這些政策可讓您存取整個機構的機構和專案事件 API。 
參考資料
請參閱「事件」(v1、v1beta)、「機構事件」(v1、v1beta) 和「機構影響」(v1、v1beta) API 參考資料,瞭解可用的方法和回應中各個欄位的意義。
設定產品或位置時,請使用 Google Cloud products 和 locations 中的值。
列出專案的所有待處理事件
您可以列出特定專案的所有事件。 Google Cloud Google Cloud
使用任何要求資料之前,請先替換以下項目:
- API_VERSION:要使用的 API 版本。使用 v1或v1beta。
- PROJECT_ID:專案 ID。
HTTP 方法和網址:
GET https://servicehealth.googleapis.com/API_VERSION/projects/PROJECT_ID/locations/global/events?filter=state=ACTIVE%20category=INCIDENT&page_size=2&page_token={page_token}如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{
  "events": [
    {
      "name": "projects/PROJECT_ID/locations/global/events/event-123",
      "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. We thank you for your patience while we worked on resolving the issue.",
      "category": "INCIDENT",
      "detailedCategory": "CONFIRMED_INCIDENT",
      "state": "ACTIVE",
      "detailedState": "CONFIRMED",
      "eventImpacts": [
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "asia-east2",
          }
        },
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "asia-southeast1",
          }
        }
      ],
      "relevance": "RELATED",
      "updateTime": "2022-10-18T17:44:05.690761Z",
      "startTime": "2022-10-18T17:41:20.112287Z",
    },
    {
      "name": "projects/PROJECT_ID/locations/global/events/event-567",
      "title": "Cloud Firestore may experience errors.",
      "description": "Mitigation work is currently underway by our engineering team. The mitigation is expected to complete by 2022-10-07T16:30:00Z.",
      "category": "INCIDENT",
      "detailedCategory": "CONFIRMED_INCIDENT",
      "state": "ACTIVE",
      "detailedState": "CONFIRMED",
      "eventImpacts": [
        {
          "product": {
            "productName": "Cloud Firestore",
            "id": "CETSkT92V21G6A1x28me",
          },
          "location": {
            "locationName": "us-central1-a",
          }
        }
      ],
      "relevance": "RELATED",
      "updateTime": "2022-10-07T15:19:59.409530Z",
      "startTime": "2022-10-07T15:10:35.887125Z",
      "nextUpdateTime": "2022-10-07T16:30:00Z"
    }
  ],
  "nextPageToken": "CgwIw8bDmgYQz4nUlgMQChomcHJvamVjdHMvcHNoLW1hbnVhbC"
}
如果您沒有列出活動的必要權限,系統會顯示 PERMISSION_DENIED 錯誤。
{
  "error": {
    "code": 403,
    "message": "Permission 'servicehealth.events.list' denied on resource '//servicehealth.googleapis.com/projects/PROJECT_ID/locations/global' (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",
          "permission": "servicehealth.events.list"
        }
      }
    ]
  }
}
列出機構的所有未解決事件
您可以列出影響任何專案的所有事件,這些專案已在特定 Google Cloud 機構中啟用 Personalized Service Health。 Google Cloud
使用任何要求資料之前,請先替換以下項目:
- API_VERSION:要使用的 API 版本。使用 v1或v1beta。
- ORGANIZATION_ID:您的 Google Cloud 機構 ID。
HTTP 方法和網址:
GET https://servicehealth.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/locations/global/organizationEvents?filter=state=ACTIVE%20category=INCIDENT&page_size=2&page_token={page_token}如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{
  "organization_events": [
    {
      "name": "organizations/ORGANIZATION_ID/locations/global/organizationEvents/event-123",
      "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. We thank you for your patience while we worked on resolving the issue.",
      "category": "INCIDENT",
      "detailedCategory": "CONFIRMED_INCIDENT",
      "state": "ACTIVE",
      "detailedState": "CONFIRMED",
      "eventImpacts": [
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "asia-east2",
          }
        },
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "asia-southeast1",
          }
        }
      ],
      "updateTime": "2022-10-18T17:44:05.690761Z",
      "startTime": "2022-10-18T17:41:20.112287Z",
    },
    {
      "name": "organizations/ORGANIZATION_ID/locations/global/organizationEvents/event-567",
      "title": "Cloud Firestore may experience errors.",
      "description": "Mitigation work is currently underway by our engineering team. The mitigation is expected to complete by 2022-10-07T16:30:00Z.",
      "category": "INCIDENT",
      "detailedCategory": "CONFIRMED_INCIDENT",
      "state": "ACTIVE",
      "detailedState": "CONFIRMED",
      "eventImpacts": [
        {
          "product": {
            "productName": "Cloud Firestore",
            "id": "CETSkT92V21G6A1x28me",
          },
          "location": {
            "locationName": "us-central1-a",
          }
        }
      ],
      "updateTime": "2022-10-07T15:19:59.409530Z",
      "startTime": "2022-10-07T15:10:35.887125Z",
      "nextUpdateTime": "2022-10-07T16:30:00Z"
    }
  ],
  "nextPageToken": "CgwIw8bDmgYQz4nUlgMQChomcHJvamVjdHMvcHNoLW1hbnVhbC"
}
如要取得 ORGANIZATION_ID,請參閱「取得機構資源 ID」。
如果沒有列出活動的權限,就會收到 PERMISSION_DENIED 錯誤訊息。
{
  "error": {
    "code": 403,
    "message": "Permission 'servicehealth.organizationEvents.list' denied on resource '//servicehealth.googleapis.com/organizations/ORGANIZATION_ID/locations/global' (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": "organizations/<var class="readonly">ORGANIZATION_ID</var>/locations/global",
          "permission": "servicehealth.organizationEvents.list"
        }
      }
    ]
  }
}
列出機構中可能受事件影響的專案
您可以列出特定 Google Cloud 機構下的所有專案,這些專案:
- 可能受到事件 (OrganizationImpact) 影響。
- 已啟用 Personalized Service Health。
使用任何要求資料之前,請先替換以下項目:
- API_VERSION:要使用的 API 版本。使用 v1或v1beta。
- EVENT_ID:可能影響機構的事件 ID。
- ORGANIZATION_ID:您的 Google Cloud 機構 ID。
HTTP 方法和網址:
GET https://servicehealth.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/locations/global/organizationImpacts?filter=events:organizations%2FORGANIZATION_ID%2Flocations%2Fglobal%2FEVENT_ID&page_size=2&page_token={page_token}如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{
  "organization_impacts": [
    {
      "name": "organizations/ORGANIZATION_ID/locations/global/organizationImpacts/impact-123",
      "events": [
        "organizations/ORGANIZATION_ID/locations/global/organizationEvents/EVENT_ID",
      ],
      "asset": {
        "assetName": "//cloudresourcemanager.googleapis.com/projects/{PROJECT_NUMBER_1}",
        "assetType": "cloudresourcemanager.googleapis.com/Project",
      },
      "updateTime": "2022-10-18T17:44:05.690761Z",
    },
    {
      "name": "organizations/ORGANIZATION_ID/locations/global/organizationImpacts/impact-234",
      "events": [
        "organizations/ORGANIZATION_ID/locations/global/organizationEvents/EVENT_ID",
      ],
      "asset": {
        "assetName": "//cloudresourcemanager.googleapis.com/projects/{PROJECT_NUMBER_2}",
        "assetType": "cloudresourcemanager.googleapis.com/Project",
      },
      "updateTime": "2022-10-18T17:44:05.690761Z",
    }
  ],
  "nextPageToken": "CgwIw8bDmgYQz4nUlgMQChomcHJvamVjdHMvcHNoLW1hbnVhbC"
}
如果沒有列出活動的權限,您會收到下列 PERMISSION_DENIED 錯誤。
{
  "error": {
    "code": 403,
    "message": "Permission 'servicehealth.organizationImpacts.list' denied on resource '//servicehealth.googleapis.com/organizations/ORGANIZATION_ID/locations/global' (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": "organizations/ORGANIZATION_ID/locations/global",
          "permission": "servicehealth.organizationImpacts.list"
        }
      }
    ]
  }
}
後續步驟
請參閱操作說明,瞭解如何使用 Service Health API,依專案或機構提取事件資訊。