配置出站集成,以连接IBM Cloud Logs和IBM Cloud Event Notifications
要发送在 IBM Cloud Logs 实例中触发警报时生成的事件,必须通过配置出站集成将 IBM Cloud Logs 实例连接到 Event Notifications。
先决条件
- 在IBM Cloud Logs 中了解有关警报的信息。 更多信息,请参阅 警报。
- 了解IBM Cloud Event Notifications。 更多信息,请参阅 什么是IBM Cloud Event Notifications?
- 在启用 IBM Cloud Logs 的通知之前,请确保您有 Event Notifications 实例和在 Event Notifications 实例中配置资源的许可。
步骤 1. 定义服务对服务的授权
IBM Cloud账户使用服务对服务授权,授权IBM Cloud Logs服务向Event Notifications服务发送事件。
您必须在IBM Cloud Logs实例和Event Notifications实例之间配置服务对服务授权。 有关详细信息,请参阅 创建S2S授权以便与IBM Cloud Event Notifications服务配合使用。
步骤 2. 使用应用程序接口配置向外集成
您可以使用应用程序接口创建外向集成。 有关 API 方法的更多信息,请参阅 创建出站集成。
您只能通过 API 配置 IBM Cloud Logs 实例和 Event Notifications 实例之间的集成,这两个实例位于不同的账户中。
例如,您可以使用以下 cURL 命令通过 API 创建集成:
curl -X POST "https://API-ENDPOINT/v1/outgoing_webhooks" \
-H "Authorization: ${IAM_TOKEN}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"type": "ibm_event_notifications",
"name": "<NAME>",
"ibm_event_notifications": {
"event_notifications_instance_id": "<EventNotificationsInstanceID>",
"region_id": "<Region-of-EventNotifications-Instance>",
"endpoint_type": "default_or_public"
}
}'
位置
-
API-ENDPOINT:设置 IBM Cloud Logs 实例的 API 端点。 -
type:定义集成类型。 设置为 ibm _event_notifications。 -
name:输入此资源定义的名称。 -
IAM_TOKEN:输入 IAM_TOKEN。 您可以运行以下命令获取 IAM 令牌:export IAM_TOKEN=`ibmcloud iam oauth-tokens --output json | jq -r '.iam_token'` -
event_notifications_instance_id:设置为 Event Notifications 实例 ID。 -
region_id:设置为 Event Notifications 实例可用的区域。 -
endpoint_type:定义集成是通过公共网络还是专用网络进行。 有效值为default_or_public或private
步骤 2. 在用户界面中配置出站集成
完成以下步骤配置出站集成:
- 在控制台中,单击导航菜单图标
> 资源列表。
- 选择您的IBM Cloud Logs 实例。
- 在IBM Cloud Logs导航中,单击集成图标
>出站集成。
- 在向外集成部分,找到Event Notifications并单击添加。
- 在集成页面,单击添加新内容。
- 如果您的账户中不存在介于IBM Cloud Logs和Event Notifications之间的 IAM 授权,则必须点击 IAM 授权 进行配置。 按照提示在服务之间授予访问权限。 有关详细信息,请参阅 创建S2S授权以便与IBM Cloud Event Notifications服务配合使用。
- 输入集成的名称。
- 选择要连接到您的Event Notifications实例的IBM Cloud Logs服务实例。
- 将端点类型选择为公共或私有。 更多信息,请参阅 Event Notifications的服务端点
- 要确认连接,请单击保存。
IBM Cloud Event Notifications }}源文件创建后,文件名为:
IBM Cloud Logs - <CLOUD_LOGS_INSTANCE_ID>
例如,IBM Cloud Event Notifications源名称如下所示:
IBM Cloud Logs - rfdt3147-484f-4dee-b3c7-ab0c85a8e5c7
在 IBM Cloud Event Notifications 实例中,出站集成的名称不用于命名源。
测试连接
启用IBM Cloud Logs的通知功能后,请测试您的连接,确保IBM Cloud Logs生成的事件被转发到Event Notifications。
首先,Event Notifications中完成以下步骤:
-
请验证源名称
IBM Cloud Logs - <CLOUD_LOGS_INSTANCE_ID>,该名称与您IBM Cloud Event Notifications中创建的集成名称一致。- 选择来源。
- 请通过
IBM Cloud Logs - <CLOUD_LOGS_INSTANCE_ID>联系消息来源。
-
创建一个主题,指定此云日志实例为源,并将“事件类型”限定为“测试事件”。
- 选择主题。 然后,单击创建。
- 输入主题名称,例如:
CloudLogsInstance-test。 - 选择源
IBM Cloud Logs - <CLOUD_LOGS_INSTANCE_ID>,以测试您要集成的实例。 - 选择活动类型 “测试活动”。
- 选择添加条件 > 保存源文件。
- 单击创建。
-
创建目的地并 确认目的地已配置。 例如,您可以设置Slack或电子邮件的发送目的地。
-
创建订阅,将主题和目的地配对。
- 输入一个名称,例如
Test integration。 - 请选择主题
CloudLogsInstance-test。 - 请选择目的地。
- 单击创建。
- 输入一个名称,例如
接下来,在 IBM Cloud Logs中,完成以下步骤:
- 编辑出站集成。
- 单击测试。
- 检查您选择的目的地,并确认测试事件已发送。