操作审计默认为每个阿里云账号记录最近90天的事件。为了能够追溯90天以前的事件,您可以创建跟踪,将操作事件投递到对象存储OSS、日志服务SLS或大数据计算服务MaxCompute,以便对事件进行分析。
接口说明
通过 API 创建的跟踪默认处于已关闭状态,您需要调用接口 StartLogging 开启跟踪,操作审计才能投递操作事件至目标云产品。
前提条件
创建跟踪之前,请您确保至少完成下列的一项存储配置:
-
投递到对象存储 OSS
请确保您已开通对象存储,且已创建存储空间(Bucket)。
-
投递到日志服务 SLS
请确保您已开通日志服务,且已创建日志项目。
说明创建跟踪时,操作审计会自动在目标日志项目下创建一个名为
actiontrail_<跟踪名称>
的日志库(Logstore),该日志库禁止其他数据写入,保证审计数据的准确性。 -
投递到大数据计算服务 MaxCompute
请确保您已开通大数据计算服务 MaxCompute。
说明创建跟踪时,操作审计会自动在项目管理中创建一个名为
actiontrail_<账号 ID>
的项目,该项目禁止其他数据写入,保证审计数据的准确性。
使用说明
本文将提供一个示例,为您创建一个名为trail-test
的单账号跟踪,将操作事件投递到名为audit-log
的 OSS 存储空间中。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
actiontrail:CreateTrail |
create |
*Trail
|
无 | 无 |
请求参数
名称 |
类型 |
必填 |
描述 |
示例值 |
Name |
string |
是 |
创建的跟踪名称。 说明
同一个账号内跟踪名称不可重复。 |
trail-test |
OssBucketName |
string |
否 |
跟踪投递的 OSS 存储空间。 说明
OssBucketName、SlsProjectArn、MaxComputeProjectArn 需至少指定其中一个参数。 |
audit-log |
OssKeyPrefix |
string |
否 |
跟踪投递的 OSS 存储空间文件名的前缀,可为空。 |
at-product-account-audit-B |
OssWriteRoleArn |
string |
否 |
操作审计向对象存储 OSS 存储空间投递操作事件时,扮演的角色 ARN。
|
acs:ram::15127787691****:role/aliyunserviceroleforactiontrail |
SlsProjectArn |
string |
否 |
跟踪投递的日志服务项目的 ARN。 说明
OssBucketName、SlsProjectArn、MaxComputeProjectArn 需至少指定其中一个参数。 |
acs:log:cn-shanghai:151266687691****:project/test-project |
SlsWriteRoleArn |
string |
否 |
操作审计向日志服务项目投递操作事件时,扮演的角色 ARN。
|
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
EventRW |
string |
否 |
投递事件的读写类型,取值:
|
Write |
TrailRegion |
string |
否 |
跟踪的地域。 |
All |
IsOrganizationTrail |
boolean |
否 |
是否创建多账号跟踪,取值:
|
false |
MaxComputeProjectArn |
string |
否 |
跟踪投递的大数据计算服务项目的 ARN。 说明
OssBucketName、SlsProjectArn、MaxComputeProjectArn 需至少指定其中一个参数。 说明
MaxComputeProjectArn 中指定的大数据计算服务项目名称必须以 actiontrail_作为前缀。 |
acs:odps:cn-hangzhou:15127787691****:project/actiontrail_**** |
MaxComputeWriteRoleArn |
string |
否 |
操作审计向大数据计算服务项目投递操作事件时,扮演的角色 ARN。
|
acs:ram::15127787691****:role/aliyunserviceroleforactiontrail |
关于公共请求参数的详情,请参见公共参数。
返回参数
名称 |
类型 |
描述 |
示例值 |
object |
|||
EventRW |
string |
投递事件的读写类型。 |
Write |
HomeRegion |
string |
跟踪的 Home 地域。 |
cn-hangzhou |
MaxComputeProjectArn |
string |
跟踪投递的大数据计算服务项目的 ARN。 |
acs:odps:cn-hangzhou:151266687691****:project/actiontrail_**** |
MaxComputeWriteRoleArn |
string |
操作审计向大数据计算服务项目投递操作事件时,扮演的角色 ARN。 |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
Name |
string |
跟踪名称。 |
trail-test |
OssBucketName |
string |
OSS 存储空间。 |
audit-log |
OssKeyPrefix |
string |
OSS 存储空间文件名的前缀。 |
at-product-account-audit-B |
OssWriteRoleArn |
string |
操作审计向对象存储 OSS 存储空间投递操作事件时,扮演的角色 ARN。 |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
RequestId |
string |
请求 ID。 |
442DDADF-DA58-4029-8E8B-82C73E9A7A70 |
SlsProjectArn |
string |
跟踪投递的日志服务项目的 ARN。 |
acs:log:cn-hangzhou:151266687691****:project/test-project |
SlsWriteRoleArn |
string |
操作审计向日志服务项目投递操作事件时,扮演的角色 ARN。 |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
TrailRegion |
string |
跟踪的地域。 |
All |
示例
正常返回示例
JSON
格式
{
"EventRW": "Write",
"HomeRegion": "cn-hangzhou",
"MaxComputeProjectArn": "acs:odps:cn-hangzhou:151266687691****:project/actiontrail_****",
"MaxComputeWriteRoleArn": "acs:ram::151266687691****:role/aliyunserviceroleforactiontrail",
"Name": "trail-test",
"OssBucketName": "audit-log",
"OssKeyPrefix": "at-product-account-audit-B",
"OssWriteRoleArn": "acs:ram::151266687691****:role/aliyunserviceroleforactiontrail",
"RequestId": "442DDADF-DA58-4029-8E8B-82C73E9A7A70",
"SlsProjectArn": "acs:log:cn-hangzhou:151266687691****:project/test-project",
"SlsWriteRoleArn": "acs:ram::151266687691****:role/aliyunserviceroleforactiontrail",
"TrailRegion": "All"
}
错误码
HTTP status code |
错误码 |
错误信息 |
描述 |
---|---|---|---|
400 | InvalidDeliveryConfigurationException | You must specify at least one Log Service project or OSS bucket for a Trail. | |
400 | InvalidPrefixException | The specified OSS bucket prefix is invalid. | 指定的OSS前缀无效。 |
400 | InvalidQueryParameter | The specified query parameter is invalid. | 无效的查询参数。 |
400 | InvalidTrailNameException | The specified Trail name is invalid. | 跟踪名称无效,请修改。 |
400 | RepeatOssBucket | The specified OSS bucket is already in use. We recommend that you modify the existing Trail or specify another bucket. | |
400 | SlsProjectDoesNotExistException | The specified Log Service project does not exist. | |
400 | TrailAlreadyExistsException | The specified Trail name already exists. | 您输入的跟踪名称已存在,如需创建新跟踪请修改跟踪名称。 |
400 | MaximumNumberOfOrganizationTrailExceeded | Your account can create only one organization trail. | 您的账号只能创建一个多账号跟踪。 |
400 | NotAllowCreateOrganizationTrail | Your account does not allow you to create organization trail. Submit a ticket to get customer support. | 您的账号不允许创建多账号跟踪,请提交工单联系客户支持。 |
403 | InsufficientBucketPolicyException | Access to the specified OSS bucket was denied. | |
403 | InsufficientSlsPolicyException | Access to the specified Log Service project was denied. | 无法访问指定的SLS Project。 |
403 | MaximumNumberOfTrailsExceededException | The number of Trails in the same region exceeds the upper limit (5). | 同一地域最多可以创建5个跟踪。 |
404 | BucketDoesNotExistException | The specified OSS bucket does not exist. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。