管理项目的事件

本文档介绍了如何使用 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 记录的 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"
}