Creates a trail to deliver events to a destination for long-term storage and analysis, such as an Object Storage Service (OSS) bucket, a Simple Log Service (SLS) Logstore, or a MaxCompute project.
Operation description
By default, a trail that you create by using this API is in a disabled state. You must call the StartLogging operation operation to enable the trail. After a trail is enabled, ActionTrail begins delivering events to your specified destination.
Prerequisites
Before you create a trail, you must have at least one of the following resources configured as a destination:
-
OSS
You must activate OSS and create a bucket.
-
SLS
You must activate SLS and create a Logstore.
NoteWhen you create a trail with an SLS destination, ActionTrail automatically creates a Logstore named
actiontrail_<trail_name>in your specified project. To ensure the integrity of your audit data, this Logstore only accepts events delivered by ActionTrail. -
MaxCompute
You must activate MaxCompute.
NoteWhen you create a trail with a MaxCompute destination, ActionTrail automatically creates a project named
actiontrail_<account_ID>. To ensure the integrity of your audit data, this project only accepts events delivered by ActionTrail.
Usage notes
This example shows how to create a single-account trail named trail-test that delivers events to an OSS bucket named audit-log.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
actiontrail:CreateTrail |
create |
*Trail
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Name |
string |
Yes |
The name of the trail. Note
|
trail-test |
| OssBucketName |
string |
No |
The name of the OSS bucket to which ActionTrail delivers events.
Note
You must specify a destination for the trail by providing at least one of the following parameters: |
audit-log |
| OssKeyPrefix |
string |
No |
The prefix for the names of log files that ActionTrail delivers to your OSS bucket.
|
at-product-account-audit-B |
| OssWriteRoleArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the RAM role that ActionTrail assumes to deliver events to the OSS bucket.
|
acs:ram::15127787691****:role/aliyunserviceroleforactiontrail |
| SlsProjectArn |
string |
No |
The ARN of the SLS project to which ActionTrail delivers events. Note
You must specify a destination for the trail by providing at least one of the following parameters: |
acs:log:cn-shanghai:151266687691****:project/test-project |
| SlsWriteRoleArn |
string |
No |
The ARN of the RAM role that ActionTrail assumes to deliver events to the SLS project.
|
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
| EventRW |
string |
No |
Specifies the read/write type of events that the trail delivers. Valid values:
|
Write |
| TrailRegion |
string |
No |
The region in which the trail is created. By default, a trail is created in all regions and this parameter is set to |
All |
| IsOrganizationTrail |
boolean |
No |
Specifies whether the trail is a multi-account trail. Valid values:
To create a trail for an organization, set this parameter to |
false |
| MaxComputeProjectArn |
string |
No |
The ARN of the MaxCompute project to which ActionTrail delivers events. Note
You must specify a destination for the trail by providing at least one of the following parameters: Note
The project name in the ARN must start with |
acs:odps:cn-hangzhou:15127787691****:project/actiontrail_**** |
| MaxComputeWriteRoleArn |
string |
No |
The ARN of the RAM role that ActionTrail assumes to deliver events to the MaxCompute project.
|
acs:ram::15127787691****:role/aliyunserviceroleforactiontrail |
For more information, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| EventRW |
string |
The read/write type of events that the trail delivers. |
Write |
| HomeRegion |
string |
The home region of the trail. |
cn-hangzhou |
| MaxComputeProjectArn |
string |
The ARN of the MaxCompute project to which the trail delivers events. |
acs:odps:cn-hangzhou:151266687691****:project/actiontrail_**** |
| MaxComputeWriteRoleArn |
string |
The ARN of the RAM role that ActionTrail assumes to deliver events to the MaxCompute project. |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
| Name |
string |
The name of the trail. |
trail-test |
| OssBucketName |
string |
The name of the destination OSS bucket. |
audit-log |
| OssKeyPrefix |
string |
The prefix for the names of log files in the OSS bucket. |
at-product-account-audit-B |
| OssWriteRoleArn |
string |
The ARN of the RAM role that ActionTrail assumes to deliver events to the OSS bucket. |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
| RequestId |
string |
The request ID. |
442DDADF-DA58-4029-8E8B-82C73E9A7A70 |
| SlsProjectArn |
string |
The ARN of the SLS project to which the trail delivers events. |
acs:log:cn-hangzhou:151266687691****:project/test-project |
| SlsWriteRoleArn |
string |
The ARN of the RAM role that ActionTrail assumes to deliver events to the SLS project. |
acs:ram::151266687691****:role/aliyunserviceroleforactiontrail |
| TrailRegion |
string |
The region in which the trail is created. A value of |
All |
Examples
Success response
JSON format
{
"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"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 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. | The specified OSS bucket prefix is not valid. |
| 400 | InvalidQueryParameter | The specified query parameter is invalid. | The specified query parameter is not valid. |
| 400 | InvalidTrailNameException | The specified Trail name is invalid. | The specified Trail name is not valid. |
| 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. | The specified Trail name already exists,if you want to create a new Trail,please use another Trail name. |
| 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. | Access SLS Project denied. |
| 403 | MaximumNumberOfTrailsExceededException | The number of Trails in the same region exceeds the upper limit (5). | The number of Trail in same region has exceeded the limit 5 |
| 404 | BucketDoesNotExistException | The specified OSS bucket does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.