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
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.
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:
In the Google Cloud Console, go to the API Gateway > APIs page for your project:
If you have more than one API, click the one you want to monitor.
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.
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
ORbetween 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 Viewer 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 Viewer page:
In the Cloud Console, go to the Logs Viewer page:
Select Produced API,
SERVICE_NAMEis the name of the managed service.
See the API Gateway logs reference for details on the structure of the logs in the Logs Viewer.
Learn what else you can do with the logs:
- Get started using the Logs Viewer.
- Export your logs using the logs Viewer. 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:
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.
In the Cloud Console, go to the API Gateway > APIs page for your project.
In the top-left corner of the Overview page, enter the project number in the Filter by Project Number field.
The metrics on the page update to reflect traffic only from the specified project.