Amazon Api Gateway Integration

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

Installation

If you haven’t already, set up the Amazon Web Services integration.

Metric collection

  1. On the AWS integration page, ensure that API Gateway is enabled under the Metric Collection tab.

  2. Add the following permissions to your Datadog IAM policy in order to get custom tags applied to API Gateway Stages:

    • apigateway:GET
    • tag:GetResources
  3. Install the Datadog - Amazon API Gateway integration.

Each of the metrics retrieved from AWS are assigned the same tags that appear in the AWS console, including but not limited to 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 will be incorrect.

Log collection

To enable API Gateway logging:

  1. Go to API Gateway in your AWS console.

  2. Select the wanted API and go to the Stages section.

  3. In the Logs tab, enable Enable CloudWatch Logs and Enable Access Logging.

  4. Select the INFO level to make sure you have all the requests.

  5. Make sure your CloudWatch Group name starts with api-gateway.

  6. Select the JSON format (CLF and CSV are also supported) and add the following in the Log format box:

    {
        "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
    }
    

Send logs to Datadog

  1. If you haven’t already, set up the Datadog log collection AWS Lambda function.
  2. 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 to start exploring your logs!

Data Collected

Metrics

See metric-spec.yaml for a list of metrics provided by this integration.

Events

The Amazon API Gateway integration does not include any events.

Service Checks

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

Troubleshooting

Need help? Contact Datadog support.