Queries logs. This command is applicable to scenarios where you need to query a large amount of log data.

Request syntax

aliyunlog log get_log_all --project=<value> --logstore=<value> --from_time=<value> --to_time=<value> [--topic=<value>] [--query=<value>] [--reverse=<value>] [--offset=<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>]

Request parameters

The following table describes the required and specific parameters of the get_log_all command.
Parameter Type Required Example Description
--project String Yes aliyun-test-project The name of the project.
--logstore String Yes logstore-a The name of the Logstore.
--from_time String Yes 2021-05-28 15:33:00+8:00 The start time of the time range that is specified in the request. The start time can be a UNIX timestamp. The start time can also be a value in the "%Y-%m-%d %H:%M:%S<time_zone>" format, for example, “2018-01-02 12:12:10+8:00”.
--to_time String Yes 2021-05-28 15:40:00+8:00 The end time of the time range that is specified in the request. The end time can be a UNIX timestamp. The end time can also be a value in the "%Y-%m-%d %H:%M:%S<time_zone>" format, for example, “2018-01-02 12:12:10+8:00”.
--topic String No None The topic of the logs. For more information, see Topic.
--query String No level:Information|select event_id as Key1,COUNT(*) as Key2 group by Key1 The query statement. For more information, see Log search and Log analysis.
Note If you specify an analytic SQL statement in the query parameter, you must set the line and offset parameters to 0 and use the LIMIT clause to limit the number of entries to return on each page. For more information, see Display analysis results on multiple pages.
--reverse Boolean No true Specifies whether to return logs in reverse order by log timestamp. Unit: minutes.
  • true: Logs are returned in reverse order. The latest log is returned first.
  • false: Logs are returned in regular order. This is the default value.
--offset Integer No None The start position of entries to return. Default value: 0.
For information about the global parameters of the Log Service command-line interface (CLI), see Global variables.

Examples

  • Sample requests
    Use the default account to query the events whose level is Information and calculate the number of the matched events. Run the following command:
    aliyunlog log get_log_all --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="level:Information|select event_id as Key1,COUNT(*) as Key2 group by Key1" --reverse=true
  • Sample responses
    [
      {
        "Key1": "16394",
        "Key2": "1",
        "__source__": "",
        "__time__": "1622186400"
      },
      {
        "Key1": "44",
        "Key2": "1",
        "__source__": "",
        "__time__": "1622186400"
      },
      {
        "Key1": "7036",
        "Key2": "7",
        "__source__": "",
        "__time__": "1622186400"
      },
      {
        "Key1": "16384",
        "Key2": "1",
        "__source__": "",
        "__time__": "1622186400"
      },
      {
        "Key1": "43",
        "Key2": "1",
        "__source__": "",
        "__time__": "1622186400"
      },
      {
        "Key1": "19",
        "Key2": "1",
        "__source__": "",
        "__time__": "1622186400"
      }
    ]