Updated on 2024-04-12 GMT+08:00

Querying Historical SQL Statements

Function

Query historical SQL statements.

URI

GET /v2/{project_id}/lts/history-sql

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.

Minimum length: 1 character.

Maximum length: 64 characters.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

log_group_id

Yes

String

Log group ID.

log_stream_id

Yes

String

Log stream ID.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum length: 1 character.

Maximum length: 10,000 characters.

Content-Type

No

String

Set this parameter to application/json;charset=UTF-8.

Minimum length: 30 characters.

Maximum length: 30 characters.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

results

Array of QuertHistorySQLResultsBody objects

Return the result.

Table 5 QuertHistorySQLResultsBody

Parameter

Type

Description

last_use_time

Long

Last modification time. The value is a timestamp, in milliseconds.

sql_statement

String

Historical SQL statements.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

message

ErrorMessagebody object

Error message body.

Table 7 ErrorMessagebody

Parameter

Type

Description

code

String

Error code. Minimum length: 8 characters. Maximum length: 36 characters.

details

String

Error description. Minimum length: 2 characters. Maximum length: 512 characters.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

message

ErrorMessagebody object

Error message body.

Table 9 ErrorMessagebody

Parameter

Type

Description

code

String

Error code. Minimum length: 8 characters. Maximum length: 36 characters.

details

String

Error description. Minimum length: 2 characters. Maximum length: 512 characters.

Example Requests

/v2/2a473356cca5487f8373be891bffc1cf/lts/history-sql?log_group_id=d1f4240d-5ee2-4e0b-9e2c-e25c7978c001&log_stream_id=f3d853be-0576-4dff-aee9-c093e4924b63

Example Responses

Status code: 200

Query SQL statements succeeded.

{
  "results" : [ {
    "last_use_time" : 1669689650936,
    "sql_statement" : "SELECT *"
  }, {
    "last_use_time" : 1666775421613,
    "sql_statement" : "select count(\"t\") as pv"
  }, {
    "last_use_time" : 1666661494805,
    "sql_statement" : "SELECT count(\"time\")"
  }, {
    "last_use_time" : 1666598233252,
    "sql_statement" : "SELECT count(\"t\") as pv"
  }, {
    "last_use_time" : 1666598226763,
    "sql_statement" : "SELECT count(\"t\") "
  }, {
    "last_use_time" : 1666598222298,
    "sql_statement" : "SELECT count(\"t\") as pv"
  }, {
    "last_use_time" : 1666598221585,
    "sql_statement" : "SELECT count(\"t\") as p"
  }, {
    "last_use_time" : 1666598220276,
    "sql_statement" : "SELECT count(\"t\") as "
  }, {
    "last_use_time" : 1666598212453,
    "sql_statement" : "SELECT count(\"t\")"
  } ]
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "message" : {
    "code" : "LTS.0603",
    "details" : "group or stream not exist"
  }
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "message" : {
    "code" : "LTS.0203",
    "details" : "Internal Server Error"
  }
}

Status Codes

Status Code

Description

200

Query SQL statements succeeded.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.