PullLogs

Last Updated: Nov 29, 2017

Obtains logs based on the cursor and quantity. You must specify a shard when the system obtains logs. In the Storm scenario, elective and collaborative consumption can be performed through LoghubClientLib. Currently, only [log group lists in PB format] can be read.

Request syntax

  1. GET /logstores/ay42/shards/0?type=logs&cursor=MTQ0NzMyOTQwMTEwMjEzMDkwNA==&count=100 HTTP/1.1
  2. Accept: application/x-protobuf
  3. Accept-Encoding: lz4
  4. Authorization: <AuthorizationString>
  5. Date: <GMT Date>
  6. Host: <Project Endpoint>
  7. x-log-apiversion: 0.6.0
  8. x-log-signaturemethod: hmac-sha1

Request parameters

URL parameters:

Parameter Name Type Required or Not Description
type string Yes Logs
cursor string Yes A start point for data reading
count int Yes The number of returned log groups, ranging from 0 to 1000

Request header

  • Accept: application/x-protobuf
  • Accept-Encoding: LZ4, deflate, or “”

For details about the public request header of the API, refer to Public Request Header.

Response header

  • x-log-cursor: The next cursor of the currently read data
  • x-log-count: The number of returned logs

For details about the public response header of the API, refer to Public Response Header.

Response element

Data from serialized logs in PB format (which may be compressed).

Detailed description

N/A

Specific error codes

In addition to general error codes of the API, the following special error codes may be returned:

HTTP Status Code Error Code Error Message
404 LogStoreNotExist Logstore {Name} not exist
400 ParameterInvalid Parameter Cursor is not valid
400 ParameterInvalid ParameterCount must be in [0-1000]
400 ShardNotExist Shard {ShardID} not exist
400 InvalidCursor this cursor is invalid
500 InternalServerError Specified Server Error Message

Example

Request example:
  1. Read data on the shard numbered 0.
  2. GET /logstores/sls-test-logstore/shards/0?cursor=MTQ0NzMyOTQwMTEwMjEzMDkwNA==&count=1000&type=log
  3. Header:
  4. {
  5. "Authorization"="LOG 94to3z418yupi6ikawqqd370:WeMYZp6bH/SmWEgryMrLhbxK+7o=",
  6. "x-log-bodyrawsize"=0,
  7. "User-Agent" : "sls-java-sdk-v-0.6.0",
  8. "x-log-apiversion" : "0.6.0",
  9. "Host" : "ali-test-project.cn-hangzhou-failover-intranet.sls.aliyuncs.com",
  10. "x-log-signaturemethod" : "hmac-sha1",
  11. "Accept-Encoding" : "lz4",
  12. "Content-Length": 0,
  13. "Date" : "Thu, 12 Nov 2015 12:03:17 GMT",
  14. "Content-Type" : "application/x-protobuf",
  15. "accept" : "application/x-protobuf"
  16. }
Response example:
  1. Header:
  2. {
  3. "x-log-count" : "1000",
  4. "x-log-requestid" : "56447FB20351626D7C000874",
  5. "Server" : "nginx/1.6.1",
  6. "x-log-bodyrawsize" : "34121",
  7. "Connection" : "close",
  8. "Content-Length" : "4231",
  9. "x-log-cursor" : "MTQ0NzMyOTQwMTEwMjEzMDkwNA==",
  10. "Date" : "Thu, 12 Nov 2015 12:01:54 GMT",
  11. "x-log-compresstype" : "lz4",
  12. "Content-Type" : "application/x-protobuf"
  13. }
  14. Body:
  15. Data from the compressed <log group list in PB format>

Page flip

To flip the page (to get the next token) without returning data, the system can send HTTP HEAD requests.

Thank you! We've received your feedback.