Queries a cursor based on a specific time.

Description

You can use a cursor to locate a specific log. The following figure shows the relationships among a cursor, project, Logstore, and shard.Cursor
  • Each project can have multiple Logstores.
  • Each Logstore can have multiple shards.
  • You can use a cursor to locate a specific log.

Request syntax

GET /logstores/ay42/shards/2? type=cursor&from=1402341900 HTTP/1.1
Authorization: <AuthorizationString>
Date: <GMT Date>
Host: <Project Endpoint>
x-log-apiversion: 0.6.0

Request parameters

  • Request headers

    The GetCursor operation does not have operation-specific request headers. For information about the common request headers of Log Service API operations, see Common request headers.

  • Parameters
    Parameter Type Required Example Description
    shard string Yes 0 The name of the shard.
    type string Yes cursor This parameter must be set to cursor.
    from string Yes begin The time that is used to query a cursor. Set the value to a UNIX timestamp or a string such as begin and end.
    You can use the from parameter to locate the logs within the lifecycle of a Logstore. If the lifecycle of a Logstore is [begin_time, end_time) and the from parameter is set to from_time, the following responses are returned:
    • If from_time is earlier than or equal to begin_time, or from_time is equal to "begin", a cursor is returned. The cursor corresponds to the log whose timestamp is begin_time.
    • If from_time is later than or equal to end_time, or from_time is equal to "end", a cursor is returned. The cursor corresponds to the next log to be written at the current time (No data exists at the current cursor position).
    • If from_time is later than begin_time, and from_time is earlier than end_time, a cursor is returned. The cursor corresponds to the first packet that Log Service receives later than or at from_time.
    Note The lifecycle of a Logstore is specified by the ttl parameter. For example, the server time is November 11, 2018, 09:00:00 and the ttl parameter is set to 5. The data that was received in the interval [2018-11-05 09:00:00,2018-11-11 09:00:00) is consumable.

Response parameters

  • Response headers

    The GetCursor operation does not have operation-specific response headers. For information about the common response headers of Log Service API operations, see Common response headers.

  • Response elements
    If the GetCursor request succeeds, the response body contains the information of the cursor. The following example shows a cursor:
    {
        "cursor": "MTQ0NzI5OTYwNjg5NjYzMjM1Ng=="
    }

Examples

  • Sample requests
    GET /logstores/sls-test-logstore/shards/0? type=cursor&from=begin
    Header:
    {
        "Content-Length": 0, 
        "x-log-signaturemethod": "hmac-sha1", 
        "x-log-bodyrawsize": 0, 
        "User-Agent": "log-python-sdk-v-0.6.0", 
        "Host": "ali-test-project.cn-hangzhou-devcommon-intranet.sls.aliyuncs.com", 
        "Date": "Thu, 12 Nov 2015 03:56:57 GMT", 
        "x-log-apiversion": "0.6.0", 
        "Content-Type": "application/json", 
        "Authorization": "LOG <yourAccessKeyId>:<yourSignature>"
    }
  • Sample success responses
    Header:
    {
        "content-length": "41", 
        "server": "nginx/1.6.1", 
        "connection": "close", 
        "date": "Thu, 12 Nov 2015 03:56:57 GMT", 
        "content-type": "application/json", 
        "x-log-requestid": "56440E0999248C070600C6AA"
    }
    Body:
    {
        "cursor": "MTQ0NzI5OTYwNjg5NjYzMjM1Ng=="
    }

Error codes

HTTP status code Error code Error message Description
404 LogStoreNotExist Logstore {Name} does not exist. The error message returned because the specified Logstore does not exist.
400 ParameterInvalid Parameter From is not valid. The error message returned because a parameter value is invalid.
400 ShardNotExist Shard {ShardID} does not exist. The error message returned because the specified shard does not exist.
500 InternalServerError Specified Server Error Message. The error message returned because an internal server error has occurred.
400 LogStoreWithoutShard the logstore has no shard. The error message returned because no shards exist in the Logstore.

For more information about the error codes, see Common error codes.