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.
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
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
Parameter | Type | Position | Required | Example | Description |
---|---|---|---|---|---|
project | String | Host | Yes | ali-test-project | The name of the project. |
logstore | String | Path | Yes | test-logstore | The name of the Logstore. |
from | Long | Query | Yes | 1409529600 | 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. |
to | Long | Query | Yes | 1409569200 | 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. |
topic | String | Query | No | topic | The topic of the logs. |
query | String | Query | No | with_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
Parameter | Type | Example | Description |
---|---|---|---|
Server | String | nginx | The name of the server. |
Content-Type | String | application/json | The type of the HTTP response body. |
Content-Length | String | 0 | The length of the HTTP response body. |
Connection | String | close | Indicates whether the connection is persistent. Valid values:
|
Date | String | Sun, 27 May 2018 08:25:04 GMT | The time. |
x-log-requestid | String | 5B0A6B60BB6EE39764D458B5 | The ID of the request. |
Array | |||
from | Long | 1409529600 | 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. |
to | Long | 1409569200 | 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. |
count | Long | 2 | The number of logs that are generated within the subinterval. |
progress | String | Complete | 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.