Queries the distribution of logs that meet the specified search conditions in a specified Logstore. The response includes the number of logs that are generated within a specified time range.

Description

  • Host consists of a project name and a Log Service endpoint. You must specify a project in Host.
  • The time range is evenly divided into subintervals in the responses. If the time range that is specified in the request remains unchanged, the subintervals in the responses also remain unchanged.
  • If the number of logs in a Logstore significantly changes, Log Service cannot predict 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 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. 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 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 Log Service received the log at 12:05:00, September 25, 2014 (UTC), Log Service processes the log as real-time data. After real-time data is written to a Logstore, the data can be queried with a maximum latency of 3 seconds.
    • Historical data: The difference between the time record in a log and the current time on 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 Log Service received the log at 12:05:00, September 25, 2014 (UTC), 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.

Note Log Service calculates the difference between the log time that is specified by the __time__ field and the receiving time that is specified by the __tag__:__receive_time__ field for each log. The receiving time indicates the time at which Log Service receives the log. If the difference is within the interval (-180 seconds,900 seconds], Log Service processes the log as real-time data. If the difference is within the interval [-604,800 seconds,-180 seconds), Log Service processes the log as historical data.

Log Service provides examples on how to call the GetHistograms operation by using Log Service SDK for Java. For more information, see Use GetHistograms to query the distribution of logs.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

This operation uses only common request headers. For more information, see Common request parameters.

Request syntax

GET /logstores/{logstore}/index?type=histogram HTTP/1.1

Request parameters

ParameterTypePositionRequiredExampleDescription
projectStringHostYesali-test-project

The name of the project.

logstoreStringPathYestest-logstore

The name of the Logstore.

fromLongQueryYes1409529600

The start time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

toLongQueryYes1409569200

The end time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

topicStringQueryNotopic

The topic of the logs.

queryStringQueryNowith_pack_meta

The search statement. Only search statements are supported. Analytic statements are not supported. For more information about the syntax of search statements, see Log search overview.

Response parameters

ParameterTypeExampleDescription
ServerStringnginx

The name of the server.

Content-TypeStringapplication/json

The type of the HTTP response body.

Content-LengthString0

The length of the HTTP response body.

ConnectionStringclose

Indicates whether the connection is persistent. Valid values:

  • close: The connection is non-persistent. A new TCP connection is established for each HTTP request.
  • keep-alive: The connection is persistent. After a TCP connection is established, the connection remains open, and no more time or bandwidth is consumed to establish new connections.
DateStringSun, 27 May 2018 08:25:04 GMT

The time.

x-log-requestidString5B0A6B60BB6EE39764D458B5

The ID of the request.

Array
fromLong1409529600

The start time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

The time range that is specified in this operation is a left-closed, right-open interval. The interval includes the start time specified by the from parameter, but does not include the end time specified by the to parameter. If you specify the same value for the from and to parameters, the interval is invalid, and an error message is returned.

toLong1409569200

The end time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

The time range that is specified in this operation is a left-closed, right-open interval. The interval includes the start time specified by the from parameter, but does not include the end time specified by the to parameter. If you specify the same value for the from and to parameters, the interval is invalid, and an error message is returned.

countLong2

The number of logs that are generated within the subinterval.

progressStringComplete

Specifies whether the query result in the subinterval is complete. Valid values:

Complete: The query is successful, and the complete result is returned.

Incomplete: The query is successful, but the query result is incomplete. To obtain the complete result, you must repeat the request.

Examples

Sample requests

GET /logstores/logstoreName HTTP/1.1
Host:big-game.cn-hangzhou.log.aliyuncs.com
Content-Type:application/json

Common request parameters

Sample success responses

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "from" : 1409529600,
  "to" : 1409569200,
  "count" : 2,
  "progress" : "Complete"
}

Error codes

For a list of error codes, visit the API Error Center.

HTTP status code

Error code

Error message

Description

404

ProjectNotExist

Project does not exist.

The error message returned because the specified project does not exist.

404

LogStoreNotExist

Logstore does not exist.

The error message returned because the specified Logstore does not exist.

400

InvalidTimeRange

request time range is invalid.

The error message returned because the specified time range is invalid.

400

InvalidQueryString

query string is invalid.

The error message returned because the specified query statement in the request is invalid.

500

InternalServerError

Specified Server Error Message.

The error message returned because an internal server error has occurred.

For more information, see Common error codes.