本文档介绍了如何列出可能影响或曾经影响 Google Cloud 项目或组织中 Google Cloud 产品的服务运行状况事件。您将使用 Service Health API。
准备工作
- 为组织下要列出事件的项目启用 Service Health API。
-
Verify that billing is enabled for your Google Cloud project.
- 设置访问 Service Health API 的权限。
在组织中配置 Identity and Access Management (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 商品和位置中的值。
列出项目的所有有效突发事件
您可以列出特定 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 按项目或组织提取事件信息。