logdna / logdna-cloudwatch

AWS Lambda for logging from CloudWatch into LogDNA
MIT License
12 stars 19 forks source link
aws-cloudwatch aws-lambda cloudwatch cloudwatch-logs devops logdna logdna-cloudwatch logging

LogDNA CloudWatch Lambda Function

The LogDNA AWS CloudWatch integration relies on AWS Lambda to route your CloudWatch Logs to LogDNA.

How to Use

Deploy the Code

  1. Create a new Lambda function and select Author from scratch
  2. Click on the Lambda function to edit the details:
    • Code entry type: Upload a .ZIP file
    • Upload our LogDNA Lambda function .ZIP File.
    • Handler: index.handler
    • Runtime: Node.js 20.x

Configuration

General Configuration

If the S3 Lambda is being used to stream from gzipped files:

  1. Set Timeout to, at least, 10 seconds.
  2. Set Memory limit to, at least, 128 MB.

Notes:

Triggers

Add CloudWatch Logs as a trigger with the following configuration:

Notes:

Permissions

For Execution role, assign a role that has the following policies:

Environment Variables

Set LOGDNA_KEY variable to your LogDNA ingestion key. Optionally, you can use the following environment variables:

Notes: The following optional environment variables can also be used to tune this Lambda function for specific use cases.

Monitoring

Enabling monitoring means forwarding the metrics and logs about the execution of the CloudWatch Lambda function to CloudWatch. You can also create and use a separate CloudWatch Lambda function to monitor the performance of this CloudWatch Lambda function.

Test

You can test the configuration and code package using the following test input containing the sample event data:

{
    "awslogs": {
        "data": "H4sIAAAAAAAAEzWQQW+DMAyF/wrKmaEkJCbhhjbWCzuBtMNUVSmkNBIQRMKqqep/X6Cb5Ivfs58++45G7ZzqdfMza5Sjt6IpTh9lXReHEsXI3ia9BJnQlHHIhMSEBnmw/WGx6xwcp8Z50M9uN2q/aDUGx2vn/5oYufXs2sXM3tjp3QxeLw7lX6hS47lTz6lTO9i1uynfXkOMe5lsp9Fxzyy/9eS3hTsyXYhOGVCaEsBSgsyEYBkGzrDMAIMQlAq+gQIQSjFhBFgqJOUMAog34WAfoFFOOM8kA0Y5SSH+f0SIb67GRaHq/baosn1UmUlHF7tErxvk5wa56b2Z+iRJ0OP4+AWj9ITzSgEAAA=="
    }
}

License

Copyright © LogDNA, released under an MIT license. See the LICENSE file and https://opensource.org/licenses/MIT

Contributing

Contributions are always welcome. See the contributing guide to learn how you can help.

Happy Logging!