This page describes how to enable and authorize use of the
Monitoring API v3. You must enable this API before you can use it.

## Enable the Monitoring API

To enable the Monitoring API, use either the Google Cloud console or
the Google Cloud CLI.

### Console


Enable the Cloud Monitoring API, if it is not already enabled.


**Roles required to enable APIs**


To enable APIs, you need the `serviceusage.services.enable` permission. If you
created the project, then you likely already have this permission through the
Owner role (`roles/owner`). Otherwise, you can get this permission through the
Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
[Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

[Enable the API](https://console.cloud.google.com/apis/enableflow?apiid=monitoring.googleapis.com)

<br />

### gcloud


Enable the Cloud Monitoring API, if it is not already enabled:


**Roles required to enable APIs**


To enable APIs, you need the `serviceusage.services.enable` permission. If you
created the project, then you likely already have this permission through the
Owner role (`roles/owner`). Otherwise, you can get this permission through the
Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
[Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

```bash
gcloud services enable monitoring.googleapis.com
```

<br />

## Authorize use of the Monitoring API

Access to the Monitoring API is controlled by
Identity and Access Management (IAM) roles and permissions.
There is a permission associated with each method, and
permissions for related methods are clustered into roles, which can then
be granted to users. For more information, see
[Control access with IAM](https://docs.cloud.google.com/monitoring/access-control.md.txt).

After access to an API is authorized, the API can be used from anywhere.
For example, you can call the [`timeSeries.list`](https://docs.cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list.md.txt)
method from your local workstation. You can also use the API to send
metrics against any entity that can be represented as a monitored resource.
See [Monitored-resource types for user-defined metrics](https://docs.cloud.google.com/monitoring/custom-metrics.md.txt#which-resource)
for the list of available types.

If you are writing an application that uses the
recommended [client libraries](https://docs.cloud.google.com/monitoring/docs/reference/libraries.md.txt), these libraries
authorize your application by using
[Application Default Credentials](https://docs.cloud.google.com/docs/authentication/production).

You might also be able to use API keys in some situations, but service accounts
are generally recommended. API keys are useful in clients like
browsers and mobile applications that don't have a backend server.
For more information, see [Using API Keys](https://docs.cloud.google.com/docs/authentication/api-keys.md.txt).

You can find out more about authentication and authorization
in our [Authentication guide](https://docs.cloud.google.com/docs/authentication/getting-started).