快速入门:使用 Service Health API 列出影响项目或组织的事件

本文档介绍了如何列出可能正在影响或已经影响 Google Cloud 项目或组织中的 Google Cloud 产品的 Personalized Service Health 事件。您将使用 Personalized Service Health API。

准备工作

  1. 启用 Service Health API(如果尚未启用):

    启用 API 所需的角色

    如需启用 API,您需要拥有 serviceusage.services.enable 权限。如果您创建了项目,则可能已经通过 Owner 角色 (roles/owner) 获得了此权限。否则,您可以通过 Service Usage Admin 角色 (roles/serviceusage.serviceUsageAdmin) 获得此权限。了解如何授予角色。

    gcloud services enable servicehealth.googleapis.com
  2. 验证是否已为您的 Google Cloud 项目启用结算功能。

  3. 如果您要使用现有项目来完成本指南,请验证您是否拥有完成本指南所需的权限。如果您创建了新项目,则您已拥有所需的权限。

所需的角色

如需获得列出 Service Health 事件所需的权限,请让管理员向您授予要为其列出事件的项目或组织的 Personalized Service Health Viewer (roles/servicehealth.viewer) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

参考

请参阅 Events(v1、v1beta)、Impacts (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"
        }
      }
    ]
  }
}

列出组织的所有活跃突发事件

您可以列出影响特定 Google Cloud 组织中已启用 Personalized Service Health 的任何项目的所有 Google Cloud 突发事件。

在使用任何请求数据之前,请先进行以下替换:

  • API_VERSION:要使用的 API 版本。请使用 v1 或 v1beta。
  • ORGANIZATION_ID:您的 Google Cloud 组织 ID。
  • PROJECT_ID:用于配额和结算的项目 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。
  • PROJECT_ID:用于配额和结算的项目 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"
        }
      }
    ]
  }
}

列出项目中受影响的资源

对于受支持的 Google Cloud 产品,您可以列出项目中受 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 记录的 IMPACT_ID 检索该记录。

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"
}

后续步骤

了解如何使用 Service Health API 按项目或组织提取事件信息。