All Products
Search
Document Center

Data Management:GetOpLog

Last Updated:Apr 26, 2024

Queries the details of operation logs that are generated in a specified period of time.

Operation description

Prerequisites: You are an administrator of Data Management (DMS) or a security administrator. 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.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
dms:GetOpLogRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
TidlongNo

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

3***
ModulestringNo

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 rules
  • CONFIG_MANAGE: configuration management
  • RESOURCE_AUTH: resource authorization
  • ACCESS_WHITE_IP: access IP address whitelist
  • NDDL: schema design
  • DSQL_CONSOLE: cross-database data query
  • DSQL_CONSOLE_EXPORT: cross-database query result export
  • DATA_TRACT: data tracking
  • DATA_QUALITY: data quality
  • DATALINK_MANAGE :DBLink management
  • DATASEC_MANAGE: sensitive data management
  • SELL: sales
SECURITY_RULE
StartTimestringYes

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

2022-03-23 10:00:00
EndTimestringYes

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

2022-03-29 10:00:00
PageSizeintegerYes

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

  • 30
  • 50
  • 100
30
PageNumberintegerYes

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

1
UserNickstringNo

UserNick.

test_name
DatabaseNamestringNo

DatabaseName.

dmstest@rm-bp1qb97d4b****.mysql.rds.aliyuncs.com:3306[poc_dev]

Response parameters

ParameterTypeDescriptionExample
object
TotalCountlong

The total number of operation logs that are returned.

1
RequestIdstring

The ID of the request.

47D56208-DB1D-4FD3-BE32-300E43185488
ErrorCodestring

The error code.

403
OpLogDetailsobject []

The details of the operation log.

Modulestring

The functional module for which the operation log is queried.

SECURITY_RULE
Databasestring

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.

dmstest_prod_database@dmstest.rds... \[Test instance]
UserIdstring

The ID of the Alibaba Cloud account.

22275482072787****
OpUserIdlong

The ID of the user who performed the operation.

51****
OpContentstring

The details of the operation.

SELECT * FROM `orders` \n LIMIT 20
UserNickstring

The display name of the user.

test_name
OrderIdlong

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.
509****
OpTimestring

The time when the operation was performed.

2022-03-28 16:45:19
ErrorMessagestring

The error message returned if the request failed.

UnknownError
Successboolean

Indicates whether the request was successful. Valid values:

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

Examples

Sample success responses

JSONformat

{
  "TotalCount": 1,
  "RequestId": "47D56208-DB1D-4FD3-BE32-300E43185488",
  "ErrorCode": "403",
  "OpLogDetails": {
    "OpLogDetail": [
      {
        "Module": "SECURITY_RULE\n",
        "Database": "dmstest_prod_database@dmstest.rds... \\[Test instance]\n",
        "UserId": "22275482072787****",
        "OpUserId": 0,
        "OpContent": "SELECT * FROM `orders` \\n LIMIT 20",
        "UserNick": "test_name",
        "OrderId": 0,
        "OpTime": "2022-03-28 16:45:19"
      }
    ]
  },
  "ErrorMessage": "UnknownError",
  "Success": true
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-04-27The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: DatabaseName
    delete Input Parameters: InstanceName
2023-04-27The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: UserNick
    Added Input Parameters: InstanceName

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("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