管理影响组织的事件

本文档介绍了如何使用 Service Health API 管理影响贵组织的事件。

Personalized Service Health 提供 OrganizationEvents 和 OrganizationImpacts API 资源,可让您获取有关影响贵组织的事件的信息。此类信息包括:

  • 可能会影响组织中一个或多个项目的服务运行状况事件。
  • 可能受影响或已受影响的项目列表。

API 资源不会获取影响组织的所有事件,也不会在服务运行状况信息中心中显示这些事件。

准备工作

  1. 为贵组织下至少一个项目启用 Service Health API。OrganizationEvents 和 OrganizationImpacts API 资源仅可获取已启用 Service Health API 的项目的信息。
  2. 设置访问 Service Health API 的权限
  3. 为您的组织配置 Identity and Access Management (IAM) 权限,以使用 OrganizationEvents 和 OrganizationImpacts API 资源。运行以下命令:

    gcloud organizations add-iam-policy-binding $ORGANIZATION_ID \
      --member {USER|GROUP|SERVICE_ACCOUNT} \
      --role roles/servicehealth.viewer
    

    如需获取 ORGANIZATION_ID,请参阅获取组织资源 ID

    组织中所有项目都会继承为组织授予的 IAM 政策。借助这些政策,您可以访问整个组织中的组织和项目事件 API。

参考

如需了解您可以使用的方法以及响应中字段的含义,请参阅 OrganizationEventsOrganizationImpacts API 参考。

设置商品或地理位置时,请使用 Google Cloud productslocations 中找到的值。

列出可能受事件影响的组织下项目

请参阅快速入门

列出组织的所有有效突发事件

请参阅快速入门

获取影响组织的事件的详细信息

您可以使用 Get API 查看影响组织的事件的详细信息。

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

  • API_VERSION:要使用的 API 版本。请使用 v1v1beta
  • ORGANIZATION_ID:您的 Google Cloud 组织 ID。

HTTP 方法和网址:

GET https://servicehealth.googleapis.com/API VERSION/organizations/ORGANIZATION_ID/locations/global/organizationEvents/EVENT_ID

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "name": "organizations/ORGANIZATION_ID/locations/global/organizationEvents/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",
      "eventImpacts": [
        {
          "product": {
            "productName": "Google Cloud SQL",
            "id": "hV87iK5DcEXKgWU2kDri",
          },
          "location": {
            "locationName": "us-central1",
          }
        }
      ],
   "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.organizationEvents.get' denied on resource '//servicehealth.googleapis.com/organizations/ORGANIZATION_ID/locations/global/organizationEvents/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": "organizations/ORGANIZATION_ID/locations/global/organizationEvents/EVENT_ID",
          "permission": "servicehealth.organizationEvents.get"
        }
      }
    ]
  }
}

如需修正此错误,请设置所需的权限

获取可能受到事件影响的组织下项目的详细信息

对于给定事件,项目事件和组织事件中的事件 ID 保持不变。OrganizationImpact 包含 EVENT_IDPROJECT_NUMBER,您可以使用它们来获取影响项目的事件的详细信息。这些详细信息包括 staterelevance

PROJECT_NUMBER 可与 Get API 返回的 PROJECT_ID 互换使用。