Set up AWS API Gateway Logging with AWS Lambda

Created:
March 13, 2023
Updated:
April 15, 2024

This integration sets up logging resources in an AWS account region with AWS Lambda. To initiate logging, the created integration must be attached to each necessary API.

Alternatively, you can create the integration directly from the APIs section of the FireTail platform by following the Create an API Gateway logging integration from an API instructions in this article. Note: Creating the integration from an API automatically attaches it to that specific API, enabling logging to commence immediately for that API.

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.