Mengelola penyimpanan rekaman aktivitas

Dokumen ini menjelaskan cara menggunakan Observability API untuk mendapatkan informasi tentang bucket kemampuan pengamatan yang menyimpan data rekaman aktivitas Anda. Bagian ini mencakup informasi tentang cara mencantumkan set data, link, dan tampilan. Untuk mengetahui informasi tentang cara penyimpanan data trace Anda, lihat Ringkasan penyimpanan trace.

Sebelum memulai

Konfigurasi project, peran IAM, dan pilih antarmuka yang akan Anda gunakan.

Mengonfigurasi project dan peran Anda

  1. Login ke akun Google Cloud Anda. Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Observability API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Observability API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  8. Untuk mendapatkan izin yang diperlukan guna membuat daftar bucket, link, dan tampilan, minta administrator untuk memberi Anda peran IAM Observability Viewer (roles/observability.viewer) di project Anda. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

    Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

Pilih antarmuka yang akan Anda gunakan

gcloud

Di konsol Google Cloud , aktifkan Cloud Shell.

Aktifkan Cloud Shell

Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

REST

Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, gunakan kredensial yang Anda berikan ke gcloud CLI.

    Instal Google Cloud CLI.

    Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

Untuk mengetahui informasi selengkapnya, lihat Melakukan autentikasi untuk menggunakan REST dalam dokumentasi autentikasi Google Cloud .

Mencantumkan bucket kemampuan observasi

gcloud

Sebelum menggunakan salah satu data perintah di bawah, lakukan penggantian berikut:

  • LOCATION: Lokasi bucket pengamatan. Untuk mencantumkan semua bucket kemampuan pengamatan, terlepas dari lokasi, tetapkan lokasi ke tanda hubung (-).
  • PROJECT_ID: ID project.

Jalankan perintah gcloud beta observability buckets list:

Linux, macOS, atau Cloud Shell

gcloud beta observability buckets list \
 --location=LOCATION --project=PROJECT_ID

Windows (PowerShell)

gcloud beta observability buckets list `
 --location=LOCATION --project=PROJECT_ID

Windows (cmd.exe)

gcloud beta observability buckets list ^
 --location=LOCATION --project=PROJECT_ID

Respons mencantumkan nama, deskripsi, dan waktu pembuatan setiap bucket pengamatan. Berikut adalah contoh respons saat perintah berhasil:

---
createTime: '2026-01-21T21:39:22.381083860Z'
description: Bucket for storing spans from Cloud Trace.
name: projects/my-project/locations/us/buckets/_Trace

REST

Untuk mencantumkan bucket pengamatan yang ada di project Anda dan di lokasi tertentu, kirim permintaan ke endpoint projects.locations.buckets.list.

Anda harus menentukan parameter induk, yang memiliki bentuk berikut:

projects/PROJECT_ID/locations/LOCATION

Kolom dalam ekspresi sebelumnya memiliki arti berikut: