Getting Started with Google Cloud Monitoring
Enable the API
Before you can begin monitoring a project, you must enable the Google Cloud Monitoring API in the Google Developers Console and create a client ID to allow your sample app to connect to the Google APIs. This document assumes you are testing the sample on
- If you don’t already have one, sign up for a Google Account.
- Enable the Google Cloud Monitoring API in the Developers Console. You can choose an existing Compute Engine or App Engine project, or you can create a new project.
http://localhost:8080. Click Create Client ID.
- Note the following information in the project that you will need to input in later steps:
- The client ID (
- The project ID that you wish to monitor. You can find the ID at the top of the project’s Overview page in the Google Developers Console. You could also ask your user to provide the project ID that they want to monitor in your app.
- The client ID (
Now that the API is enabled for your project, you will configure your app to access the REST API on behalf of a user.
Authorize the requests
https://www.googleapis.com/auth/monitoring.readonly grants your app access to the Cloud Monitoring API data.
In a real-world app, you might choose to use a service account and backend code to request monitoring data.
Request authorization from the user and get an access token.
Now that your app has an access token, you are ready to query the Cloud Monitoring API to retrieve time series data.
Get time series data points
Now that your app has an access token, it can retrieve monitoring data for a project. You will want to decide which types of metrics you want to monitor. This quick example looks for time series directly rather than discovering available resources by using the
The simple examples in this document demonstrate how to get started quickly with the Cloud Monitoring API. Your app will likely need to perform more complex queries, store results, and possibly parse the data on your own backend. Get more information about the following topics: