API 呼び出しの指標は、Google Cloud コンソールの API の概要ページで確認できます。
Google Cloud コンソールの API 割り当てページで、API 呼び出しと関数実行の両方の割り当て指標を確認できます。STATUS 指標ラベルの out of quota 値が割り当て量を超えている実行をフィルタすることで、Cloud Monitoring で割り当てエラーのアラートを設定できます。詳細については、アラートの概要をご覧ください。
プログラムで指標を読み取る
次のスニペットは、コードから指標を読み取る方法を示しています。
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();
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-25 UTC。"],[[["You can view Cloud Run function metrics like execution times, counts, and memory usage in the Google Cloud console and Cloud Monitoring."],["Metrics for API calls can be viewed on the API overview page in the Google Cloud console."],["Quota metrics for API calls and function execution are available in the API quotas page of the Google Cloud console."],["You can set up alerts for quota errors in Cloud Monitoring by filtering executions with an `out of quota` status."],["Metrics can also be read programmatically from your code using the Google Cloud client library, as shown in the provided Node.js example."]]],[]]