Queries the distribution of logs that meet the request syntax conditions in a specified Logstore.

Request syntax

aliyunlog log get_histograms --request=<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_histograms command.
Parameter Type Required Example Description
--request JSON Object Yes file://./gethistograms.json The path of the configuration file that is used to query logs.
For information about the global parameters of the Log Service command-line interface (CLI), see Global variables.

Examples

  1. Create a file named gethistograms.json. The following example shows the content of the gethistograms.json file:
    {
    "topic": "",
    "logstore": "logstore-a",
    "project": "aliyun-test-project",
    "toTime": "2021-05-28 15:33:00",
    "query": "level:Information",
    "fromTime": "2021-05-28 15:18:00"
    }
    Parameters:
    Parameter Description
    topic The topic of the logs.
    logstore The name of the Logstore.
    project The name of the project.
    toTime The end time of the time range that is specified in the request. The end time is a UNIX timestamp. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
    query The query statement. Only search statements are supported. Analytic statements are not supported. For more information, see Search syntax.
    fromTime The start time of the time range that is specified in the request. The start time is a UNIX timestamp. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  2. Use the default account to query the distribution of the logs whose severity level is Information during a specified relative time range. Run the following command:
    aliyunlog log get_histograms --request="file://./gethistograms.json"
    The following output is returned:
    [
      {
        "count": 0,
        "from": 1622186280,
        "progress": "Complete",
        "to": 1622186310
      },
      {
        "count": 7,
        "from": 1622186580,
        "progress": "Complete",
        "to": 1622186610
      },
      {
        "count": 3,
        "from": 1622186610,
        "progress": "Complete",
        "to": 1622186640
      },
      {
        "count": 0,
        "from": 1622186640,
        "progress": "Complete",
        "to": 1622186670
      },
      {
        "count": 0,
        "from": 1622186670,
        "progress": "Complete",
        "to": 1622186700
      },
      {
        "count": 1,
        "from": 1622186760,
        "progress": "Complete",
        "to": 1622186790
      },
      {
        "count": 0,
        "from": 1622186790,
        "progress": "Complete",
        "to": 1622186820
      }
    ]

Error codes

If an error message is returned, fix the error based on the error codes of the related API operation. For more information, see Error codes of GetHistograms.

API reference

GetHistograms