Queries SQL logs within a specific time range.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSQLLogs

The operation that you want to perform. Set the value to DescribeSQLLogs.

DBInstanceId String Yes gp-xxxxxxxx

The ID of the instance.

Note You can call the DescribeDBInstances operation to query details of all AnalyticDB for PostgreSQL instances in a specific region, including instance IDs.
QueryKeywords String No select 1

The keywords of the SQL statement.

StartTime String Yes 2021-03-10T06:30Z

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Database String No adbpgadmin

The name of the database.

User String No testadmin

The database user.

EndTime String Yes 2021-03-17T06:30Z

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Note The end time must be later than the start time. Their interval cannot be more than seven days.
PageSize Integer No 1

The number of the page to return.

PageNumber Integer No 10

The number of entries to return on each page.

ExecuteCost String No 1

The execution duration of the query. Unit: seconds.

SourceIP String No 100.**.**.90

The source IP address.

ExecuteState String No success

The execution state of the query. Valid values:

  • success
  • fail
OperationClass String No DQL

The type of the query language. Valid values:

  • DQL
  • DML
  • DDL
  • DCL
  • TCL
OperationType String No SELECT

The type of the SQL statement.

Note
  • If the OperationClass parameter is specified, the OperationType value must belong to the corresponding query language. For example, if the OperationClass value is DQL, the OperationType value must be a DQL SQL statement such as SELECT.
  • If the OperationClass parameter is not specified, the OperationType value can be an SQL statement of all query languages.
  • If neither of the OperationClass and OperationType parameters is specified, all types of SQL statements are returned.
MaxExecuteCost String No 1000

The maximum amount of time consumed by a slow query. Minimum value: 0. Unit: seconds.

MinExecuteCost String No 1

The minimum amount of time consumed by a slow query. Minimum value: 0. Unit: seconds.

Response parameters

Parameter Type Example Description
PageRecordCount Integer 1

The number of entries returned per page.

RequestId String A7941C94-B92F-46A0-BD3E-2D**********

The ID of the request.

PageNumber Integer 1

The page number of the returned page.

Items Array of Item

Details of the SQL logs.

OperationClass String DQL

The type of the query language.

ExecuteState String success

The execution state of the query.

  • success
  • fail
ExecuteCost Float 2

The execution duration of the query.

SQLText String select 1

The SQL statement.

SourcePort Integer 50514

The number of the source port.

DBRole String master

The role of the database.

OperationType String SELECT

The type of the SQL statement.

SourceIP String 100.**.**.90

The source IP address.

SQLPlan String ""

The SQL execution plan.

ReturnRowCounts Long 1

The number of entries returned.

DBName String adbpgadmin

The name of the database.

OperationExecuteTime String 2021-03-15T17:02:32Z

The time when the SQL statement was executed.

ScanRowCounts Long 1

The number of entries scanned.

AccountName String testadmin

The database user that executes the SQL statement.

Examples

Sample requests

http(s)://gpdb.aliyuncs.com/?Action=DescribeSQLLogs
&DBInstanceId=gp-xxxxxxxx
&EndTime=2021-03-17T06:30Z
&StartTime=2021-03-10T06:30Z
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeSQLLogsResponse>
    <PageRecordCount>1</PageRecordCount>
    <RequestId>A7941C94-B92F-46A0-BD3E-2D**********</RequestId>
    <PageNumber>1</PageNumber>
    <Items>
        <OperationClass>DQL</OperationClass>
        <ExecuteState>success</ExecuteState>
        <ExecuteCost>2</ExecuteCost>
        <SQLText>select 1</SQLText>
        <SourcePort>50514</SourcePort>
        <DBRole>master</DBRole>
        <OperationType>SELECT</OperationType>
        <SourceIP>100.**.**.90</SourceIP>
        <SQLPlan>""</SQLPlan>
        <ReturnRowCounts>1</ReturnRowCounts>
        <DBName>adbpgadmin</DBName>
        <OperationExecuteTime>2021-03-15T17:02:32Z</OperationExecuteTime>
        <ScanRowCounts>1</ScanRowCounts>
        <AccountName>testadmin</AccountName>
    </Items>
</DescribeSQLLogsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "PageRecordCount" : 1,
  "RequestId" : "A7941C94-B92F-46A0-BD3E-2D**********",
  "PageNumber" : 1,
  "Items" : [ {
    "OperationClass" : "DQL",
    "ExecuteState" : "success",
    "ExecuteCost" : 2,
    "SQLText" : "select 1",
    "SourcePort" : 50514,
    "DBRole" : "master",
    "OperationType" : "SELECT",
    "SourceIP" : "100.**.**.90",
    "SQLPlan" : "\"\"",
    "ReturnRowCounts" : 1,
    "DBName" : "adbpgadmin",
    "OperationExecuteTime" : "2021-03-15T17:02:32Z",
    "ScanRowCounts" : 1,
    "AccountName" : "testadmin"
  } ]
}

Error codes

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