CDN Pro
创建日志配置,用于定义访问日志的输出格式。同一个日志配置可适用于一个或多个域名。每个域名必须有指定的日志配置,才能获取到该域名的日志。
单用户调用频率:300/5min
Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试
参数名称 | 描述 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
descriptionString | 日志配置描述。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*hostnamesList | 适用该日志配置的域名列表。每个域名必须是完整的FQDN域名如domain.com,或者是带星号的泛域名如*.domain.com。如果该日志配置适用于所有域名,则直接用星号*表示。每个域名有且只能有一个对应的日志配置。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logDownloadFormatString | 默认值: %cltip %rmtuser [%utctime] '%method %url %protocol' %statuscode %rspsize '%referer' '%ua' %rsptime
日志格式。可使用以下变量来自定义日志输出格式:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logDownloadStorageDaysInteger | 默认值: 14 取值范围: [ 1 .. 30 ]
日志保存天数。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logDownloadFileSpanMinutesInteger | 取值范围: 5,15,30,60,120,240,480,1440
默认值: 30
每几分钟生成日志文件。为避免单个日志文件过大,当日志条目增长过快时,同一个时间段内的日志可能被分割为多个文件。当日志入库发生显著延迟时,延迟入库的部分会被写入单独的日志文件。 |
参数名称 | 描述 |
---|---|
LocationString | 通过Location响应头返回新建的日志配置的URL。URL中包含日志配置的ID,可使用该ID调用'查询日志配置详情'接口来查看日志配置的详细信息。URL示例: Location: http://open.chinanetcenter.com/cdn/report/logConfigs/4427 |
错误代码(code) | 描述(message) | HTTP状态码 | 语义 |
---|---|---|---|
InvalidHostname | Duplicated hostname "testdomain.domain.info". | 400 | 存在重复的域名。 |
InvalidStorageDays | The log download storage days must be 1 - 30. | 400 | 日志存储天数必须在1-30的范围。 |
InvalidFormat | Invalid variable name: %referer12. It supports: referer, rmtuser, scheme, cltport, ua, cltregion, statuscode, reqsize, protocol, hostname, custom1, cachestate, custom2, reqhdrsize, svrip, uniqueid, samplerate, querystr, cltisp, method, utctime, tcprtt, cpu_ns, url, rspsize, svrnode, cltip, rsptime, reqrange. | 400 | 指定的变量中存在无效的变量。 |
AccessDenied | You are not allowed to perform this action. | 403 | 无操作权限。 |
#!/bin/bash username="example_username" apiKey="example_apiKey" date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"` password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64` curl -i --url "https://open.chinanetcenter.com/cdn/report/logConfigs" \ -X "POST" \ -u "$username:$password" \ -H "Date: $date" \ -H "Accept: application/json" \ -d '{"description": "Our log configuration", "hostnames": ["domain.com"], "logDownloadFormat": "%cltip %rmtuser [%utctime] "%method %url %protocol" %statuscode %rspsize "%referer" "%ua" %rsptime", "logDownloadStorageDays": 14, "logDownloadFileSpanMinutes": 30}'
{ "code": "InvalidHostname", "message": "Duplicated hostname \"testdomain.domain.info\"." }