Queries a specified number of logs from a Logstore.
Request syntax
aliyunlog log get_log --project=<value> --logstore=<value> --from_time=<value> --to_time=<value> [--topic=<value>] [--query=<value>] [--reverse=<value>] [--offset=<value>] [--size=<value>] [--power_sql=<value>] [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>] [--profile=<value>]
Request parameters
The following table lists the command-specific parameters.
|
Parameter name |
Data type |
Required |
Example value |
Description |
|
--project |
String |
Yes |
aliyun-test-project |
The project name. |
|
--logstore |
String |
Yes |
logstore-a |
The Logstore name. |
|
--from_time |
String |
Yes |
2021-05-28 15:33:00+8:00 |
Start of the query time range. Specify as a UNIX timestamp or in the |
|
--to_time |
String |
Yes |
2021-05-28 15:40:00+8:00 |
End of the query time range. Specify as a UNIX timestamp or in the |
|
--topic |
String |
No |
"" |
The log topic. Defaults to an empty string (""). Topic. |
|
--query |
String |
No |
|
The query or analytic statement. Query and analysis overview. Adding Note
If the query parameter contains an analytic statement, set size and offset to 0 and use the LIMIT clause for pagination. Paginate query and analysis results. |
|
--reverse |
Boolean |
No |
true |
Whether to return logs in descending order of timestamp (accurate to the minute).
Important
|
|
--offset |
Integer |
No |
0 |
The row to start the query from. Valid only for query statements. Default: 0. |
|
--size |
Integer |
No |
10 |
Maximum number of logs to return. Valid only for query statements. Value range: 0 to 100. Default: 100. |
|
--power_sql |
Boolean |
No |
false |
Whether to use Dedicated SQL. High-performance and fully accurate query and analysis (Dedicated SQL).
You can enable Dedicated SQL by setting this parameter to true or by adding the directive in the query parameter. |
This command also supports Global parameters.
Examples
-
Request example
Query the top 20 POST request statuses using the default account.
aliyunlog log get_log --project="aliyun-test-project" --logstore="logstore-a" --from_time="2021-05-28 15:33:00+8:00" --to_time="2021-05-28 15:40:00+8:00" --query="request_method:POST | select status,COUNT(*) as pv group by status order by pv desc limit 20" --format-output=json -
Response example
{ "data": [ { "__source__": "", "__time__": "1719382500", "pv": "17", "status": "200" }, { "__source__": "", "__time__": "1719382500", "pv": "3", "status": "500" } ], "meta": { "aggQuery": "select status,COUNT(*) as pv group by status order by pv desc limit 20", "columnTypes": [ "long", "long" ], "count": 2, "cpuSec": 0.025, "elapsedMillisecond": 0, "hasSQL": true, "insertedSQL": "1,29, from \"gs-api\" ", "isAccurate": true, "keys": [ "status", "pv" ], "processedBytes": 226, "processedRows": 20, "progress": "Complete", "telementryType": "logging", "telemetryType": "logging", "terms": [ { "key": "", "term": "*" } ], "whereQuery": "*" } }
Related commands
|
Command |
Scenario |
|
Performs a term query on logs using a JSON configuration file. |
|
|
Queries a large volume of log data. |