Monitoring your API

This page describes how you can monitor the health of your API Gateway APIs using the logs and metrics that API Gateway maintains for you automatically.

When you create an API, API Gateway automatically creates a corresponding managed service. The name of the managed service created can be found in the output of the following command:

gcloud api-gateway apis describe API_ID

The name of your service is the value of the managedService field.

When users make requests to your API, API Gateway logs information about the requests and responses. API Gateway also tracks three of the four golden signals of monitoring: latency, traffic, and errors. These usage and performance metrics help you monitor your API.

Before you begin

To generate logs and metrics for viewing, deploy an API and send requests to it. If you have not created and deployed an API to a gateway yet, try the API Gateway quickstart.

API overview

When you are debugging an issue with your service or just want to ensure that everything is running as expected, go to your API's overview:

  1. In the Google Cloud Console, go to the API Gateway > APIs page for your project:

    Go to the APIs page

  2. If you have more than one API, click the one you want to monitor.

  3. Ensure you are on the Overview tab.


The overview page provides a number of graphs for some of the metrics, so you can spot any spikes, drops, or unexpected activity right away. Using the filters at the top of the page, you can:

  • Use the Select graphs drop-down list to show graphs for metrics you are interested in, and remove the ones you don't want to view.
  • Adjust the scope of the graphs by selecting from the various time spans. This adjusts the time range of values displayed, which also alters the point granularity.

Methods table

When you are ready to drill down further, scroll below the graphs for a table with metrics for individual methods in your API. You can:

  • In the top-left corner of the table, click the Filter Table icon to select refined filter query options from the drop-down table. Add an OR between each filter query to search for multiple terms.
  • In the top-right corner of the table, click on the Column Display Options icon to display a drop-down list. Check the metrics you are interested in and uncheck the ones you don't want displayed.
  • In the top-right corner of the Overview page, select a time span for the metric values in the table by using the time span picker. This picks a time span for both the graphs and the table.


When you spot an issue in the metrics, you can use the Logs Explorer page in the Google Cloud Console to see logs of the requests and responses for your API.

  • To see logs for individual methods of your API, in the table click View logs.

  • To see logs for all methods in your API, in the bottom-right corner click View all logs.

  • To locate API Gateway logs directly from the Logs Explorer page:

    1. In the Cloud Console, go to the Logs Explorer page:

      Go to the Logs Explorer page

    2. Select Produced API, SERVICE_NAME, where SERVICE_NAME is the name of the managed service.

See the API Gateway logs reference for details on the structure of the logs in the Logs Explorer.

Learn what else you can do with the logs:

  • Get started using the Logs Explorer.
  • Export your logs using the Cloud Console. This lets you stream logs to BigQuery for further analysis, save the raw logs to Cloud Storage, or send them to Pub/Sub messaging topics.
  • Use Advanced log filters to specify the set of log entries that you want to view, such as getting all requests with a latency greater than 300 milliseconds.

Filter for a specific consumer project

To filter metrics for a specific consumer project:

  1. Get the project number of the API consumer's project. If you don't have permission to access the API consumer's project, ask someone who has permission to get the project number for you.

  2. In the Cloud Console, go to the API Gateway > APIs page for your project.

    Go to the APIs page

  3. In the top-left corner of the Overview page, enter the project number in the Filter by Project Number field.

  4. Click Filter.

The metrics on the page update to reflect traffic only from the specified project.

What's next