This repository contains a solution for pushing log entries from an AWS CloudWatch log group to the Papertrail log management service (papertrailapp.com). The solution relies on the following AWS services:
See the following links for more information relating to the log subscription:
http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters.html
The solution mentioned above is provided as a Terraform module that can be used in your Terraform configuration to automatically create the necessary parts for this solution to run. If you are not using Terraform, you can use the code from this repository as a base for creating your own custom solution.
Note! This repository is provided under the MIT license and we make no guarantees about the safety of the source code that is located here. Please review the source code yourself before using the solution and don't blindly trust other people's code online.
To use the module with Terraform 0.11.x, add the segment below to your Terraform configuration:
module "cloudwatch-log-group-x-papertrail" {
source = "github.com/vaana-tech/cloudwatch-logs-to-papertrail//tf_module_0.11?ref=GIT_TAG_TO_USE"
monitor_log_group_names = ["/aws/lambda/my-lambda-function", "/aws/some/other/log/group/name"]
papertrail_host = "logsX.papertrailapp.com"
papertrail_port = "12345"
filter_pattern = FILTER_PATTERN | ""
timeout = "10"
lambda_log_role_arn = ARN_OF_LAMDA_ROLE_WITH_CW_LOGS_WRITE_PERMISSION
lambda_name_prefix = "MyLambdaFunction"
parse_log_levels = "true"
}
Note: Some of the variables have default values and don't need to be explicitly specified, check the tf_module_0.11/variables.tf
file for the default values.
To use the module with Terraform 0.12.x, do the same as for 0.11, but use the following source line instead:
source = "github.com/vaana-tech/cloudwatch-logs-to-papertrail//tf_module_0.12?ref=GIT_TAG_TO_USE"
ref
query parameter to refer to a specific tag in the repository, please check the CHANGELOG.md file for which versions are available and what has been updated in each versionpapertrail_host
and papertrail_port
parse_log_levels
functionality to parse out the log level from the cloudwatch log messages, you must use the npm winston simple log format that prefixes log entries with "LOGLEVEL:"This project was based on source code from this project: https://github.com/apiaryio/cloudwatch-to-papertrail