设置用量封顶
更新时间:2023-10-12
设置用量封顶
接口描述
本接口用于设置用量封顶配置,可针对带宽、流量、QPS、PV之一设置。用量封顶功能本质上是一个触发器,例如当用户带宽达到指定值时自动触发stop域名或者访问404,触发后默认不自动恢复,可设置自动恢复时间,或手动关闭恢复。
注意事项
当用量封顶配置action触发后,如果没有设置自动恢复,需要用户手动恢复。如:threshold设置为1Gbps,action为stop,则当带宽达到1Gbps时域名被stop,需要用户主动去start该域名,否则域名将一直处于stop状态。设置action deny 同理。建议用户谨慎看待该配置
请求接口
Method | Path | 说明 |
---|---|---|
PUT | /v2/domain/{domain}/config?limitConsumption | 设置用量封顶配置 |
请求头域
除公共头域外,无其它特殊头域。
请求参数(Request Body)
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
limitConsumption | 必选 | limitConsumption | 用量封顶配置 |
limitConsumption类型说明
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
enabled | 必选 | bool | 开启/关闭用量封顶配置,enabled=true开启。如果已经触发限制,可设置 |
type | 必选 | string | 检测类型,enable为true时必选,取值flow、bandwidth、pv、qps |
threshold | 必选 | string | 检测阈值,enable为true时必选,type不同时,阈值不同。type=flow,可填1GB、1TB、1PB,单位只能为GB或TB或PB。type=bandwidth,可填1Mbps、1Gbps、1Tbps,单位只能为Mbps或Gbps或Tbps。type=pv或qps,填数字即可,无需单位 |
statisticalCycle | 必选 | int | 检测周期,单位s,enable为true时必选。取值300、3600、86400。当type=bandwidth或qps时,只能填300。例如type=flow,statisticalCycle=3600时,检测范围为最近一小时流量,延迟10min |
action | 必选 | string | 达到阈值时触发的动作,当enabled为true时必选,取值deny、stop,"stop"表示stop加速域名,"deny"表示拒绝所有请求,访问会404 |
recoverAfterSeconds | 必选 | int | 触发阈值,执行action后自动恢复的时间,单位s,enable为true时必选。取值-1、3600、86400、259200,-1表示不自动恢复,其他取值恢复时间存在一定延迟,最多延迟10min |
notification | 可选 | list,元素类型为string | 触发阈值后的通知方式,最多可填写三种方式。取值sms(短信)、mail(邮件)、internal_message(站内信) |
响应头域
除公共头域外,无其它特殊头域。
响应参数
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
status | 必选 | string | 当前域名状态,设置配置后通常为OPERATING |
请求示例
Plain Text
1PUT /v2/domain/myself.baidu.com/config?limitConsumption HTTP/1.1
2Host: cdn.baidubce.com
3Content-Length: 17
4Content-Type: application/json
5
6示例1:
7{
8 "type": "bandwidth",
9 "statisticalCycle": 300,
10 "recoverAfterSeconds": 3600,
11 "threshold": "10Gbps",
12 "enabled": true,
13 "action": "deny",
14 "notification": ["sms", "mail", "internal_message"]
15}
16示例2:
17{
18 "type": "pv",
19 "statisticalCycle": 3600,
20 "recoverAfterSeconds": 3600,
21 "threshold": "100000",
22 "enabled": true,
23 "action": "stop",
24 "notification": ["sms", "mail", "internal_message"]
25}
响应示例
Plain Text
1HTTP/1.1 200 OK
2Server: nginx/1.1.10
3Date: Wed, 21 Jul 2021 08:32:34 GMT
4Content-Type: application/json; charset=utf-8
5Transfer-Encoding: chunked
6Connection: keep-alive
7X-Powered-By: PHP/7.2.28
8x-bce-request-id: d58bb985-e61b-8d1-eaee-4422bff9e93e
9
10{
11 "status":"OPERATING"
12}