按类型创建警报
IBM Cloud® Internet Services 具有可配置为在发生事件时向您发出警告的警报。 使用电子邮件或 Webhook 来接收警报。
警报仅可用于企业套餐。
有关每种类型的警报的更多信息,请参阅 警报类型。
使用 UI 创建电子邮件警报
您可以使用 UI 为每种警报类型创建电子邮件警报。 有关使用控制台创建电子邮件警报的更多信息,请参阅 配置警报策略。
使用 CLI 创建电子邮件警报
您可以使用 CLI 为每种警报类型创建电子邮件警报。
DDoS 攻击层 7 命令
通过运行以下命令,为 DDoS 攻击层 7 创建警报策略:
ibmcloud cis alert-policy ddos-attack-l7-alert-create --name NAME (--emails EMAILS | --webhooks WEBHOOKS) --enabled (true | false) [--description DESCRIPTION] [-i, --instance INSTANCE] [--output FORMAT]
其中:
-
- -name 是警报策略的名称。
-
- -description 是警报策略的描述。
- -- email 是用于分派警报通知的电子邮件地址。 例如,
--emails test1@cn.ibm.com,test2@cn.ibm.com
- -- webhook 是用于分派警报通知的 Webhook 标识。 例如,
--webhook webhookID1,webhookID2
- -- enabled 用于设置是否启用警报策略。
- -i, --instance 是实例名称或 ID。 如果未设置,那么将使用
ibmcloud cis instance-set INSTANCE
指定的上下文实例。 - -- output 指定输出格式; 仅支持 JSON。
池切换警报命令
为池切换警报创建警报策略。
ibmcloud cis alert-policy pool-toggle-alert-create --name NAME (--emails EMAILS | --webhooks WEBHOOKS) --enabled (true | false) --pools POOLS --trigger-condition (enabled | disabled | either) [--include-future-pools (true | false)] [--description DESCRIPTION] [-i, --instance INSTANCE] [--output FORMAT]
其中:
-
- -name 是警报策略的名称。
-
- -description 是警报策略的描述。
- -- email 是用于分派警报通知的电子邮件地址。 例如,
--emails test1@cn.ibm.com,test2@cn.ibm.com
- -- webhook 是用于分派警报通知的 Webhook 标识。 例如,
--webhook webhookID1,webhookID2
- -- enabled 用于设置是否启用警报策略。
-
- -pools 是源池的 ID,如果设置为 all,则使用所有池的 ID。
-
- -触发条件是池切换状态的条件。
- --include-future-pools 设置是否包括将来的池。
- -i, --instance 是实例名称或 ID。 如果未设置,那么将使用
ibmcloud cis instance-set INSTANCE
指定的上下文实例。 - -- output 指定输出格式; 仅支持 JSON。
WAF 警报命令和 Advanced WAF 警报命令
创建有关防火墙事件峰值的警报策略。 防火墙事件警报在过去 6 小时和 5 分钟的事件存储区中使用 z-score 计算。 每当 z-score 高于 3.5 (阈值) 时,都会触发警报。 在同一两个小时的时间范围内,您将不会收到重复的警报。
ibmcloud cis alert-policy firewall-events-alert-create --name NAME (--emails EMAILS | --webhooks WEBHOOKS) --enabled (true | false) --domains DOMAINS [--services SERVICES] [--description DESCRIPTION] [-i, --instance INSTANCE] [--output FORMAT]
其中:
-
- -name 是警报策略的名称。
-
- -description 是警报策略的描述。
- -- email 是用于分派警报通知的电子邮件地址。 例如,
--emails test1@cn.ibm.com,test2@cn.ibm.com
- -- webhook 是用于分派警报通知的 Webhook 标识。 例如,
--webhook webhookID1,webhookID2
- -- enabled 用于设置是否启用警报策略。
- --domains 是警报策略的域标识。 例如,
--domains domainID1,domainID2
- -- services (高级 WAF) 指定警报监视器的服务。 有效值: "country-access-rules","waf","firewall-rules","ratelimit","securitylevel","ip-access-rules","browser-integrity-check","ua-rules",“lock悟”,"iprange-access-rules","asn-access-rules","Managed-firewall"。
- -i, --instance 是实例名称或 ID。 如果未设置,那么将使用
ibmcloud cis instance-set INSTANCE
指定的上下文实例。 - -- output 指定输出格式; 仅支持 JSON。
通用 SSL 警报命令
为证书事件创建警报策略。
ibmcloud cis alert-policy certificate-alert-create --type (universal | dedicated) --name NAME (--emails EMAILS | --webhooks WEBHOOKS) --enabled (true | false) [--description DESCRIPTION] [-i, --instance INSTANCE] [--output FORMAT]
其中:
-
- -type 是证书类型。
-
- -name 是警报策略的名称。
-
- -description 是警报策略的描述。
- -- email 是用于分派警报通知的电子邮件地址。 例如,
--emails test1@cn.ibm.com,test2@cn.ibm.com
- -- webhook 是用于分派警报通知的 Webhook 标识。 例如,
--webhook webhookID1,webhookID2
- -- enabled 用于设置是否启用警报策略。
- -i, --instance 是实例名称或 ID。 如果未设置,那么将使用
ibmcloud cis instance-set INSTANCE
指定的上下文实例。 - -- output 指定输出格式; 仅支持 JSON。
负载均衡运行状况检查警报命令
为全局负载均衡器、池和源的运行状况状态更改创建警报策略。
ibmcloud cis alert-policy glb-healthcheck-alert-create --name NAME (--emails EMAILS | --webhooks WEBHOOKS) --enabled (true | false) --pools POOLS [--include-future-pools (true | false)] [--health-status-trigger (healthy | unhealthy | either)] [--event-source-trigger (pool | origin | either)] [--description DESCRIPTION] [-i, --instance INSTANCE] [--output FORMAT]
其中:
-
- -name 是警报策略的名称。
-
- -description 是警报策略的描述。
- -- email 是用于分派警报通知的电子邮件地址。 例如,
--emails test1@cn.ibm.com,test2@cn.ibm.com
- -- webhook 是用于分派警报通知的 Webhook 标识。 例如,
--webhook webhookID1,webhookID2
。 - -- enabled 用于设置是否启用警报策略。
- -- pools 是源池的标识。 如果设置为
all
,那么将使用所有池标识。 - --include-future-pools 设置是否包括 future 池 (缺省值为 "false")。
- -- health-status-trigger 是触发通知的触发条件。 有效值:“运行状况”,“运行状况不佳”,“任一”(缺省值为 "任一")。
-
- -event-source-trigger(事件源触发器)是触发通知的事件源。 有效值: "pool","origin","either" (缺省值为 "either")。
- -i, --instance 是实例名称或 ID。 如果未设置,那么将使用
ibmcloud cis instance-set INSTANCE
指定的上下文实例。 - -- output 指定输出格式; 仅支持 JSON。
使用 API 创建电子邮件警报
要创建电子邮件警报,请执行以下步骤:
- 登录到 IBM Cloud 帐户。
- 获取令牌。
- 使用该令牌,运行下列其中一个命令:
DDoS 攻击层 7 命令
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Policy","enabled":true,"alert_type":"dos_attack_l7","mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks":[]}}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - description (可选) 是警报的描述。
池切换警报命令
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Policy","enabled":true,"alert_type":"load_balancing_pool_enablement_alert","mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks":[]},
“filters”: {
“enabled”: [
“false”,
“true”
],
“pool_id”: [
“6e67c08e3bae7eb398101d08def8a68a”,
“df2d9d70fcb194ea60d2e58397cb35a6”
]
}}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - description (可选) 是警报的描述。
- filter 是池切换警报的所有启用状态和池标识的列表。
WAF 警报命令
要配置 WAF 警报,请使用以下命令:
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'Content-Type: application/json' \
-H 'X-Auth-User-Token: Bearer xxxxxx' \
-d '{
"name": "WAF Alerter",
"description": "Send an email on spike in firewall events for any service",
"enabled": true,
"alert_type": "clickhouse_alert_fw_anomaly",
"mechanisms": {
"email": [
{
"id": "sreteam@techcompany.com"
}
]
},
"filters": {
"zones": [
"123456ab7d8e9f0g12h2j34l5mn6op78"
]
}
}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- description (可选) 是警报的描述。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - 过滤器 是 WAF 警报的所有区域的列表。
高级 WAF 警报命令
要配置高级 WAF 警报,请使用以下命令:
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'Content-Type: application/json' \
-H 'X-Auth-User-Token: Bearer xxxxxx' \
-d '{
"name": "WAF Alerter",
"description": "Send an email on spike in firewall events for WAF or browser integrity check",
"enabled": true,
"alert_type": "clickhouse_alert_fw_ent_anomaly",
"mechanisms": {
"email": [
{
"id": "sreteam@techcompany.com"
}
]
},
"filters": {
"services": [
"waf",
"bic"
],
"zones": [
"123456ab7d8e9f0g12h2j34l5mn6op78"
]
}
}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- description (可选) 是警报的描述。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - 过滤器 是要针对高级 WAF 警报监视安全性事件和区域的所有服务的列表。
您可以监控以下服务:
服务 | 日志值 |
---|---|
国家或地区 IP 访问规则 | country |
WAF | waf |
防火墙规则 | firewallrules |
速率限制 | ratelimit |
安全级别 | securitylevel |
IP 访问规则 | ip |
验证 | validation |
浏览器完整性检查 | bic |
热链接保护 | hot |
用户代理阻止 | uablock |
区域锁定 | zonelockdown |
IP 范围访问规则 | iprange |
ASN IP 访问规则 | asn |
定制防火墙 | firewallCustom |
受管防火墙 | firewallManaged |
数据丢失预防 | dlp |
通用 SSL 警报命令
要配置通用 SSL 警报,请使用以下命令:
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Policy","enabled":true,"alert_type":"universal_ssl_event_type","mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks":[]}}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - description (可选) 是警报的描述。
负载均衡运行状况检查警报命令
要配置负载均衡运行状况检查警报,请使用以下命令:
curl -X POST \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Policy","enabled":true,"alert_type":"load_balancing_health_alert","mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks":[]},
“filters”: {
“event_source”: [
“pool”,
“origin”
],
“new_health”: [
“Healthy”,
“Unhealthy”
],
“pool_id”: [
“6e67c08e3bae7eb398101d08def8a68a”,
“df2d9d70fcb194ea60d2e58397cb35a6”
]
}}'
其中:
- -d 是创建警报所需的属性数组。
- name 是警报的名称。
- enabled 是警报的状态 (
true
或false
之一)。 - alert_type 是警报类型 (
dos_attack_l7
,load_balancing_pool_enablement_alert
,clickhouse_alert_fw_anomaly
,clickhouse_alert_fw_ent_anomaly
,dedicated_ssl_certificate_event_type
,universal_ssl_event_type
或load_balancing_health_alert
之一)。 - 机制 至少是
email
,webhooks
中的一个。 - description (可选) 是警报的描述。
- filter 是负载均衡运行状况警报的所有源,池和运行状况状态的列表。
使用 API 创建 Webhook 警报
创建 Webhook 警报需要两个步骤。
-
发送以下请求以创建 Webhook:
curl -X POST \ https://api.cis.cloud.ibm.com/v1/:crn/alerting/destinations/webhooks \ -H 'content-type: application/json' \ -H 'x-auth-user-token: Bearer xxxxxx' \ -d '{"name":"Example Webhook","url":"https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"}'
返回的响应如下
{ "result": { "id": "6d16fcab3e8044b3b59ba3716237832e" }, "success": true, "errors": [], "messages": [] }
-
使用您接收到的响应中的标识来创建警报:
curl -X POST \ https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies \ -H 'content-type: application/json' \ -H 'x-auth-user-token: Bearer xxxxxx' \ -d '{"name":"Example Policy","enabled":true,"alert_type":"dos_attack_l7","mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks": [{"id": "6d16fcab3e8044b3b59ba3716237832e"}]}}'
使用 API 编辑警报
要编辑电子邮件警报,请运行以下命令:
curl -X PUT \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies/:policy_id \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Policy","enabled":true,"alert_type":"dos_attack_l7","conditions":{},"mechanisms":{"email":[{"id":"cistestemail@ibm.com"}],"webhooks":[]}}'
conditions 字段是必需的,即使它可能为空也是如此。
要编辑 Webhook,请使用以下 PUT
请求:
curl -X PUT \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/destinations/webhooks/:webhook_id \
-H 'content-type: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx' \
-d '{"name":"Example Webhook","url":"https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"}'
使用 API 删除警报
要删除电子邮件警报,请运行以下命令:
curl -X DELETE \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/policies/:policy_id \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx'
要删除 Webhook,请使用以下 DELETE
请求:
curl -X DELETE \
https://api.cis.cloud.ibm.com/v1/:crn/alerting/destinations/webhooks/:webhook_id \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-H 'x-auth-user-token: Bearer xxxxxx'