調用PullLogs介面擷取指定遊標(Cursor)位置的日誌資料。此介面擷取的是原始日誌,如要查詢或分析日誌,請使用GetLogsV2介面。
介面說明
擷取日誌時必須指定 Shard。
目前僅支援讀取Protocol Buffer格式資料。
請求文法中 Host 由 Project 名稱和Log Service Endpoint 構成,您需要在 Host 中指定 Project。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
請求文法
GET /logstores/{logStore}/shards/{shardId}?type=log HTTP/1.1
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| project |
string |
是 |
Project 名稱。 |
ali-test-project |
| logStore |
string |
是 |
Logstore 名稱。 |
ali-test-logstore |
| shardId |
integer |
是 |
日誌庫的分區 id。 |
1 |
| cursor |
string |
是 |
遊標,表示從什麼位置開始讀取資料,相當於起點。 |
MTQ0NzMyOTQwMTEwMjEzMDkwNA |
| count |
integer |
是 |
返回的 Loggroup 數目,最小值為 1,最大值為 1000。 |
1000 |
| end_cursor |
string |
否 |
結束遊標,表示讀取資料到什麼地方結束,相當於終點。 |
MTU1NzA1NzQwMTEwMjEzMDkwCg |
| query |
string |
否 |
過濾語句,spl 文法,請參見 SPL 指令 |
* | where userId='123' |
| Accept-Encoding |
string |
否 |
期望服務端返回的資料壓縮格式,支援 lz4 |
lz4 |
PullLogs 介面的特有要求標頭如下所示:
Accept:application/x-protobuf
Accept-Encoding:lz4
其中,Accept-Encoding 取值包括 lz4、deflate 或雙引號("")之一。
請求樣本:
GET /logstores/sls-test-logstore/shards/0?type=logs&cursor=MTQ0NzMyOTQwMTEwMjEzMDkwNA&count=1000 HTTP/1.1
Host:ali-test-project.cn-hangzhou.log.aliyuncs.com
Content-Type:application/json
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
| headers |
object |
||
| Content-Length |
string |
0 |
|
| Date |
string |
Sun, 27 May 2018 08:25:04 GMT |
|
| x-log-requestid |
string |
5B0A6B60BB6EE39764D458B5 |
|
| x-log-count |
string |
||
| x-log-cursor |
string |
||
| x-log-cursor-time |
string |
||
| x-log-end-of-cursor |
string |
||
| Content-Type |
string |
application/json |
|
| x-log-compresstype |
string |
||
| x-log-bodyrawsize |
string |
||
|
LogGroupList |
壓縮後的 pb 資料 |
PullLogs 介面的特有響應元素如下所示:
x-log-cursor:當前讀取資料下一條 Cursor。
x-log-end-of-cursor:當前讀取資料最後一條 Cursor。
x-log-count:當前返回數量。
關於 Log Service API 的公用回應標頭,請參見公用回應標頭。
響應元素為 protobuf 格式序列化後的資料(可能經過壓縮)。
樣本
正常返回樣本
JSON格式
{
"logGroupList": [
{
"Topic": "topic-test",
"Source": "192.1.1.1",
"LogTags": [
{
"Key": "key-test",
"Value": "value-test"
}
],
"LogItems": [
{
"Time": 1690254376,
"Contents": [
{
"Key": "key-test",
"Value": "value-test"
}
]
}
]
}
]
}
錯誤碼
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。