调用GetOpLog获取指定时间内的操作日志详情列表。

DMS企业版用户的管理员可以通过这个接口获取本企业产生的相关操作日志详情列表。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String GetOpLog

系统规定参数。取值:GetOpLog

Tid Long -1

租户ID。

说明 取自系统右上角头像处悬停展示的信息,租户ID
StartTime String 2018-11-01 10:00:00

开始时间,时间格式为 yyyy-MM-DD HH:mm:ss

EndTime String 2018-11-01 11:00:00

结束时间,时间格式为 yyyy-MM-DD HH:mm:ss

PageNumber Integer 3

页码,从1开始

PageSize Integer 30

每页记录数,取值:

  • 30
  • 50
  • 100
Module String PERMISSION

日志模块,缺省则对应时间段内所有模块返回,日志模块取值和说明如下:

  • PERMISSION: 权限
  • OWNER: 数据Owner
  • SQL_CONSOLE: 数据查询
  • SQL_CONSOLE_EXPORT: 查询结果导出
  • DATA_CHANGE: 数据变更
  • DATA_EXPORT: 数据导出
  • SQL_REVIEW: SQL审核
  • DT_SYNC: 库表同步
  • DT_DETAIL: 库表详情
  • DB_TASK: 任务管理
  • INSTANCE_MANAGE: 实例管理
  • USER_MANAGE: 用户管理
  • SECURITY_RULE: 安全规则
  • CONFIG_MANAGE: 配置管理
  • RESOURCE_AUTH: 资源授权
  • ACCESS_WHITE_IP: 访问IP白名单

返回数据

名称 类型 示例值 描述
ErrorCode String 403

错误码

ErrorMessage String 请求参数不合法

错误消息

OpLogDetails Array

操作日志详情列表

OpLogDetail
Database String dmstest_prod_database@dmstest.rds...【测试实例】

数据库访问地址,只有当实例类型为LocalInstance时,这个参数才有值。

说明 仅任务类型区域的各功能模块操作才有这个属性。
Module String PERMISSION

功能模块

OpContent String 申请权限

操作内容

OpTime String 2018-11-01 10:00:00

操作时间

OrderId Long 1

工单号/任务号。

说明 仅任务类型区域的各功能模块操作与系统管理任务管理功能模块的操作才有这个属性。
UserId Long 12345678

用户阿里云uid

UserNick String dmstest

用户显示名

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

请求唯一ID

Success Boolean true

请求是否成功

TotalCount Long 22

操作日志总条数

示例

请求示例

http(s)://[Endpoint]/?Action=GetOpLog
&Tid=-1
&StartTime=2018-11-01 10:00:00
&EndTime=2018-11-01 11:00:00
&PageNumber=3
&PageSize=30
&<公共请求参数>

正常返回示例

XML 格式

<GetOpLogResponse>
     <OpLogDetails>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 20:04:10</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 20:04:06</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 20:03:55</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 20:02:59</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 20:02:49</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:34:05</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:33:54</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5486</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:26:57</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5485</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:23:55</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5484</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:23:30</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5483</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:23:11</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>【成功,行数:1】show CREATE TABLE multi_db_single_tbl</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:22:30</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:22:15</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:19:31</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5482</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:19:25</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:18:57</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>新增SQL任务,任务号:5481</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:18:46</OpTime>
               <Module>任务管理</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:04:13</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 14:04:08</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent></OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 12:11:41</OpTime>
               <Module>数据查询</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>管理员或DBA编辑库OWNER,库名:dmstest_database@dmstest.rds...【测试实例】</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_database@dmstest.rds...【测试实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 12:11:14</OpTime>
               <Module>数据Owner</Module>
          </OpLogDetail>
          <OpLogDetail>
               <OpContent>管理员或DBA编辑库OWNER,库名:dmstest_prod_database@dmstest.rds...【生产实例】</OpContent>
               <UserNick>dmstest</UserNick>
               <Database>dmstest_prod_database@dmstest.rds...【生产实例】</Database>
               <UserId>12345678</UserId>
               <OpTime>2018-11-22 12:11:07</OpTime>
               <Module>数据Owner</Module>
          </OpLogDetail>
     </OpLogDetails>
     <TotalCount>22</TotalCount>
     <RequestId>DC3A5360-67CC-4A0B-B5BD-734CBEAF8A23</RequestId>
     <Success>true</Success>
</GetOpLogResponse>

JSON 格式

{
	"OpLogDetails": {
		"OpLogDetail": [{
			"OpContent": "【成功,行数:1】SELECT (data_length + index_length) AS store_capacity FROM information_schema.tables WHERE table_type = &#39;BASE TABLE&#39; AND `table_schema` = &#39;dmstest_database&#39; AND `table_name` = &#39;multi_db_multi_tbl&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 20:04:10",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:1】SELECT (data_length + index_length) AS store_capacity FROM information_schema.tables WHERE table_type = &#39;BASE TABLE&#39; AND `table_schema` = &#39;dmstest_database&#39; AND `table_name` = &#39;multi_db_multi_tbl&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 20:04:06",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:24】show topology FROM multi_db_multi_tbl",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 20:03:55",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:1】SELECT (data_length + index_length) AS store_capacity FROM information_schema.tables WHERE table_type = &#39;BASE TABLE&#39; AND `table_schema` = &#39;dmstest_database&#39; AND `table_name` = &#39;user_log3&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 20:02:59",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:1】SELECT (data_length + index_length) AS store_capacity FROM information_schema.tables WHERE table_type = &#39;BASE TABLE&#39; AND `table_schema` = &#39;dmstest_database&#39; AND `table_name` = &#39;user_log3&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 20:02:49",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:1】show CREATE TABLE user_log3",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:34:05",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:9】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:33:54",
			"Module": "数据查询"
		}, {
			"OpContent": "新增SQL任务,任务号:5486",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:26:57",
			"Module": "任务管理"
		}, {
			"OpContent": "新增SQL任务,任务号:5485",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:23:55",
			"Module": "任务管理"
		}, {
			"OpContent": "新增SQL任务,任务号:5484",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:23:30",
			"Module": "任务管理"
		}, {
			"OpContent": "新增SQL任务,任务号:5483",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:23:11",
			"Module": "任务管理"
		}, {
			"OpContent": "【成功,行数:1】show CREATE TABLE multi_db_single_tbl",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:22:30",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:2】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:22:15",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:2】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:19:31",
			"Module": "数据查询"
		}, {
			"OpContent": "新增SQL任务,任务号:5482",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:19:25",
			"Module": "任务管理"
		}, {
			"OpContent": "【成功,行数:1】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:18:57",
			"Module": "数据查询"
		}, {
			"OpContent": "新增SQL任务,任务号:5481",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:18:46",
			"Module": "任务管理"
		}, {
			"OpContent": "【成功,行数:0】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:04:13",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:0】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 14:04:08",
			"Module": "数据查询"
		}, {
			"OpContent": "【成功,行数:0】SELECT `TABLE_NAME` FROM information_schema.tables WHERE TABLE_TYPE = &#39;BASE TABLE&#39; AND table_schema = &#39;dmstest_database&#39;",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 12:11:41",
			"Module": "数据查询"
		}, {
			"OpContent": "管理员或DBA编辑库OWNER,库名:dmstest_database@dmstest.rds...【测试实例】",
			"UserNick": "dmstest",
			"Database": "dmstest_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 12:11:14",
			"Module": "数据Owner"
		}, {
			"OpContent": "管理员或DBA编辑库OWNER,库名:dmstest_prod_database@dmstest.rds...【测试实例】",
			"UserNick": "dmstest",
			"Database": "dmstest_prod_database@dmstest.rds...【测试实例】",
			"UserId": 12345678,
			"OpTime": "2018-11-22 12:11:07",
			"Module": "数据Owner"
		}]
	},
	"TotalCount": 22,
	"RequestId": "47D56208-DB1D-4FD3-BE32-300E43185488",
	"Success": true
}

错误码

访问错误中心查看更多错误码。

SDK示例

SDK使用基础信息参考:阿里云Python SDK

示例如下:


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("请输入你的企业租户id")
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