All Products
Search
Document Center

Simple Log Service:GetHistograms

Last Updated:Jul 08, 2026

Queries the distribution of logs that meet the specified query conditions in a Logstore by calling the GetHistograms operation.

Operation description

Operation description

  • The Host in the request syntax consists of the project name and the Simple Log Service endpoint. Specify the project in the Host.

  • The subinterval division in the response is always stable. If the time range in your query request remains unchanged, the subinterval division in the response also remains unchanged.

  • When the number of logs involved in a query changes significantly, the Simple Log Service API cannot predict how many times this operation needs to be invoked to obtain complete results. Check the progress status value in the response of each request to determine whether to invoke this operation again to obtain the final complete results. Each repeated invocation consumes the same number of query CUs.

  • The latency between writing a log to a Logstore and querying the log by using LogSearch operations (GetHistograms and GetLogs) varies depending on the 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 writing real-time data to querying the data in the LogSearch interface is 3 seconds.

    • Historical data: The time point in the log is within the range of [-7x86400 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 writing real-time data to querying the data is 3 seconds. In 99.9% of cases, the query is completed within 1 second.

Note

Simple Log Service calculates the difference between the log time (field name: __time__) and the server receive 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 [-7x86400 seconds, -180 seconds), the log is historical data.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

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

Path Parameters

Parameter

Type

Required

Description

Example

logstore

string

Yes

The Logstore name.

test-logstore

Request parameters

Parameter

Type

Required

Description

Example

project

string

Yes

The project name.

ali-test-project

from

integer

Yes

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

1409529600

to

integer

Yes

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

1409569200

topic

string

No

The topic of the logs.

topic

query

string

No

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

with_pack_meta

Response elements

Element

Type

Description

Example

array

object

from

integer

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

The time interval follows the left-closed, right-open principle. The interval 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 January 1, 1970, 00:00:00 UTC.

The time interval follows the left-closed, right-open principle. The interval 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 logs queried in the subinterval.

2

progress

string

Indicates whether the query results in the subinterval are complete.

Complete: The query is complete and the returned results are complete.

Incomplete: The query is complete but the returned results are incomplete. Repeat the request to obtain complete results.

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.