---
title: Amazon API Gateway Integration
description: Amazon API Gateway is a managed service for APIs.
breadcrumbs: Docs > Integrations > Amazon API Gateway Integration
---

# Amazon API Gateway Integration

## Overview{% #overview %}

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.

Enable this integration to see all of your API Gateway metrics in Datadog.

## Setup{% #setup %}

### Installation{% #installation %}

If you haven't already, set up the [Amazon Web Services integration](https://docs.datadoghq.com/integrations/amazon_web_services/).

### Metric collection{% #metric-collection %}

1. On the [AWS integration page](https://app.datadoghq.com/integrations/amazon-web-services), ensure that `API Gateway` is enabled under the `Metric Collection` tab.

1. Add the following permissions to your [Datadog IAM policy](https://docs.datadoghq.com/integrations/amazon_web_services/#installation) in order to get custom tags applied to API Gateway Stages:

   - `apigateway:GET`
   - `tag:GetResources`

1. Install the [Datadog - Amazon API Gateway integration](https://app.datadoghq.com/integrations/amazon-api-gateway).

Each of the metrics retrieved from AWS is assigned the same tags that appear in the AWS console, including host name, security-groups, and more.

**Note**: If you've enabled detailed CloudWatch metrics, you must enable them for all Resources or Routes within a Stage. Otherwise, aggregate values in Datadog are incorrect.

### Log collection{% #log-collection %}

To enable API Gateway logging:

1. Go to API Gateway in your AWS console.
1. Select the desired API.
1. Click **Stages**.
1. In the **Logs and Tracing** section, click the **Edit** button.
1. Enable CloudWatch logs for either `Errors only` or `Errors and info logs`.
1. Click to enable **Custom access logging**.
1. In **Access log destination ARN**, enter the Amazon Resource Name (ARN) of the CloudWatch Log group you want to receive your logs.
1. In the **Log format** box, enter the following on a single line:

```json
{"apiId":"$context.apiId","stage": "$context.stage","requestId":"$context.requestId","ip":"$context.identity.sourceIp","caller":"$context.identity.caller","user":"$context.identity.user","requestTime":"$context.requestTimeEpoch","httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath","status":"$context.status","protocol":"$context.protocol","responseLength":"$context.responseLength"}
```
Click **Save**.
#### Send logs to Datadog{% #send-logs-to-datadog %}

**Note**: Datadog's [automatic trigger setup](https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/?tab=awsconsole#automatically-set-up-triggers) is available for CloudWatch log groups only. For S3 buckets, use the [manual trigger setup](https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-s3-buckets).

1. If you haven't already, set up the [Datadog log collection AWS Lambda function](https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function).
1. Once the Lambda function is installed, manually add a trigger on the CloudWatch Log group that contains your API Gateway logs in the AWS console. Select the corresponding CloudWatch Log group, add a filter name (but feel free to leave the filter empty) and add the trigger.

Once completed, navigate to the [Logs page](https://app.datadoghq.com/logs) to start exploring your logs!

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **aws.apigateway.4xx**(count)                          | The number of client-side errors for HTTP APIs*Shown as operation*                                                                                                                                                  |
| **aws.apigateway.4xxerror**(count)                     | The number of client-side errors for REST APIs*Shown as operation*                                                                                                                                                  |
| **aws.apigateway.5xx**(count)                          | The number of server-side errors for HTTP APIs*Shown as operation*                                                                                                                                                  |
| **aws.apigateway.5xxerror**(count)                     | The number of server-side errors for REST APIs*Shown as operation*                                                                                                                                                  |
| **aws.apigateway.cache\_hit\_count**(count)            | The number of requests served from the API cache*Shown as operation*                                                                                                                                                |
| **aws.apigateway.cache\_miss\_count**(count)           | The number of requests served from the back end when API caching is enabled*Shown as operation*                                                                                                                     |
| **aws.apigateway.client\_error**(count)                | The average number of requests that have a 4XX response returned by API Gateway before the integration is invoked.*Shown as operation*                                                                              |
| **aws.apigateway.client\_error.sum**(count)            | The total number of requests that have a 4XX response returned by API Gateway before the integration is invoked.*Shown as operation*                                                                                |
| **aws.apigateway.connect\_count**(count)               | The average number of messages sent to the $connect route integration.*Shown as operation*                                                                                                                          |
| **aws.apigateway.connect\_count.sum**(count)           | The total number of messages sent to the $connect route integration.*Shown as operation*                                                                                                                            |
| **aws.apigateway.count**(count)                        | The number call to API methods*Shown as operation*                                                                                                                                                                  |
| **aws.apigateway.execution\_error**(count)             | Average errors that occurred when calling the integration.*Shown as operation*                                                                                                                                      |
| **aws.apigateway.execution\_error.sum**(count)         | Total errors that occurred when calling the integration.*Shown as operation*                                                                                                                                        |
| **aws.apigateway.integration\_error**(count)           | The average number of requests that return a 4XX/5XX response from the integration.*Shown as operation*                                                                                                             |
| **aws.apigateway.integration\_error.sum**(count)       | The total number of requests that return a 4XX/5XX response from the integration.*Shown as operation*                                                                                                               |
| **aws.apigateway.integration\_latency**(gauge)         | The time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                                         |
| **aws.apigateway.integration\_latency.maximum**(gauge) | The maximum time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                                 |
| **aws.apigateway.integration\_latency.minimum**(gauge) | The minimum time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                                 |
| **aws.apigateway.integration\_latency.p90**(gauge)     | The 90th percentile time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                         |
| **aws.apigateway.integration\_latency.p95**(gauge)     | The 95th percentile time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                         |
| **aws.apigateway.integration\_latency.p99**(gauge)     | The 99th percentile time between when API Gateway relays a request to the back end and when it receives a response from the back end.*Shown as millisecond*                                                         |
| **aws.apigateway.latency**(gauge)                      | The time between when API Gateway receives a request from a client and when it returns a response to the client. The latency includes the integration_latency and other API Gateway overhead.*Shown as millisecond* |
| **aws.apigateway.latency.maximum**(gauge)              | The maximum time between when requests are received and when responses returned*Shown as millisecond*                                                                                                               |
| **aws.apigateway.latency.minimum**(gauge)              | The minimum time between when requests are received and when responses returned*Shown as millisecond*                                                                                                               |
| **aws.apigateway.latency.p50**(gauge)                  | The 50th percentile time between when requests are received and when responses returned*Shown as millisecond*                                                                                                       |
| **aws.apigateway.latency.p75**(gauge)                  | The 75th percentile time between when requests are received and when responses returned*Shown as millisecond*                                                                                                       |
| **aws.apigateway.latency.p90**(gauge)                  | The 90th percentile time between when requests are received and when responses returned*Shown as millisecond*                                                                                                       |
| **aws.apigateway.latency.p95**(gauge)                  | The 95th percentile time between when requests are received and when responses returned*Shown as millisecond*                                                                                                       |
| **aws.apigateway.latency.p99**(gauge)                  | The 99th percentile time between when requests are received and when responses returned*Shown as millisecond*                                                                                                       |
| **aws.apigateway.message\_count**(count)               | The average number of messages sent to the WebSocket API, either from or to the client.*Shown as operation*                                                                                                         |
| **aws.apigateway.message\_count.sum**(count)           | The total number of messages sent to the WebSocket API, either from or to the client.*Shown as operation*                                                                                                           |

### Events{% #events %}

The Amazon API Gateway integration does not include any events.

### Service Checks{% #service-checks %}

The Amazon API Gateway integration does not include any service checks.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).
