本文档介绍了如何列出可能正在影响或已影响 Google Cloud 项目或组织中 Google Cloud 产品的服务运行状况事件。您将使用 Service Health API。
准备工作
- 为您组织下要列出事件的项目启用 Service Health API。
-
Make sure 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。
参考
请参阅 Events (v1、v1beta)、OrganizationEvents (v1、v1beta) 和 OrganizationImpacts (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"
}
}
]
}
}
列出组织的所有有效突发事件
您可以列出特定组织中启用了 Personalized Service Health 的所有项目所受影响的所有突发事件。 Google Cloud 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 按项目或组织提取事件信息的方法。