Skip to content

Latest commit

 

History

History
84 lines (55 loc) · 3.12 KB

README.md

File metadata and controls

84 lines (55 loc) · 3.12 KB

Serverless le-aws-cloudwatch

serverless

Deploy the LogentriesCommunity le-aws-cloudwatch project using the Serverless Framework. Stream AWS Lambda and other CloudWatch logs to Logentries.

Created by the LogentriesCommunity, le-aws-cloudwatch is an AWS Lambda function written in Python that is invoked by CloudWatch stream events and pushes the corresponding CloudWatch logs to Logentries.

Prerequisites

  • Serverless Framework installed or available via CICD
  • The token for a token based log set up in Logentries
  • The name of the log in CloudWatch to process (i.e. /aws/lambda/my-function)

Deployment

Deploy le-aws-cloudwatch from the command line using arguments:

serverless deploy --le-region eu --le-token abcd1234 --cw-log /aws/lambda/my-function

Depending on your workflow you can also deploy using environment variables:

export LOGENTRIES_REGION=eu
export LOGENTRIES_TOKEN=abcd1234
export CLOUDWATCH_LOG=/aws/lambda/my-function
export CICD_REGION=ap-southeast-2

serverless deploy

Options

Argument Environment Variable Description
le-region LOGENTRIES_REGION The Logentries account region, currently only eu
le-token LOGENTRIES_TOKEN The log token generated by Logentries that will be streamed to
cw-log CLOUDWATCH_LOG The Cloudwatch log to stream to Logentries

Working with Multiple CloudWatch Logs

As it is highly likely that you will want to process multiple CloudWatch logs we recommend using the name of the CloudWatch log file as the stage argument from the command line:

serverless deploy --le-region eu --le-token abcd1234 --cw-log /aws/lambda/my-function --stage my-function

The stage name must be unique for each function and environment.

Note: If the combined service name (le-cw), stage parameter (my-function) and region (ap-southeast-2) exceed 64 characters you may receive an error similar to:

An error occurred: IamRoleLambdaExecution - 1 validation error detected: Value 'le-cw-my-very-very-really-really-long-function-name-ap-southeast-2-lambdaRole' at 'roleName' failed to satisfy constraint: Member must have length less than or equal to 64.

If this occurs the ony option is to shorten your stage name. This is the reason we have kept the service name short (le-cw).

Merging the le-aws-cloudwatch Dependency

If the le-aws-cloudwatch dependency changes then those changes can be merged in using a Git Subtree Merge.

Step 1 - Add le-aws-cloudwatch as a remote
git remote add -f le-aws-cloudwatch https://github.com/LogentriesCommunity/le-aws-cloudwatch.git
Step 2 - Pull in the changes from le-aws-cloudwatch
git subtree pull --prefix=le-aws-cloudwatch/ le-aws-cloudwatch master --squash

Then push the changes or if you have created a fork open a pull request.