Google Cloud Console의 API 개요 페이지에서 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();