日志服务 Log Service - API Reference
使用HMAC-SHA1签名算法,基于AccessKeyId和AccessKeySecret进行身份验证。
SignString = Method + "\n" +
ContentMd5 + "\n" +
ContentType + "\n" +
Date + "\n" +
CanonicalizedHeaders + "\n" +
CanonicalizedResource
Signature = Base64(HMAC-SHA1(SignString, AccessKeySecret))
Authorization = "LOG " + AccessKeyId + ":" + Signature
curl --location 'https://cn-hangzhou.log.aliyuncs.com/' \
--header 'Date: Fri, 31 Oct 2025 08:00:00 GMT' \
--header 'Authorization: LOG {AccessKeyId}:{Signature}' \
--header 'x-log-apiversion: 0.6.0' \
--header 'x-log-signaturemethod: hmac-sha1' \
--header 'x-log-bodyrawsize: 0' \
--header 'Content-Length: 0'
{
"count": 2,
"total": 2,
"projects": [
{
"projectName": "feishu-message",
"status": "Normal",
"owner": "1584650070640631",
"description": "飞书聊天消息",
"region": "cn-hangzhou",
"createTime": "1760338014",
"dataRedundancyType": "LRS"
}
]
}
curl --location 'https://feishu-message.cn-hangzhou.log.aliyuncs.com/logstores' \
--header 'Date: Fri, 31 Oct 2025 08:00:00 GMT' \
--header 'Authorization: LOG {AccessKeyId}:{Signature}' \
--header 'x-log-apiversion: 0.6.0' \
--header 'x-log-signaturemethod: hmac-sha1' \
--header 'x-log-bodyrawsize: 0' \
--header 'Content-Length: 0'
{
"count": 5,
"total": 5,
"logstores": [
"feishu-message-data",
"feishu-message-user",
"feishu-message-groupname",
"test"
]
}
curl --location 'https://feishu-message.cn-hangzhou.log.aliyuncs.com/logstores/feishu-message-data?type=log&from=1761897600&to=1761901200&query=*&reverse=true&line=50&offset=0' \
--header 'Date: Fri, 31 Oct 2025 08:00:00 GMT' \
--header 'Authorization: LOG {AccessKeyId}:{Signature}' \
--header 'x-log-apiversion: 0.6.0' \
--header 'x-log-signaturemethod: hmac-sha1' \
--header 'x-log-bodyrawsize: 0' \
--header 'Content-Length: 0'
| 参数 | 类型 | 说明 |
|---|---|---|
| type | string | 固定值:log |
| from | int | 开始时间(Unix时间戳,秒) |
| to | int | 结束时间(Unix时间戳,秒) |
| query | string | 查询语句(* 表示所有日志) |
| reverse | boolean | 是否降序(true=降序,false=升序) |
| line | int | 返回的日志条数 |
| offset | int | 偏移量(用于分页) |
curl --location 'https://feishu-message.cn-hangzhou.log.aliyuncs.com/logstores/test/index' \
--header 'Date: Fri, 31 Oct 2025 08:00:00 GMT' \
--header 'Authorization: LOG {AccessKeyId}:{Signature}' \
--header 'Content-Type: application/json' \
--header 'Content-MD5: {MD5_HASH}' \
--header 'x-log-apiversion: 0.6.0' \
--header 'x-log-signaturemethod: hmac-sha1' \
--header 'x-log-bodyrawsize: {BODY_LENGTH}' \
--data '{
"line": {
"token": [",", " ", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"],
"caseSensitive": false
},
"ttl": 30
}'
| 参数 | 类型 | 说明 |
|---|---|---|
| line.token | array | 分词符列表 |
| line.caseSensitive | boolean | 是否大小写敏感 |
| ttl | int | 索引数据保留天数 |
A: 系统已自动处理签名计算,包括HMAC-SHA1加密、自定义Header排序、查询参数排序等。
A: 对于POST请求,Content-MD5是请求体的MD5哈希值的大写十六进制字符串。
A: LogStore未配置索引。系统会自动提示创建,点击"创建索引"按钮即可一键配置。
A: Unix时间戳(秒级),如:1761897600 表示 2025-10-31 00:00:00
| 区域 | Endpoint |
|---|---|
| 华东1(杭州) | cn-hangzhou.log.aliyuncs.com |
| 华东2(上海) | cn-shanghai.log.aliyuncs.com |
| 华北2(北京) | cn-beijing.log.aliyuncs.com |
| 华南1(深圳) | cn-shenzhen.log.aliyuncs.com |
| 华南1(广州) | cn-guangzhou.log.aliyuncs.com |
| 中国香港 | cn-hongkong.log.aliyuncs.com |
| 新加坡 | ap-southeast-1.log.aliyuncs.com |
| 美国西部1(硅谷) | us-west-1.log.aliyuncs.com |