Queries entries in slow query logs of an ApsaraDB for MongoDB instance.

  • This operation is applicable only to general-purpose local-disk or dedicated local-disk instances.
  • You can call this operation up to 30 times per minute. To call this operation at a higher frequency, use a Logstore. For more information, see Manage a Logstore.

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 DescribeSlowLogRecords

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

RegionId String No cn-hangzhou

The region ID of the instance.

Note You can call the DescribeDBInstanceAttribute operation to query the region ID of the instance.
DBInstanceId String Yes dds-bp1fc7e65108****

The ID of the instance.

Note If you specify this parameter to the ID of a sharded cluster instance, you must also specify the NodeId parameter.
NodeId String No d-bp18b06ebc21****

The ID of the shard node.

Note This parameter is required only when you specify the DBInstanceId parameter to the ID of a sharded cluster instance.
StartTime String Yes 2021-08-15T14:13Z

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

EndTime String Yes 2021-08-16T14:13Z

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

Note
  • The end time must be later than the start time.
  • The end time must be within 24 hours from the start time. Otherwise, the query fails.
DBName String No mongodbtest

The name of the database.

PageSize Integer No 30

The number of entries to return on each page. Valid values: 30 to 100.

PageNumber Integer No 1

The number of the page to return. The value must be an integer that is greater than 0. Default value: 1.

OrderType String No asc

The order of time in which the log entries to return are sorted. Valid values:

  • asc: The log entries are sorted by time in ascending order.
  • desc: The log entries are sorted by time in descending order.
ResourceGroupId String No rg-acfmyiu4ekp****

The ID of the resource group.

Response parameters

Parameter Type Example Description
TotalRecordCount Integer 1

The total number of entries.

PageRecordCount Integer 1

The number of slow query log entries returned on the page.

RequestId String 8076C4BA-DDBD-529C-BFF4-D8620C3F****

The ID of the request.

PageNumber Integer 1

The page number of the returned page. The value must be an integer that is greater than 0. Default value: 1.

Items Array of LogRecords

Details about the slow query logs.

LogRecords
ExecutionStartTime String 2019-02-25T 01:41:28Z

The start time of the operation. The time is in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

HostAddress String 192.168.XX.XX

The host IP address that is used to connect to the database.

QueryTimes String 600

The execution time of the statement. Unit: milliseconds.

TableName String C1

The name of the collection.

SQLText String {\"op\":\"query\",\"ns\":\"mongodbtest.customer\",\"query\":{\"find\":\"customer\",\"filter\":{\"name\":\"jack\"}}}

The SQL statement that is executed during the slow operation.

ReturnRowCounts Long 0

The number of entries returned.

KeysExamined Long 0

The data entries that are scanned during indexing.

DBName String mongodbtest

The name of the database.

DocsExamined Long 1000000

The number of documents that are scanned during the operation.

AccountName String root

The username of the database account that performs the operation.

Engine String MongoDB

The database engine.

Examples

Sample requests

http(s)://mongodb.aliyuncs.com/?Action=DescribeSlowLogRecords
&DBInstanceId=dds-bp1366caac83****
&StartTime=2021-08-15T14:13Z
&EndTime=2021-08-16T14:13Z
&<Common request parameters>

Sample success responses

XML format

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

<DescribeSlowLogRecordsResponse>
    <TotalRecordCount>1</TotalRecordCount>
    <PageRecordCount>1</PageRecordCount>
    <RequestId>8076C4BA-DDBD-529C-BFF4-D8620C3F****</RequestId>
    <PageNumber>1</PageNumber>
    <Items>
        <LogRecords>
            <TableName>$cmd</TableName>
            <QueryTimes>944</QueryTimes>
            <ExecutionStartTime>2021-08-15T21:08:36Z</ExecutionStartTime>
            <DBName>admin</DBName>
            <HostAddress>11.61.195.204</HostAddress>
            <SQLText>{"op":"command","ns":"admin.$cmd","command":{"isMaster":1,"client":{"driver":{"name":"mgo","version":"vinllen"},"os":{"type":"linux","architecture":"amd64"}},"$readPreference":{"mode":"secondaryPreferred"},"$db":"admin"},"numYield":0,"locks":{},"flowControl":{},"responseLength":748,"protocol":"op_query","millis":944,"replRole":{"stateStr":"SECONDARY","_id":1}}</SQLText>
        </LogRecords>
    </Items>
    <Engine>MongoDB</Engine>
</DescribeSlowLogRecordsResponse>

JSON format

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

{
  "TotalRecordCount" : 1,
  "PageRecordCount" : 1,
  "RequestId" : "8076C4BA-DDBD-529C-BFF4-D8620C3F****",
  "PageNumber" : 1,
  "Items" : {
    "LogRecords" : [ {
      "TableName" : "$cmd",
      "QueryTimes" : 944,
      "ExecutionStartTime" : "2021-08-15T21:08:36Z",
      "DBName" : "admin",
      "HostAddress" : "11.61.195.204",
      "SQLText" : "{\"op\":\"command\",\"ns\":\"admin.$cmd\",\"command\":{\"isMaster\":1,\"client\":{\"driver\":{\"name\":\"mgo\",\"version\":\"vinllen\"},\"os\":{\"type\":\"linux\",\"architecture\":\"amd64\"}},\"$readPreference\":{\"mode\":\"secondaryPreferred\"},\"$db\":\"admin\"},\"numYield\":0,\"locks\":{},\"flowControl\":{},\"responseLength\":748,\"protocol\":\"op_query\",\"millis\":944,\"replRole\":{\"stateStr\":\"SECONDARY\",\"_id\":1}}"
    } ]
  },
  "Engine" : "MongoDB"
}

Error codes

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