All Products
Search
Document Center

ActionTrail:CreateTrail

Last Updated:Jun 10, 2026

Membuat trail untuk mengirimkan event ke tujuan penyimpanan dan analisis jangka panjang, seperti bucket Object Storage Service (OSS), penyimpanan log Simple Log Service (SLS), atau Proyek MaxCompute.

Deskripsi operasi

Catatan

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.

    Catatan

    When 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.

    Catatan

    When 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.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

actiontrail:CreateTrail

create

*Trail

acs:actiontrail:{#regionId}:{#accountId}:trail/*

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

Name

string

Yes

Nama trail.

Catatan
  • Panjang: 6 hingga 36 karakter.

  • Karakter: Huruf kecil, digit, tanda hubung (-), dan garis bawah (_).

  • Harus diawali dengan huruf kecil.

  • Harus unik dalam satu akun Alibaba Cloud.

trail-test

OssBucketName

string

No

Nama bucket OSS tempat ActionTrail mengirimkan event.

  • Panjang: 3 hingga 63 karakter.

  • Karakter: Huruf kecil, digit, dan tanda hubung (-).

  • Harus diawali dengan huruf kecil atau digit.

Catatan

Anda harus menentukan tujuan untuk trail dengan menyediakan setidaknya satu dari parameter berikut: OssBucketName, SlsProjectArn, atau MaxComputeProjectArn.

audit-log

OssKeyPrefix

string

No

Awalan untuk nama file log yang ActionTrail mengirimkan ke bucket OSS Anda.

  • Panjang: 6 hingga 32 karakter.

  • Karakter: Huruf, digit, tanda hubung (-), garis miring (/), dan garis bawah (_).

  • Harus diawali dengan huruf.

at-product-account-audit-B

OssWriteRoleArn

string

No

Nama Sumber Daya Alibaba Cloud (ARN) Peran RAM yang diasumsikan ActionTrail untuk mengirimkan event ke bucket OSS.

  • Jika Anda tidak menentukan parameter ini, ActionTrail membuat service-linked role untuk mengirimkan event. Untuk informasi lebih lanjut, lihat Service-linked role ActionTrail.

  • Jika Anda menentukan peran, peran tersebut harus berupa Peran RAM yang Anda buat. Peran ini harus memiliki kebijakan kepercayaan yang mengizinkan layanan ActionTrail (actiontrail.aliyuncs.com) untuk mengasumsikannya. Kebijakan RAM peran tersebut harus memberikan izin untuk menulis ke bucket OSS yang ditentukan. Untuk informasi lebih lanjut tentang pengiriman lintas akun, lihat Mengirimkan event dari beberapa akun Alibaba Cloud ke akun yang sama.

acs:ram::15127787691****:role/aliyunserviceroleforactiontrail

SlsProjectArn

string

No

ARN proyek SLS tempat ActionTrail mengirimkan event.

Catatan

Anda harus menentukan tujuan untuk trail dengan menyediakan setidaknya satu dari parameter berikut: OssBucketName, SlsProjectArn, atau MaxComputeProjectArn.

acs:log:cn-shanghai:151266687691****:project/test-project

SlsWriteRoleArn

string

No

ARN Peran RAM yang diasumsikan ActionTrail untuk mengirimkan event ke proyek SLS.

  • Jika parameter ini tidak ditentukan, ActionTrail membuat service-linked role untuk mengirimkan event. Untuk informasi lebih lanjut, lihat Service-linked role ActionTrail.

  • Jika Anda menentukan peran, peran tersebut harus berupa Peran RAM yang Anda buat. Peran ini harus memiliki kebijakan kepercayaan yang mengizinkan layanan ActionTrail (actiontrail.aliyuncs.com) untuk mengasumsikannya. Kebijakan izin peran tersebut harus memberikan izin untuk menulis ke proyek SLS yang ditentukan. Untuk informasi lebih lanjut tentang pengiriman lintas akun, lihat Mengirimkan event dari beberapa akun Alibaba Cloud ke akun yang sama.

acs:ram::151266687691****:role/aliyunserviceroleforactiontrail

EventRW

string

No

Menentukan tipe baca/tulis event yang trail mengirimkan. Nilai valid:

  • Write: Event tulis.

  • Read: Event baca.

  • All (default): Semua event baca dan tulis.

Write

TrailRegion

string

No

Wilayah tempat trail dibuat. Secara default, trail dibuat di semua wilayah dan parameter ini diatur ke All. Untuk membuat trail di wilayah tertentu, berikan ID wilayah. Untuk informasi lebih lanjut tentang wilayah, panggil operasi DescribeRegions.

All

IsOrganizationTrail

boolean

No

Apakah akan membuat trail multi-akun. Nilai valid:

  • true

  • false (default)

Untuk membuat trail untuk organisasi, atur parameter ini ke true. Trail akan mengumpulkan event dari semua akun anggota dalam organisasi.

false

MaxComputeProjectArn

string

No

ARN proyek MaxCompute tempat ActionTrail mengirimkan event.

Catatan

Anda harus menentukan tujuan untuk trail dengan menyediakan setidaknya satu dari parameter berikut: OssBucketName, SlsProjectArn, atau MaxComputeProjectArn.

Catatan

Nama proyek dalam ARN harus diawali dengan actiontrail_.

acs:odps:cn-hangzhou:15127787691****:project/actiontrail_****

MaxComputeWriteRoleArn

string

No

ARN Peran RAM yang diasumsikan ActionTrail untuk mengirimkan event ke proyek MaxCompute.

  • Jika parameter ini tidak ditentukan, ActionTrail membuat service-linked role untuk mengirimkan event. Untuk informasi lebih lanjut, lihat Service-linked role ActionTrail.

  • Jika Anda menentukan peran, peran tersebut harus berupa Peran RAM yang Anda buat. Peran ini harus memiliki kebijakan kepercayaan yang mengizinkan layanan ActionTrail (`actiontrail.aliyuncs.com`) untuk mengasumsikannya. Kebijakan izin peran tersebut harus memberikan izin untuk menulis ke proyek MaxCompute yang ditentukan. Untuk informasi lebih lanjut tentang pengiriman lintas akun, lihat Mengirimkan event dari beberapa akun Alibaba Cloud ke akun yang sama.

acs:ram::15127787691****:role/aliyunserviceroleforactiontrail

Untuk informasi lebih lanjut, lihat Parameter umum.

Elemen respons

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 indicates that the trail processes events from all regions.

All

Contoh

Respons sukses

JSONformat

{
  "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"
}

Kode kesalahan

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.
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.
403 MaximumNumberOfTrailsExceededException The number of Trails in the same region exceeds the upper limit (5).
404 BucketDoesNotExistException The specified OSS bucket does not exist.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.