有奖征文:轻量对象存储LighthouseCOS用户实践> HOT

SDK 描述

LookupEvents 用于对操作日志进行检索,便于用户查询相关的操作信息。

请求参数

参数名称
必选
类型
描述
EndTime
DateTime
结束时间。
LookupAttributes
Array
属性数组,目前仅支持一个元素,不填默认返回前十条数据。
MaxResults
Number
日志返回的条数,不填默认返回10条,最多支持50条。
NextToken
String
加载更多日志的时候使用。
StartTime
DateTime
开始时间。
其中 LookupAttributes 的参数如下:
参数名称
必选
类型
描述
AttributeKey
String
搜索类型(枚举值),包括:
Username:用户名
EventName:事件名称
ResourceType:资源类型
ResourceName:资源名称
EventSource:事件源
EventId:事件 ID
AttributeValue
String
Value 值。

响应参数

参数名称
类型
描述
Events
Array
事件数组。
NextToken
String
加载更多时使用。
其中 Events 数组的参数如下:
参数名称
类型
描述
CloudAuditEvent
String
事件字符串。
EventId
String
事件 ID。
EventName
String
事件名称。
EventSource
String
事件源。
EventRegion
String
区域。
EventTime
String
事件时间。
SecretId
String
访问密钥。
ErrorCode
Number
错误码。0代表正常,其他代表错误。
RequestID
String
请求 ID。
AccountID
String
主账号 ID。
SourceIPAddress
String
源 IP 地址。
Resources
Object
资源。
Username
String
用户名。主账号为:root,子账号为:子账号 ID,角色用户为:roleUser。
其中 Resources 的参数如下:
参数名称
类型
描述
ResourceName
String
资源名称。
ResourceType
String
资源类型。

实际案例

请求示例

$config = array('SecretId' => '您的secretId',
'SecretKey' => '您的secretKey',
'RequestMethod' => 'GET',
'DefaultRegion' => 'gz');
$ca = QcloudApi::load(QcloudApi::MODULE_CLOUDAUDIT, $config);
$nowTime = time();
$startTime = $nowTime-86400;
$package = array(
'EndTime'=>$nowTime,
'LookupAttributes'=>'[{"AttributeKey":"EventName","AttributeValue":"LookupEvents"}]',
'MaxResults'=>10,
'StartTime'=>$startTime
);
$a = $ca->LookUpEvents($package);
if ($a === false) {
$error = $ca->getError();
echo "Error code:" . $error->getCode() . ".\\n";
echo "message:" . $error->getMessage() . ".\\n";
echo "ext:" . var_export($error->getExt(), true) . ".\\n";
} else {
var_dump($a);
}
echo "\\nRequest :" . $ca->getLastRequest();
echo "\\nResponse :" . $ca->getLastResponse();
echo "\\n";

响应示例

