Queries log entries based on the specified cursors.

Description

  • You must specify the shard from which you want to query log entries.
  • You can query only log entries in the Protocol Buffers (protobuf) format. For more information, see Data encoding.

Request syntax

GET /logstores/logstoreName/shards/shardID HTTP/1.1
Accept: application/x-protobuf
Accept-Encoding: lz4
Authorization: LOG yourAccessKeyId:yourSignature
Date: GMT Date
Host: Projectname.Endpoint
x-log-apiversion: 0.6.0
x-log-signaturemethod: hmac-sha1

The value of the Host parameter consists of a project name and a Log Service endpoint. You must specify a project in the Host parameter.

Request parameters

  • Request headers

    The request must contain the following headers:

    • Accept: application/x-protobuf
    • Accept-Encoding: lz4
    The valid values of the Accept-Encoding header are lz4, deflate, and a pair of double quotation marks ("").

    For information about the common request headers of Log Service API operations, see Common request headers.

  • Request parameters
    Parameter Type Required Example Description
    projectName String Yes ali-test-project The name of the project.
    logstoreName String Yes sls-test-logstore The name of the Logstore.
    shardID Integer Yes 0 The ID of the shard.
    type String Yes logs The type of the resource that you want to request. Set the value to logs.
    cursor String Yes MTQ0NzMyOTQwMTEwMjEzMDkwNA The start cursor from which the system starts to read log entries.
    end_cursor String No MTU1NzA1NzQwMTEwMjEzMDkwCg The end cursor at which the system stops reading log queries.
    count Integer No 1000 The number of log groups that you want the system to return. Valid values: 1 to 1000.

Response parameters

  • Response headers
    The response must contain the following headers:
    • x-log-cursor: the cursor of the log entry that follows the position at which the system stops reading log entries
    • x-log-count: the number of log entries that are returned
    For information about the common response headers that are supported by the Log Service API, see Common response headers.
  • Response parameters

    Serialized data in the protobuf format is returned. The data may be compressed.

Examples

  • Sample requests
    GET /logstores/sls-test-logstore/shards/0?cursor=MTQ0NzMyOTQwMTEwMjEzMDkwNA&end_cursor=MTU1NzA1NzQwMTEwMjEzMDkwCg&count=1000&type=log  
    Header:
    {
        "Authorization"="LOG yourAccessKeyId:yourSignature", 
        "x-log-bodyrawsize"=0, 
        "User-Agent" : "sls-java-sdk-v-0.6.0", 
        "x-log-apiversion" : "0.6.0", 
        "Host" : "ali-test-project.cn-hangzhou-failover-intranet.sls.aliyuncs.com", 
        "x-log-signaturemethod" : "hmac-sha1", 
        "Accept-Encoding" : "lz4", 
        "Content-Length": 0,
        "Date" : "Thu, 12 Nov 2015 12:03:17 GMT",
        "Content-Type" : "application/x-protobuf", 
        "accept" : "application/x-protobuf"
    }
  • Sample success responses
    Header:
    {
        "x-log-count" : "1000", 
        "x-log-requestid" : "56447FB20351626D7C000874", 
        "Server" : "nginx/1.6.1", 
        "x-log-bodyrawsize" : "34121", 
        "Connection" : "close", 
        "Content-Length" : "4231", 
        "x-log-cursor" : "MTQ0NzMyOTQwMTEwMjEzMDkwNA", 
        "x-log-end_cursor" : "MTU1NzA1NzQwMTEwMjEzMDkwCg",
        "Date" : "Thu, 12 Nov 2015 12:01:54 GMT", 
        "x-log-compresstype" : "lz4", 
        "Content-Type" : "application/x-protobuf"
    }
    Body:
    <The log group list in the protobuf format> after compression.
  • Page flip

    To flip the page and obtain the next token without returning data, you can send an HTTP HEAD request.

Error codes

HTTP status code Error code Error message Description
404 LogStoreNotExist Logstore logstoreName does not exist. The error message returned because the Logstore that you specified cannot be found.
400 ParameterInvalid Invalid cursor cursor. The error message returned because the value of the cursor parameter is invalid.
400 ParameterInvalid ParameterCount should be in [0-1000]. The error message returned because the value of the count parameter is invalid. The valid values of the count parameter are within the range of 0 to 1000.
400 ShardNotExist Shard ShardID does not exist. The error message returned because the shard that you specified cannot be found.
500 InternalServerError Specified Server Error Message. The error message returned because an internal error occurred.

For a list of error codes, see Common error codes.