Jika Anda membuat fungsi baru, lihat Panduan Memulai Konsol di Cloud Run. Konten di halaman ini hanya berlaku untuk fungsi lama yang sudah ada yang dibuat dengan Cloud Functions v1 API.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Melihat metrik dan kuota
Melihat metrik di konsol
Anda dapat melihat fungsi Cloud Run beserta waktu eksekusi, jumlah eksekusi, dan penggunaan memorinya di konsolGoogle Cloud . Metrik ini juga tersedia di
Cloud Monitoring,
tempat Anda dapat menyiapkan pemberitahuan kustom pada metrik ini. Lihat dokumentasi Cloud Monitoring untuk mengetahui informasi selengkapnya.
Anda dapat melihat metrik untuk panggilan API di
halaman ringkasan API
di konsol Google Cloud .
Terakhir, Anda dapat melihat metrik kuota untuk panggilan API dan eksekusi fungsi di halaman kuota API di konsol Google Cloud . Anda dapat menyiapkan pemberitahuan terkait error kuota di Cloud Monitoring dengan memfilter eksekusi yang memiliki nilai out of quota untuk label metrik STATUS. Lihat Pengantar Pemberitahuan untuk mengetahui informasi selengkapnya.
Membaca metrik secara terprogram
Cuplikan berikut menggambarkan bagaimana Anda juga dapat membaca metrik dari kode Anda.
Node.js
// Imports the Google Cloud client libraryconstmonitoring=require('@google-cloud/monitoring');// Creates a clientconstclient=newmonitoring.MetricServiceClient();asyncfunctionreadTimeSeriesData(){/** * TODO(developer): Uncomment and edit the following lines of code. */// const projectId = 'YOUR_PROJECT_ID';// const filter = 'metric.type="compute.googleapis.com/instance/cpu/utilization"';constrequest={name:client.projectPath(projectId),filter:filter,interval:{startTime:{// Limit results to the last 20 minutesseconds:Date.now()/1000-60*20,},endTime:{seconds:Date.now()/1000,},},};// Writes time series dataconst[timeSeries]=awaitclient.listTimeSeries(request);timeSeries.forEach(data=>{console.log(`${data.metric.labels.instance_name}:`);data.points.forEach(point=>{console.log(JSON.stringify(point.value));});});}readTimeSeriesData();
[[["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-09-03 UTC."],[[["\u003cp\u003eYou can view Cloud Run function metrics like execution times, counts, and memory usage in the Google Cloud console and Cloud Monitoring.\u003c/p\u003e\n"],["\u003cp\u003eMetrics for API calls can be viewed on the API overview page in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eQuota metrics for API calls and function execution are available in the API quotas page of the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eYou can set up alerts for quota errors in Cloud Monitoring by filtering executions with an \u003ccode\u003eout of quota\u003c/code\u003e status.\u003c/p\u003e\n"],["\u003cp\u003eMetrics can also be read programmatically from your code using the Google Cloud client library, as shown in the provided Node.js example.\u003c/p\u003e\n"]]],[],null,["# View metrics and quotas\n=======================\n\nViewing metrics in the console\n------------------------------\n\nYou can [view your Cloud Run functions](https://console.cloud.google.com/functions/list)\nwith their execution times, execution counts, and memory usage in the\nGoogle Cloud console. These metrics are also available in\n[Cloud Monitoring](https://console.cloud.google.com/monitoring),\nwhere you can set up custom alerting on these metrics. See the\n[Cloud Monitoring documentation](/monitoring/docs) for more information.\n\nYou can view the metrics for API calls in the\n[API overview page](https://console.cloud.google.com/apis/api/cloudfunctions.googleapis.com/overview)\nof the Google Cloud console.\n\nFinally, you can view the quota metrics for both API calls and function\nexecution in the [API quotas page](https://console.cloud.google.com/apis/api/cloudfunctions.googleapis.com/quotas)\nof the Google Cloud console. You can set up alerting on quota errors in\n[Cloud Monitoring](https://console.cloud.google.com/monitoring)\nby filtering executions that have an `out of quota`\nvalue for the `STATUS` metric label. See [Introduction to Alerting](/monitoring/alerts)\nfor more information.\n\nReading metrics programmatically\n--------------------------------\n\nThe following snippet illustrates how you can also read metrics from your code. \n\n### Node.js\n\n // Imports the Google Cloud client library\n const monitoring = require('https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html');\n\n // Creates a client\n const client = new monitoring.https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html();\n\n async function readTimeSeriesData() {\n /**\n * TODO(developer): Uncomment and edit the following lines of code.\n */\n // const projectId = 'YOUR_PROJECT_ID';\n // const filter = 'metric.type=\"compute.googleapis.com/instance/cpu/utilization\"';\n\n const request = {\n name: client.projectPath(projectId),\n filter: filter,\n interval: {\n startTime: {\n // Limit results to the last 20 minutes\n seconds: Date.now() / 1000 - 60 * 20,\n },\n endTime: {\n seconds: Date.now() / 1000,\n },\n },\n };\n\n // Writes time series data\n const [timeSeries] = await client.listTimeSeries(request);\n timeSeries.forEach(data =\u003e {\n console.log(`${data.metric.labels.instance_name}:`);\n data.points.forEach(point =\u003e {\n console.log(JSON.stringify(point.value));\n });\n });\n }\n readTimeSeriesData();"]]