Before you start
Have the following information ready:- Your log source’s API key. If you do not have a log source yet, create a new log source first.
- The name of the existing CloudWatch log group you want to stream to AppSignal.
- The AWS region where the log group lives. Deploy the stack in the same region and account as the log group.
What the template creates
The CloudFormation template creates the following resources:- An S3 bucket to store records that fail to deliver, with server-side encryption, public access blocked, a 30-day lifecycle expiration, and a retain-on-delete policy.
- An IAM role that allows Amazon Data Firehose to write failed records to the S3 bucket and to write its own delivery error logs to CloudWatch.
- A Firehose delivery stream that sends logs to the AppSignal endpoint over HTTPS.
- An IAM role that allows CloudWatch Logs to write to the Firehose delivery stream.
- A CloudWatch log subscription filter on your existing log group that forwards log events to the Firehose delivery stream.
CloudFormation template
Copy the following template and save it asappsignal-cloudwatch-logs.yaml:
The
logs:PutLogEvents statement allows Firehose to write its own delivery error logs to CloudWatch. It targets the Firehose error log group (/aws/kinesisfirehose/<STREAM_NAME>), which is separate from the log group you want to stream to AppSignal. See Controlling access with Amazon Data Firehose for more details.Deploy the stack
- Open the AWS CloudFormation console.
- Select Create stack and choose With new resources (standard).
- Under Specify template, select Upload a template file and upload
appsignal-cloudwatch-logs.yaml. - Select Next.
- Enter a stack name, for example
appsignal-cloudwatch-logs. - For LogSourceApiKey, enter your log source’s API key.
- For CloudWatchLogGroupName, enter the exact name of the log group you want to stream.
- Select Next twice, then check I acknowledge that AWS CloudFormation might create IAM resources and select Submit.
Verify the deployment
- In the AWS Console, search for “CloudFormation” and select Stacks. Open your stack and select the Resources tab to confirm all resources show CREATE_COMPLETE.
- In the AWS Console, search for “CloudWatch”. In the left sidebar, open your log group and select the Subscription filters tab to confirm the
AppSignalfilter is listed. - In the AWS Console, search for “Firehose”. Open the delivery stream and use the Test with demo data function to verify connectivity.
- In AppSignal, open the log management screen and confirm log entries from your log group appear there.
Multi-region deployments
The template must be deployed in the same region and account as the CloudWatch log group. If you have log groups in multiple regions, deploy a separate copy of this stack in each region.Clean up
To remove all resources created by this template, delete the stack in the CloudFormation console. The S3 bucket for failed deliveries has aDeletionPolicy of Retain, so it is kept when the stack is deleted to avoid losing any failed delivery records. Failed delivery records in the bucket are automatically deleted after 30 days by the lifecycle rule. You can delete the bucket manually once you no longer need it.