Set up AWS API Gateway Logging with AWS Lambda

Created:
March 13, 2023
Updated:
September 19, 2024

The AWS API Gateway Logging with AWS Lambda integration automates the collection and analysis of logs from your AWS API Gateway, giving you valuable insights into performance and issues for better monitoring and troubleshooting.

This integration uses AWS Lambda to handle log data, and a CloudFormation template deploys the required resources and configurations. Once set up, logs are sent to CloudWatch, where FireTail processes them for analysis.

To start logging, the integration must be attached to each relevant API. You can also create the integration directly from the APIs section in the FireTail platform by following the Create an API Gateway Logging Integration from an API instructions provided in this article.

Note: If you create the integration directly from an API, it is automatically attached to that API, and logging begins immediately.

Create an API Gateway logging integration

1. Navigate to Integrations in the FireTail platform. Select the Create Integration tab.

2. Click FireTail API Gateway logging with AWS Lambda.

3. In the Name of Integration field, enter a name for the integration.

4. Select the AWS Region to deploy the integration to.

5. Select an application from the dropdown, or click Create to create a new application. This is the application that will be associated with the integration. Learn more about applications here.

6. Under App Token, click Create to create a token. Enter a name for the token. Click OK. Copy the app token. This is needed when the template is launched.

7. Log in to AWS.

8. In FireTail, click Launch CloudFormation to launch the template. This opens in a new window.

9. Paste the app token into the FTKEY field.

10. Select the checkboxes. Click Create.

11. When the CloudFormation Stack has a status of CREATE_COMPLETE, copy the FiretailRoleARN and the FiretailCloudwatchARN from the Outputs tab.

12. Paste the above data into the AWS Cloudwatch group ARN and AWS Role Arn fields respectively.

13. Click Submit.

Attach the integration to an API

When the integration has been created you must attach it to every API Gateway API that you want the logging for. This needs to be done for logging to start.

Note: The integration must be attached to an API Gateway and App that have been populated with APIs, or the logs will not correlate and won’t get saved.

To attach an integration:

1. Navigate to APIs in the FireTail platform. Select the appropriate AWS API.

2. Click the Logging tab.

Note: If a logging integration has not already been attached to the API, a message is displayed on the platform indicating this.

3. Click Update Logging.

4. Select the previously created integration from the Select an Integration dropdown.

5. Select the relevant stage from the Select a Stage dropdown.

6. Click OK.

Repeat these steps for every API and stage you want to add the integration to.

Create an API Gateway logging integration from an API

This integration can also be created from the APIs area of the FireTail platform.

To do this:

1. Navigate to APIs in the FireTail platform. Select the appropriate AWS API.

2. Click the Logging tab.

3. Click Update Logging.

4. Click Create to set up an integration

5. Fill out the integration form as detailed above from step 3 in the Create an API Gateway logging integration instructions. Note: The Region and Application fields are pre-filled with the correct data extracted from the API.

6. When the integration is created, select the relevant stage from the Select a Stage dropdown.

7. Click OK.