0

How can I use the command-line interface for GCP and download metrics such as utilization, autoscaling and backlogs via gcloud?

Baiqing
  • 1,223
  • 2
  • 9
  • 21

1 Answers1

0

There seems to be no available gcloud command yet to retrieve Cloud Monitoring metrics through command-line interface.

On the other hand, you may use the cURL command approach for this.

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) "https://monitoring.googleapis.com/v3/projects/<projectID>/timeSeries?interval.startTime=2022-01-31T13:45:46-05:00&interval.endTime=2022-02-02T14:05:06-05:00&filter="metric.type=\"dataflow.googleapis.com/job/total_vcpu_time\"%20AND%20resource.labels.job_name=\"<job-name>\"""

You may use your desired Time Series followed by your desired Metric Type. You may also add additional parameters like the JobName/instance (just like my sample script) depending on your desired output by using the documetnation I provided as reference.

Scott B
  • 2,516
  • 1
  • 8
  • 15