Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara mengaktifkan dan memberikan otorisasi penggunaan
Monitoring API v3. Anda harus mengaktifkan API ini sebelum dapat menggunakannya.
Mengaktifkan Monitoring API
Untuk menentukan apakah Monitoring API diaktifkan atau untuk mengaktifkan
API, gunakan konsol Google Cloud atau Google Cloud CLI.
Google Cloud console
Di Google Cloud konsol, pilih Google Cloud project yang ingin Andaaktifkan API-nya, lalu buka halaman APIs & Services:
Di hasil penelusuran, klik "Stackdriver Monitoring API".
Jika "API enabled" ditampilkan, berarti API sudah diaktifkan. Jika
belum, klik Aktifkan.
gcloud CLI
Jika Anda belum menginstal Google Cloud CLI di
workstation, lihat
Menginstal gcloud CLI.
Untuk melihat apakah Monitoring API diaktifkan, jalankan perintah berikut di workstation Anda, setelah mengganti PROJECT_ID dengan ID project yang API-nya ingin Anda aktifkan:
gcloud services list --project=PROJECT_ID
Jika monitoring.googleapis.com muncul dalam output, API akan diaktifkan.
Jika API tidak diaktifkan, jalankan perintah berikut untuk mengaktifkannya:
Akses ke Monitoring API dikontrol oleh peran dan izin Identity and Access Management (IAM).
Ada izin yang terkait dengan setiap metode, dan izin untuk metode terkait dikelompokkan ke dalam peran, yang kemudian dapat diberikan kepada pengguna. Untuk mengetahui informasi selengkapnya, lihat
Mengontrol akses dengan IAM.
Setelah akses ke API diotorisasi, API dapat digunakan dari mana saja.
Misalnya, Anda dapat memanggil metode timeSeries.list
dari workstation lokal. Anda juga dapat menggunakan API untuk mengirim
metrik terhadap entitas apa pun yang dapat direpresentasikan sebagai resource yang dipantau.
Lihat Jenis resource yang dimonitor untuk metrik yang ditentukan pengguna
untuk mengetahui daftar jenis yang tersedia.
Jika Anda menulis aplikasi yang menggunakan
library klien yang direkomendasikan, library ini
akan memberikan otorisasi ke aplikasi Anda menggunakan
Kredensial Default Aplikasi.
Anda mungkin juga dapat menggunakan kunci API dalam beberapa situasi, tetapi akun layanan
umumnya direkomendasikan. Kunci API berguna di klien seperti browser dan aplikasi seluler yang tidak memiliki server backend.
Untuk informasi selengkapnya, lihat Menggunakan Kunci API.
Anda dapat mengetahui lebih lanjut tentang autentikasi dan otorisasi
di Panduan autentikasi kami.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-20 UTC."],[],[],null,["# Enable the Monitoring API\n\nThis page describes how to enable and authorize use of the\nMonitoring API v3. You must enable this API before you can use it.\n\nEnable the Monitoring API\n-------------------------\n\nTo determine whether the Monitoring API is enabled or to enable the\nAPI, use either the Google Cloud console or the Google Cloud CLI.\n\n\n### Google Cloud console\n\n1. In the Google Cloud console, select the Google Cloud project for\n which you want to enable the API,\n and then go to the **APIs \\& Services** page:\n\n [Go to **APIs \\& Services**](https://console.cloud.google.com/apis/dashboard)\n2. Click the **Enable APIs and Service** button.\n\n3. Search for \"Monitoring\".\n\n4. In the search results, click through to \"Stackdriver Monitoring API\".\n\n5. If \"API enabled\" is displayed, then the API is already enabled. If\n not, then click **Enable**.\n\n### gcloud CLI\n\n1. If you have not already installed the Google Cloud CLI on your\n workstation, see\n [Installing the gcloud CLI](/sdk/docs/install).\n\n2. To see if the Monitoring API is enabled, run the following\n command on your workstation, after replacing \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the\n ID of the project for which you want to enable the API:\n\n gcloud services list --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n If `monitoring.googleapis.com` appears in the output, the API is\n enabled.\n3. If the API is not enabled, then run the following command to enable it:\n\n gcloud services enable monitoring --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n For more information, see\n [`gcloud services`](/sdk/gcloud/reference/services).\n\n\u003cbr /\u003e\n\nAuthorize use of the Monitoring API\n-----------------------------------\n\nAccess to the Monitoring API is controlled by\nIdentity and Access Management (IAM) roles and permissions.\nThere is a permission associated with each method, and\npermissions for related methods are clustered into roles, which can then\nbe granted to users. For more information, see\n[Control access with IAM](/monitoring/access-control).\n\nAfter access to an API is authorized, the API can be used from anywhere.\nFor example, you can call the [`timeSeries.list`](/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)\nmethod from your local workstation. You can also use the API to send\nmetrics against any entity that can be represented as a monitored resource.\nSee [Monitored-resource types for user-defined metrics](/monitoring/custom-metrics#which-resource)\nfor the list of available types.\n\nIf you are writing an application that uses the\nrecommended [client libraries](/monitoring/docs/reference/libraries), these libraries\nauthorize your application by using\n[Application Default Credentials](/docs/authentication/production).\n\nYou might also be able to use API keys in some situations, but service accounts\nare generally recommended. API keys are useful in clients like\nbrowsers and mobile applications that don't have a backend server.\nFor more information, see [Using API Keys](/docs/authentication/api-keys).\n\nYou can find out more about authentication and authorization\nin our [Authentication guide](/docs/authentication/getting-started)."]]