审计
获取审计数据(GetAuditData)
API请求
URLs
GET zstack/v1/zwatch/auditsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/audits?startTime=1.557300700509E12&limit=50.0&auditType=Resource参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| startTime (可选) | Long | query | 起始时间 | 2.3 | |
| endTime (可选) | Long | query | 结束时间 | 2.3 | |
| limit (可选) | Integer | query | 最大返回条数 | 2.3 | |
| labels (可选) | List | query | 过滤标签列表 | 2.3 | |
| auditType (可选) | AuditType | query | 审计类型,默认为Resource |
|
3.5.0 |
| systemTags (可选) | List | query | 系统标签 | 2.3 | |
| userTags (可选) | List | query | 用户标签 | 2.3 |
API返回
返回示例
{
"audits": [
{
"resourceUuid": "b1ca3fab6ebc4302ad9249d5402cb06c",
"resourceType": "VmInstanceVO",
"clientIp": "172.0.0.1",
"clientBrowser": "Chrome/69.0.3497.81",
"apiName": "org.zstack.header.vm.APISetVmRDPMsg",
"operatorAccountUuid": "36c27e8ff05c4780bf6d2fa65700f22e",
"duration": 22.0,
"requestUuid": "d78093c0b2fb3850b3ce563b3a0b029d",
"responseUuid": "08cf3fd2c4614811b4acc0620e20a98e",
"sessionUuid": "05e5c663eb794faab5c5606c38103a17",
"responseDump": "{\"success\":true}",
"time": 1.512037844556E12
}
]
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#audits
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| resourceUuid | String | 资源UUID | 2.3 |
| resourceType | String | 资源类型 | 2.3 |
| apiName | String | API名称 | 2.3 |
| error | String | 错误详情 | 2.3 |
| operatorAccountUuid | String | 发起API账号UUID | 2.3 |
| duration | long | API耗时 | 2.3 |
| requestUuid | String | API请求UUID | 2.3 |
| responseUuid | String | API返回UUID | 2.3 |
| sessionUuid | String | 会话UUID | 2.3 |
| requestDump | String | API请求JSON存档 | 2.3 |
| responseDump | String | API返回JSON存档 | 2.3 |
| time | long | 记录生成时间 | 2.3 |
SDK示例
Java
SDK
GetAuditDataAction action = new GetAuditDataAction();
action.startTime = 1.557300701132E12;
action.limit = 50.0;
action.conditions = asList("VMUuid=4ca37b1e21e846bf8d35b23d4138489c");
action.auditType = "Resource";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAuditDataAction.Result res = action.call();Python
SDK
GetAuditDataAction action = GetAuditDataAction()
action.startTime = 1.557300701178E12
action.limit = 50.0
action.conditions = [VMUuid=6623c395df0d44b6afc3732e76aac0ac]
action.auditType = "Resource"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetAuditDataAction.Result res = action.call()查询审计数据(QueryAudit)
API请求
URLs
GET zstack/v1/zwatch/audit-recordsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/audit-records?q=resourceUuid=ed54196e3439329489f39c78337ae8b0可查询字段
运行CLI命令行工具,输入QueryAudit并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
QueryAuditAction action = new QueryAuditAction();
action.conditions = asList("resourceUuid=8705e96cf85d314dbec2e0a4ec8038c9");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAuditAction.Result res = action.call();Python
SDK
QueryAuditAction action = QueryAuditAction()
action.conditions = ["resourceUuid=f2561dbe12b13b1a849eb1db696d3bec"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAuditAction.Result res = action.call()