You can view the metrics for API calls in the
API overview page
of the Google Cloud console.
Finally, you can view the quota metrics for both API calls and function
execution in the API quotas page
of the Google Cloud console. You can set up alerting on quota errors in
Cloud Monitoring
by filtering executions that have an out of quota
value for the STATUS metric label. See Introduction to Alerting
for more information.
Reading metrics programmatically
The following snippet illustrates how you can also read metrics from your code.
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();
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-21 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."]]],[]]