Skip to content

AWS Lambda function for sending AWS CloudWatch logs to Logentries

License

Notifications You must be signed in to change notification settings

omgapuppy/le-aws-cloudwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

le-aws-cloudwatch

AWS Lambda function for sending AWS CloudWatch logs to Logentries in near real-time for processing and analysing
Example use cases:

Obtain log token(s)

  1. Log in to your Logentries account
  2. Add a new token based log
    • Optional: repeat to add second log for debugging

Deploy the script on AWS Lambda

  1. Create a new Lambda function

  2. On the "Select Blueprint" screen, press "Skip"

  3. Configure function:

    • Give your function a name
    • Set runtime to Python 2.7
  4. Edit code:

    • Edit the contents of le_config.py
    • Replace values of log_token and debug_token with tokens obtained earlier.
    • Create a .ZIP file, containing the updated le_config.py, le_cloudwatch.py and the folder certifi
      • Make sure the files and certifi folder are in the root of the ZIP archive
    • Choose "Upload a .ZIP file" in "Code entry type" dropdown and upload the archive created in previous step
  5. Lambda function handler and role

    • Change the "Handler" value to le_cloudwatch.lambda_handler
    • Create a new basic execution role (your IAM user must have sufficient permissions to create & assign new roles)
  6. Allocate resources:

    • Set memory to 128 MB
    • Set timeout to ~2 minutes (script only runs for seconds at a time)
  7. Enable function:

    • Click "Create function"

Configure CloudWatch Stream

  1. Create a new stream:

    • Select CloudWatch log group
    • Navigate to "Actions / Stream to AWS Lambda"

    Stream to Lambda

  2. Choose destination Lambda function:

    • Select the AWS Lambda function deployed earlier from drop down menu
    • Click "Next" at the bottom of the page

    Select Function

  3. Configure log format:

    • Choose the correct log format from drop down menu
    • Specify subscription filter pattern
    • Click "Next" at the bottom of the page

    Log Format

  4. Review and start log stream

    • Review your configuration and click "Start Streaming" at the bottom of the page

    Start stream

  5. Watch your logs come in:

About

AWS Lambda function for sending AWS CloudWatch logs to Logentries

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages