GetCursor
Retrieves the cursor corresponding to a specified time.
Operation description
Operation description
-
The host consists of the project name and the Simple Log Service endpoint. You must specify the project in the host.
-
You can use a cursor to obtain the position of a specific log. The relationships among the cursor, project, Logstore, and shard are as follows:
A project contains multiple Logstores.
Each Logstore contains multiple shards.
You can use a cursor to obtain the position of a specific log.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
log:GetCursorOrData |
get |
*LogStore
|
|
None |
Request syntax
GET /logstores/{logstore}/shards/{shardId}?type=cursor HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| logstore |
string |
Yes |
The name of the Logstore. |
sls-test-logstore |
| shardId |
integer |
Yes |
The shard ID. |
1 |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| project |
string |
Yes |
The name of the project. |
ali-test-project |
| from |
string |
Yes |
The time point (UNIX timestamp) or the string |
begin |
You can use the from parameter to locate logs within the lifecycle in a shard. If the lifecycle of the Logstore is [begin_time,end_time) and from=from_time, the following rules apply:
If
from_time ≤ begin_timeorfrom_time = "begin", the cursor position corresponding tobegin_timeis returned.If
from_time ≥ end_timeorfrom_time = "end", the cursor position of the next log to be written at the current time is returned. No data exists at this cursor position.If
from_time > begin_timeandfrom_time < end_time, the cursor corresponding to the first data packet whose server-side receiving time is greater than or equal tofrom_timeis returned.
The lifecycle of a Logstore is specified by the TTL field in the attributes. For example, if the current time is 2018-11-11 09:00:00 and TTL is 5, the data timestamp period of consumable data in each shard is [2018-11-05 09:00:00,2018-11-11 09:00:00). The time here refers to the server-side time. For more information, see Data retention period.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The cursor value. |
||
| cursor |
string |
The cursor value. |
MTQ0NzI5OTYwNjg5NjYzMjM1Ng== |
Examples
Success response
JSON format
{
"cursor": "MTQ0NzI5OTYwNjg5NjYzMjM1Ng=="
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.