Using google-cloud-monitoring - client library to use gcp monitoring API
For explanation on these code samples, you can check out the blog series on GCP monitoring APIs -
- Creating custom monitoring metrics and dashboards on GCP console - https://medium.com/google-cloud/confused-with-custom-monitoring-metrics-on-gcp-c514cd4a776b
- Fetching monitoring metrics data from GCP - https://medium.com/google-cloud/fetching-monitoring-metrics-data-from-gcp-into-your-application-using-python-214358b0047e
- Using
pages
to paginate through your API response to get all data points in one request - https://medium.com/google-cloud/missing-data-points-in-your-monitoring-api-response-use-page-iterators-81d27e954c70