Queries the logs of a Logstore in a project.
Operation description
Usage notes
-
Host consists of a project name and a Simple Log Service endpoint. You must specify a project in Host.
-
If the number of logs in a Logstore significantly changes, Simple Log Service cannot forecast the number of times that you must call this operation to obtain the complete result. In this case, you must check the value of the x-log-progress parameter in the response of each request and determine whether to call this operation one more time to obtain the complete result. Each time you call this operation, the same number of charge units (CUs) are consumed.
-
After a log is written to a Logstore, you can call the GetHistograms or GetLogs operation to query the log after a short latency. The latency of a query varies based on the type of the log. Simple Log Service classifies logs into the following types based on the log time:
Real-time data: The difference between the time record in a log and the current time on Simple Log Service is within the interval (-180 seconds,900 seconds]. For example, if a log was generated at 12:03:00, September 25, 2014 (UTC) and Simple Log Service received the log at 12:05:00, September 25, 2014 (UTC), Simple Log Service processes the log as real-time data. This type of log is usually generated in common scenarios.
- Historical data: The difference between the time record in a log and the current time on Simple Log Service is within the interval [-604,800 seconds,-180 seconds). For example, if a log was generated at 12:00:00, September 25, 2014 (UTC) and Simple Log Service received the log at 12:05:00, September 25, 2014 (UTC), Simple Log Service processes the log as historical data. This type of log is usually generated in data backfill scenarios.
After real-time data is written to a Logstore, the data can be queried with a maximum latency of 3 seconds. For 99.9% of queries, the latency is no more than 1 second.
- Simple Log Service provides examples on how to call the GetLogs operation by using Simple Log Service SDK for Java and Simple Log Service SDK for Python. For more information, see Examples of calling the GetLogs operation by using Simple Log Service SDK for Java and Examples of calling the GetLogs operation by using Simple Log Service SDK for Python.
Debugging
Authorization information
Request syntax
GET /logstores/{logstore}?type=log
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
project | string | Yes | The name of the project. | ali-test-project |
logstore | string | Yes | The Logstore whose logs you want to query. | example-logstore |
from | integer | Yes | The beginning of the time range to query. The value is the log time that is specified when log data is written.
Note
To ensure that full data can be queried, specify a query time range that is accurate to the minute. If you also specify a time range in an analytic statement, Simple Log Service uses the time range specified in the analytic statement for query and analysis.
If you want to specify a time range that is accurate to the second in your analytic statement, you must use the from_unixtime or to_unixtime function to convert the time format. For more information about the functions, see from_unixtime function and to_unixtime function. Examples:
| 1627268185 |
to | integer | Yes | The end of the time range to query. The value is the log time that is specified when log data is written.
Note
To ensure that full data can be queried, specify a query time range that is accurate to the minute. If you also specify a time range in an analytic statement, Simple Log Service uses the time range specified in the analytic statement for query and analysis.
If you want to specify a time range that is accurate to the second in your analytic statement, you must use the from_unixtime or to_unixtime function to convert the time format. For more information about the functions, see from_unixtime function and to_unixtime function. Examples:
| 1627269085 |
query | string | No | The search statement or the query statement. For more information, see Log search overview and Log analysis overview. If you add Note
If you specify an analytic statement in the value of the query parameter, the line and offset parameters do not take effect. In this case, we recommend that you set the line and offset parameters to 0 and use the LIMIT clause to limit the number of logs to return on each page. For more information, see Paged query.
| status: 401 | SELECT remote_addr,COUNT(*) as pv GROUP by remote_addr ORDER by pv desc limit 5 |
topic | string | No | The topic of the logs. The default value is double quotation marks (""). For more information, see Topic . | topic |
line | long | No | The maximum number of logs to return for the request. This parameter takes effect only when the query parameter is set to a search statement. Minimum value: 0. Maximum value: 100. Default value: 100. | 100 |
offset | long | No | The line from which the query starts. This parameter takes effect only when the query parameter is set to a search statement. Default value: 0. | 0 |
reverse | boolean | No | Specifies whether to return logs in reverse chronological order of log timestamps. The log timestamps are accurate to the minute. Valid values:
Note
| false |
powerSql | boolean | No | Specifies whether to enable the Dedicated SQL feature. For more information, see Enable Dedicated SQL. Valid values:
You can use the powerSql or query parameter to configure Dedicated SQL. | false |
Response parameters
Examples
Sample success responses
JSON
format
[
{
"test": "test",
"test2": 1
}
]
Error codes
For a list of error codes, visit the Service error codes.