Enabling the Monitoring API

Before you can use the Monitoring API, you must enable it and authorize users to access it.

This page describes how to enable and authorize use of the Monitoring API v3.

Enabling the API

The Monitoring API must be enabled before it can be used. You can check the status and enable the API if necessary by using either the Cloud SDK gcloud command-line tool or the Cloud Console.

Cloud SDK

  1. If you have not already installed the Cloud SDK on your workstation, see Google Cloud SDK.

  2. To see if the Monitoring API is enabled, run the following command on your workstation:

    gcloud services list

    If monitoring.googleapis.com appears in the output, the API is enabled.

  3. If the API is not enabled, run the following command to enable it:

    gcloud services enable monitoring

For more information, see gcloud services.

Cloud Console

Go to APIs & services

  1. Select the project you will use to access the API.
  2. Click the Enable APIs and Service button.
  3. Search for "Stackdriver".
  4. In the search results, click through to "Cloud Monitoring API".
  5. If "API enabled" is displayed, then the API is already enabled. If not, click the Enable button.

Authorizing use of the API

Access to the API is controlled by Cloud Identity and Management roles and permission. There is a permission associated with each method, and permissions for related methods are clustered into roles, which can then be granted to users. See Access Control for more information.

If you are writing an application that uses the Monitoring API, the recommended client libraries authorize your application using Application Default Credentials. This hides authorization details from your application code.

You can find out more about authentication and authorization for Cloud APIs in our Authentication guide.

Using client libraries

After you have enabled and authorized the use of the API, you are ready to start writing code. See Client Libraries to get started using the Monitoring client libraries.