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

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 again 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 in a log and the current time on the server is within the interval (-180 seconds,900 seconds]. For example, if a log was generated at 12:03:00 UTC, September 25, 2014 and the server received the log at 12:05:00 UTC, September 25, 2014, 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 in a log and the current time on the server is within the interval [-604,800 seconds,-180 seconds). For example, if a log was generated at 12:00:00 UTC, September 25, 2014 and the server received the log at 12:05:00 UTC, September 25, 2014, Log Service processes the log as historical data. Logs of this type are 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. The latency of 99.9% of queries is within 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. The receiving time indicates when the server 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.

Request headers

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

Request syntax

GET /logstores/{logstore}/index HTTP/1.1

Request parameters

Parameter Type Location Required Example Description
projectName String Host Yes big-game

The name of the project.

logstoreName String Host Yes app_log

The name of the Logstore.

type String Host Yes histogram

The type of the data in the Logstore. Set the value to histogram.

from Long Host Yes 1409529600

The beginning of the time range to query. Specify a timestamp that follows the UNIX time format. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.

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.

to Long Host Yes 1409608800

The end of the time range to query. Specify a timestamp that follows the UNIX time format. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.

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.

topic String Host No groupA

The topic of the logs.

query String Host No error

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

Response parameters

Parameter Type Example Description
Server String nginx

The name of the server.

Content-Type String application/json

The type of the content.

Content-Length String 0

The length of the content.

Connection String close

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.
Content-MD5 String *

The MD5 hash value of the HTTP response body that is defined in RFC 2616. The value is an uppercase string that is calculated by using the MD5 algorithm.

Date String Sun, 27 May 2018 08:25:04 GMT

The time.

x-log-requestid String 5B0A6B60BB6EE39764D458B5

The ID of the request.

from Long 1409529600

The start time of the subinterval. The value is a timestamp that follows the UNIX time format. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.

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.

to Long 1409569200

The end time of the subinterval. The value is a timestamp that follows the UNIX time format. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.

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.

count Long 2

The number of logs that are generated during the subinterval.

progress String Complete

Indicates 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 in the request 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.