{
"Events": [
{
"CloudAuditEvent": "{\\"userIdentity\\":{\\"type\\":\\"Root\\",\\"principalId\\":\\"91000000009\\",\\"accountId\\":\\"91000000009\\",\\"userName\\":\\"root\\",\\"secretId\\":\\"AKIDVu8F***********4RcbO2UnvsdDdvxqX\\"},\\"eventTime\\":\\"2017-11-02 19:08:14\\",\\"eventVersion\\":\\"1.0\\",\\"eventSource\\":\\"cloudaudit.api.tencentyun.com\\\\/v2\\\\/index.php\\",\\"requestParameters\\":{\\"Action\\":\\"LookupEvents\\",\\"EndTime\\":\\"1509620894\\",\\"LookupAttributes\\":\\"[{\\\\\\"AttributeKey\\\\\\":\\\\\\"string\\\\\\",\\\\\\"AttributeValue\\\\\\":\\\\\\"LookupEvents\\\\\\"}]\\",\\"MaxResults\\":\\"10\\",\\"Nonce\\":\\"24731\\",\\"Region\\":\\"ap-guangzhou\\",\\"RequestClient\\":\\"SDK_PHP_1.1\\",\\"SecretId\\":\\"AKIDVu8F**********O2UnvsdDdvxqX\\",\\"SignatureMethod\\":\\"HmacSHA256\\",\\"StartTime\\":\\"1509534494\\",\\"Timestamp\\":\\"1509620894\\",\\"Version\\":\\"2017-03-12\\"},\\"sourceIPAddress\\":\\"10.251.88.12\\",\\"eventRegion\\":\\"ap-guangzhou\\",\\"eventName\\":\\"LookupEvents\\",\\"resourceType\\":\\"cloudaudit\\",\\"userAgent\\":\\"SDK_PHP_1.1\\",\\"errorCode\\":\\"0\\",\\"errorMessage\\":\\"end verify!permission verify\\",\\"requestID\\":662138269,\\"eventID\\":\\"5e9ec3fae7d93fd346cc28d397d4f1db1\\",\\"eventType\\":\\"ApiCall\\",\\"apiVersion\\":\\"2.0\\",\\"resources\\":\\"*\\",\\"resourceName\\":\\"*\\"}",
"EventId": "5e9ec3fae7d93fd346cc28d397d4f1db1",
"EventName": "LookupEvents",
"EventTime": "2017-11-02 19:08:14",
"SecretId": "AKIDVu8FB**********4RcbO2UnvsdDdvxqX",
"ErrorCode": "0",
"RequestID": 662138269,
"AccountID": "91000000009",
"SourceIPAddress": "10.251.88.12",
"EventSource": "cloudaudit.api.tencentyun.com/v2/index.php",
"EventRegion": "ap-guangzhou",
"Resources": {
"ResourceName": "*",
"ResourceType": "cloudaudit"
},
"Username": "root"
},
{
"CloudAuditEvent": "{\\"userIdentity\\":{\\"type\\":\\"Root\\",\\"principalId\\":\\"91000000009\\",\\"accountId\\":\\"91000000009\\",\\"userName\\":\\"root\\",\\"secretId\\":\\"AKIDPh**********CkEJLCqKbloJhx4yoGhv\\",\\"sessionContext\\":{\\"token\\":\\"2226bb8e387f5aaa9a62c5db7f59f589ff871c131\\",\\"ua\\":\\"c3c4abeb0a8fb537b7dd9f07542b0758\\",\\"userIp\\":\\"14.17.22.36\\",\\"uin\\":\\"91000000009\\",\\"ownerUin\\":\\"91000000009\\",\\"appId\\":\\"1254962721\\",\\"expireTime\\":\\"2017-11-02 16:26:46\\",\\"mfa\\":\\"0\\",\\"mfaExpireTime\\":\\"2017-11-02 15:56:46\\",\\"interfaceName\\":\\"\\",\\"hasPolicyFilter\\":\\"0\\",\\"policyFilter\\":\\"\\",\\"extraInfo\\":\\"\\"}},\\"eventTime\\":\\"2017-11-02 15:56:53\\",\\"eventVersion\\":\\"1.0\\",\\"eventSource\\":\\"cloudaudit.api.tencentyun.com\\\\/v2\\\\/index.php\\",\\"requestParameters\\":{\\"Action\\":\\"LookupEvents\\",\\"EndTime\\":\\"1509638399\\",\\"MaxResults\\":\\"10\\",\\"Nonce\\":\\"12120\\",\\"Region\\":\\"gz\\",\\"RequestClient\\":\\"SDK_NODEJS_0.1.3\\",\\"RequestOperator\\":\\"91000000009\\",\\"RequestSource\\":\\"MC\\",\\"SecretId\\":\\"AKIDPhn*************LCqKbloJhx4yoGhv\\",\\"StartTime\\":\\"1509552000\\",\\"Timestamp\\":\\"1509609414\\",\\"Token\\":\\"2226bb8e387f5aaa9a62c5db7f59f589ff871c131\\",\\"seqId\\":\\"837e01d6-30c0-b943-d4fa-3c610323f619\\",\\"spanId\\":\\"https:\\\\/\\\\/console.cloud.tencent.com;35938\\"},\\"sourceIPAddress\\":\\"14.17.22.36\\",\\"eventRegion\\":\\"gz\\",\\"eventName\\":\\"LookupEvents\\",\\"resourceType\\":\\"cloudaudit\\",\\"userAgent\\":\\"SDK_NODEJS_0.1.3\\",\\"errorCode\\":\\"0\\",\\"errorMessage\\":\\"end verify!permission verify\\",\\"requestID\\":1603560497,\\"eventID\\":\\"7f59b78fec0ffe363b8cd30aad159cc31\\",\\"eventType\\":\\"ApiCall\\",\\"apiVersion\\":\\"2.0\\",\\"resources\\":\\"*\\",\\"resourceName\\":\\"*\\"}",
"EventId": "7f59b78fec0ffe363b8cd30aad159cc31",
"EventName": "LookupEvents",
"EventTime": "2017-11-02 15:56:53",
"SecretId": "AKIDPhn***********EJLCqKbloJhx4yoGhv",
"ErrorCode": "0",
"RequestID": 1603560497,
"AccountID": "91000000009",
"SourceIPAddress": "14.17.22.36",
"EventSource": "cloudaudit.api.tencentyun.com/v2/index.php",
"EventRegion": "gz",
"Resources": {
"ResourceName": "*",
"ResourceType": "cloudaudit"
},
"Username": "root"
},
{
"CloudAuditEvent": "{\\"userIdentity\\":{\\"type\\":\\"Root\\",\\"principalId\\":\\"91000000009\\",\\"accountId\\":\\"91000000009\\",\\"userName\\":\\"root\\",\\"secretId\\":\\"AKIDPh********sYCkEJLCqKbloJhx4yoGhv\\",\\"sessionContext\\":{\\"token\\":\\"2226bb8e387f5aaa9a62c5db7f59f589ff871c131\\",\\"ua\\":\\"c3c4abeb0a8fb537b7dd9f07542b0758\\",\\"userIp\\":\\"14.17.22.36\\",\\"uin\\":\\"91000000009\\",\\"ownerUin\\":\\"91000000009\\",\\"appId\\":\\"1254962721\\",\\"expireTime\\":\\"2017-11-02 16:26:46\\",\\"mfa\\":\\"0\\",\\"mfaExpireTime\\":\\"2017-11-02 15:56:46\\",\\"interfaceName\\":\\"\\",\\"hasPolicyFilter\\":\\"0\\",\\"policyFilter\\":\\"\\",\\"extraInfo\\":\\"\\"}},\\"eventTime\\":\\"2017-11-02 15:56:47\\",\\"eventVersion\\":\\"1.0\\",\\"eventSource\\":\\"cloudaudit.api.tencentyun.com\\\\/v2\\\\/index.php\\",\\"requestParameters\\":{\\"Action\\":\\"LookupEvents\\",\\"EndTime\\":\\"1509638399\\",\\"MaxResults\\":\\"10\\",\\"Nonce\\":\\"27974\\",\\"Region\\":\\"gz\\",\\"RequestClient\\":\\"SDK_NODEJS_0.1.3\\",\\"RequestOperator\\":\\"91000000009\\",\\"RequestSource\\":\\"MC\\",\\"SecretId\\":\\"AKIDPh*********YCkEJLCqKbloJhx4yoGhv\\",\\"StartTime\\":\\"1509552000\\",\\"Timestamp\\":\\"1509609407\\",\\"Token\\":\\"2226bb8e387f5aaa9a62c5db7f59f589ff871c131\\",\\"seqId\\":\\"d65a517d-c721-b139-2d1e-9bc88b5c7d4b\\",\\"spanId\\":\\"https:\\\\/\\\\/console.cloud.tencent.com;35978\\"},\\"sourceIPAddress\\":\\"14.17.22.36\\",\\"eventRegion\\":\\"gz\\",\\"eventName\\":\\"LookupEvents\\",\\"resourceType\\":\\"cloudaudit\\",\\"userAgent\\":\\"SDK_NODEJS_0.1.3\\",\\"errorCode\\":\\"0\\",\\"errorMessage\\":\\"end verify!permission verify\\",\\"requestID\\":1352885274,\\"eventID\\":\\"8311e673d12535f8a1ae66b163554c221\\",\\"eventType\\":\\"ApiCall\\",\\"apiVersion\\":\\"2.0\\",\\"resources\\":\\"*\\",\\"resourceName\\":\\"*\\"}",
"EventId": "8311e673d12535f8a1ae66b163554c221",
"EventName": "LookupEvents",
"EventTime": "2017-11-02 15:56:47",
"SecretId": "AKIDPh***********kEJLCqKbloJhx4yoGhv",
"ErrorCode": "0",
"RequestID": 1352885274,
"AccountID": "91000000009",
"SourceIPAddress": "14.17.22.36",
"EventSource": "cloudaudit.api.tencentyun.com/v2/index.php",
"EventRegion": "gz",
"Resources": {
"ResourceName": "*",
"ResourceType": "cloudaudit"
},
"Username": "root"
},
{
"CloudAuditEvent": "{\\"userIdentity\\":{\\"type\\":\\"Root\\",\\"principalId\\":\\"91000000009\\",\\"accountId\\":\\"91000000009\\",\\"userName\\":\\"root\\",\\"secretId\\":\\"AKIDVu8FB************bO2UnvsdDdvxqX\\"},\\"eventTime\\":\\"2017-11-02 15:06:41\\",\\"eventVersion\\":\\"1.0\\",\\"eventSource\\":\\"cloudaudit.api.cloud.tencent.com\\\\/v2\\\\/index.php\\",\\"requestParameters\\":{\\"Action\\":\\"LookupEvents\\",\\"EndTime\\":\\"1509606229\\",\\"LookupAttributes\\":\\"[{\\\\\\"AttributeKey\\\\\\":\\\\\\"string\\\\\\",\\\\\\"AttributeValue\\\\\\":\\\\\\"\\\\\\"}]\\",\\"MaxResults\\":\\"10\\",\\"Nonce\\":\\"39718\\",\\"Region\\":\\"gz\\",\\"RequestClient\\":\\"SDK_PHP_1.1\\",\\"SecretId\\":\\"AKIDVu8F********2pw4RcbO2UnvsdDdvxqX\\",\\"StartTime\\":\\"1509519829\\",\\"Timestamp\\":\\"1509606229\\"},\\"sourceIPAddress\\":\\"14.17.22.36\\",\\"eventRegion\\":\\"gz\\",\\"eventName\\":\\"LookupEvents\\",\\"resourceType\\":\\"cloudaudit\\",\\"userAgent\\":\\"SDK_PHP_1.1\\",\\"errorCode\\":\\"0\\",\\"errorMessage\\":\\"end verify!permission verify\\",\\"requestID\\":803010205,\\"eventID\\":\\"cc737c139d689b109c265561a7e5bfe61\\",\\"eventType\\":\\"ApiCall\\",\\"apiVersion\\":\\"2.0\\",\\"resources\\":\\"*\\",\\"resourceName\\":\\"*\\"}",
"EventId": "cc737c139d689b109c265561a7e5bfe61",
"EventName": "LookupEvents",
"EventTime": "2017-11-02 15:06:41",
"SecretId": "AKIDVu8F**********w4RcbO2UnvsdDdvxqX",
"ErrorCode": "0",
"RequestID": 803010205,
"AccountID": "91000000009",
"SourceIPAddress": "14.17.22.36",
"EventSource": "cloudaudit.api.cloud.tencent.com/v2/index.php",
"EventRegion": "gz",
"Resources": {
"ResourceName": "*",
"ResourceType": "cloudaudit"
},
"Username": "root"
}
],
"NextToken": "MjAxNzExMDIxMywyMDE3MTEwMjEyLDIwMTcxMTAyMTEsMjAxNzExMDIxMCwyMDE3MTEwMjA5LDIwMTcxMTAyMDgsKzIwMTctMTEtMDIgMTk6MjM6MzQrMA==",
"ListOver": false
}