Queries logs in a project by executing an SQL statement.


  • You can use the query parameter to specify a standard SQL statement.
  • You must specify a project in the domain name of the request.
  • You must specify a Logstore in the FROM clause of the SQL statement. A Logstore can be used as an SQL table.
  • You must specify a time range in the SQL statement by using the __date__ parameter or __time__ parameter. The value of the __date__ parameter is a timestamp, and the value of the __time__ parameter is an integer. The unit of the __time__ parameter is seconds.
  • The value of the Host parameter consists of a project name and a Log Service endpoint. You must specify a project in the Host parameter when you call this API operation.

Request headers

The GetProjectLogs operation does not have operation-specific request headers and uses only common request headers. For more information, see Common request headers.

Request syntax

GET /logs HTTP/1.1

Request parameters

Parameter Type Position Required Example Description
query String Host Yes SELECT COUNT(*) as pv FROM nginx-moni where __time__ > 1646102500 and __time__ < 1646103400

The standard SQL statement. In this example, the SQL statement queries the number of page views (PVs) from 2022-03-01 10:41:40 to 2022-03-01 10:56:40 in a Logstore whose name is nginx-moni.

Response parameters

Parameter Type Example Description
x-log-progress String Complete

The status of the query result. Valid values:

  • Complete: The query is successful, and a complete query result is returned.
  • Incomplete: The query is successful, but the query result is incomplete. To obtain the complete query result, you must repeat the request.
x-log-count Long 10000

The total number of logs that are returned in the query result.

x-log-processed-rows Long 10000

The number of rows that are processed in the query.

x-log-elapsed-millisecond Long 5

The time that is consumed by the query. Unit: milliseconds.

__time__ Long 1409529660

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

__source__ String

The log source that is specified when logs are written.

content Array of Object null

The raw content of the log.


Sample requests

GET /logs HTTP/1.1

Common request parameters

Sample success responses

JSON format

HTTP/1.1 200 OK

Error codes

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







Parameter is invalid.

The error message returned because a specified parameter is invalid.

For more information, see Common error codes.