Queries the details of operation logs generated within a specified period.

Prerequisites: You are an administrator of Data Management (DMS) or a database administrator (DBA). You can call the ListUsers or GetUser operation to obtain your user role from the RoleIdList parameter that is returned.

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 GetOpLog

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

Tid Long Yes 3***

The ID of the tenant. You can call the GetUserActiveTenant or ListUserTenants operation to obtain the tenant ID.

Module String No SECURITY_RULE

The functional module for which you want to query operation logs. If you do not specify this parameter, operation logs for all functional modules are returned. Valid values:

  • PERMISSION: permissions
  • OWNER: data owner
  • SQL_CONSOLE: data query
  • SQL_CONSOLE_EXPORT: query result export
  • DATA_CHANGE: data change
  • DATA_EXPORT: data export
  • SQL_REVIEW: SQL review
  • DT_SYNC: database and table synchronization
  • DT_DETAIL: database and table details
  • DB_TASK: task management
  • INSTANCE_MANAGE: instance management
  • USER_MANAGE: user management
  • SECURITY_RULE: security rule
  • CONFIG_MANAGE: configuration management
  • RESOURCE_AUTH: resource authorization
  • ACCESS_WHITE_IP: access IP whitelist
StartTime String Yes 2022-03-23 10:00:00

The beginning of the time range to query. Specify the time in the yyyy-MM-DD HH:mm:ss format.

EndTime String Yes 2022-03-29 10:00:00

The end of the time range to query. Specify the time in the yyyy-MM-DD HH:mm:ss format.

PageSize Integer Yes 30

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

  • 30
  • 50
  • 100
PageNumber Integer Yes 1

The number of the page to return. Pages start from page 1.

RegionId String No cn-hangzhou

The ID of the region in which DMS is activated. For more information about the valid values of this parameter, see RegionID parameter.

Note Set this parameter to the ID of the region that is in proximity to your applications.

Response parameters

Parameter Type Example Description
TotalCount Long 1

The total number of operation logs that are returned.

RequestId String 47D56208-DB1D-4FD3-BE32-300E43185488

The ID of the request.

ErrorCode String 403

The error code that is returned.

OpLogDetails Array of OpLogDetail

The details of the operation log.

OpLogDetail
Module String Security rule

The functional module for which the operation log is queried.

Database String dmstest_prod_database@dmstest.rds...[Test instance]

The endpoint of the database instance.

Note
  • This parameter is valid only for database instances of the LocalInstance type.
  • This parameter is valid only for operations on the functional modules related to tasks.
UserId String 22275482072787****

The ID of the Alibaba Cloud account.

OpUserId Long 51****

The ID of the user who performed the operation.

OpContent String SELECT * FROM `orders` \n LIMIT 20

The details of the operation.

UserNick String test_name

The display name of the user.

OrderId Long 509****

The ID of the ticket or task.

Note This parameter is valid only for operations on the functional modules related to tasks and the task management module in system management.
OpTime String 2022-03-28 16:45:19

The time when the operation was performed.

ErrorMessage String UnknownError

The error message that is returned.

Success Boolean true

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.

Examples

Sample request

http(s)://dms-enterprise.aliyuncs.com/?Action=GetOpLog
&Tid=3***
&Module=SECURITY_RULE
&StartTime=2022-03-23 10:00:00
&EndTime=2022-03-29 10:00:00
&PageSize=30
&PageNumber=1
&<Common request parameters>

Sample success responses

XML format

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

<GetOpLogResponse>
    <TotalCount>1</TotalCount>
    <RequestId>47D56208-DB1D-4FD3-BE32-300E43185488</RequestId>
    <OpLogDetails>
        <OpUserId>51****</OpUserId>
        <UserId>22275482072787****</UserId>
        <Database>dmstest_prod_database@dmstest.rds...[Test instance]</Database>
        <OpContent>SELECT * FROM `orders` \n LIMIT 20</OpContent>
        <UserNick>test_name</UserNick>
        <Module>Security rule</Module>
        <OpTime>2022-03-28 16:39:44</OpTime>
    </OpLogDetails>
    <Success>true</Success>
</GetOpLogResponse>

JSON format

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

{
  "TotalCount" : 1,
  "RequestId" : "47D56208-DB1D-4FD3-BE32-300E43185488",
  "OpLogDetails" : [ {
    "OpUserId" : "51****",
    "UserId" : "22275482072787****",
    "Database" : "dmstest_prod_database@dmstest.rds...[Test instance]",
    "OpContent" : "SELECT * FROM `orders` \\n LIMIT 20",
    "UserNick" : "test_name",
    "Module" : "Security rule",
    "OpTime" : "2022-03-28 16:39:44"
  } ],
  "Success" : true
}

Error codes

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

SDK sample code

For more information about how to call this operation by using an SDK, see Alibaba Cloud SDK for Python.

Sample code:


from aliyunsdkcore.client import AcsClient
from aliyunsdkdms_enterprise.request.v20181101.GetOpLogRequest import GetOpLogRequest
client = AcsClient(
    "<your-access-key-id>",
   "<your-access-key-secret>",
   "<your-region-id>"
)
request = GetOpLogRequest()
request.set_Tid("Enter the tenant ID of your enterprise")
request.set_StartTime("2018-11-20 00:00:00")
request.set_EndTime("2018-11-23 00:00:00")
request.set_PageNumber(1)
request.set_PageSize(50)
response = client.do_action_with_exception(request)
print response