Queries the distribution of logs that meet the query syntax conditions in a specified Logstore.
Operation description
Operation description
The Host in the request syntax consists of the project name and the Simple Log Service endpoint. You must specify the project in the Host.
An AccessKey pair is created and obtained. For more information, see AccessKey pair.
The AccessKey pair of an Alibaba Cloud account has access permissions to all API operations, which poses high security risks. Create and use a Resource Access Management (RAM) user to invoke API operations or perform routine O&M. The RAM user must have permissions to manage Simple Log Service resources (EPS resource), such as Operation logs. For more information, see Create a RAM user and authorization.
The name of the project, the region, and the name of the Logstore to which the logs belong are identified. For more information, see Manage a project and Manage a Logstore.
Indexes are configured before you query logs. For more information, see Create indexes.
The query parameter supports only query statements and does not support analytic statements. For more information about the detailed syntax and limits of query statements, see Query overview.
The subinterval division method in the response of this operation is always stable. If the time range of the query request remains unchanged, the subinterval division result in the response also remains unchanged.
When the number of logs involved in the query is extremely large, the Simple Log Service API cannot predict how many times this operation must be invoked to obtain the complete results. Therefore, check the progress status value in the returned result of each request to determine whether to repeatedly invoke this operation to obtain the final complete results. Each repeated invocation of this operation consumes the same number of query CUs.
- The latency from when a log is written to a Logstore to when the log is queried by using the GetHistograms or GetLogs operation varies based on the written log type. Simple Log Service classifies logs into the following two types based on log UNIX timestamps:
Real-time data: The time point in the log is within the range of (-180 seconds, 900 seconds] relative to the current server time. For example, if the log time is UTC 2014-09-25 12:03:00 and the server receives the log at UTC 2014-09-25 12:05:00, the log is processed as real-time data. The latency from when real-time data is written to when it can be queried in the LogSearch interface is 3 seconds.
Historical data: The time point in the log is within the range of [-7 × 86400 seconds, -180 seconds) relative to the current server time. For example, if the log time is UTC 2014-09-25 12:00:00 and the server receives the log at UTC 2014-09-25 12:05:00, the log is processed as historical data. This typically occurs in data backfill scenarios. The maximum latency from when real-time data is written to when it can be queried is 3 seconds. In 99.9% of cases, the query is completed within 1 second.
Simple Log Service calculates the difference between the log time (field name: __time__) and the server receipt time (field name: __tag__:__receive_time__). If the difference is within the range of (-180 seconds, 900 seconds], the log is real-time data. If the difference is within the range of [-7 × 86400 seconds, -180 seconds), the log is historical data.
Simple Log Service provides an example of using GetHistograms in the Java SDK. For more information, see Use GetHistograms to query log distribution.
Try it now
Test
RAM authorization
Request syntax
GET /logstores/{logstore}/index?type=histogram HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| logstore |
string |
Yes |
The name of the Logstore. |
test-logstore |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| project |
string |
Yes |
The name of the project. |
ali-test-project |
| from |
integer |
Yes |
The start time of the subinterval. The time is a UNIX timestamp representing the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. |
1409529600 |
| to |
integer |
Yes |
The end time of the subinterval. The time is a UNIX timestamp representing the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. |
1409569200 |
| topic |
string |
No |
The topic of the log. |
topic |
| query |
string |
No |
The query statement. Only query statements are supported. Analytic statements are not supported. For more information about the detailed syntax and limits of query statements, see Query overview. |
with_pack_meta |
Response elements
|
Element |
Type |
Description |
Example |
|
array |
The list of request parameters. |
||
|
object |
The request parameters. |
||
| from |
integer |
The start time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. The time interval is left-inclusive and right-exclusive, meaning it includes the start time but excludes the end time. If the values of from and to are the same, the interval is invalid and the function returns an error. |
1409529600 |
| to |
integer |
The end time of the subinterval. The value is a UNIX timestamp representing the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. The time interval is left-inclusive and right-exclusive, meaning it includes the start time but excludes the end time. If the values of from and to are the same, the interval is invalid and the function returns an error. |
1409569200 |
| count |
integer |
The number of queried log entries in the subinterval. |
2 |
| progress |
string |
Indicates whether the query result in the subinterval is complete. Valid values:
|
Complete |
Examples
Success response
JSON format
[
{
"from": 1409529600,
"to": 1409569200,
"count": 2,
"progress": "Complete"
}
]
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.