Giter Club home page Giter Club logo

logdna-s3's Introduction

LogDNA S3 Lambda Function

The integration with Amazon S3 relies on AWS Lambda to route your logs from S3 to LogDNA.

How to Use

Deploy the Code

  1. Create a new AWS 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
  • Minimum Runtime Version: Node.js.20.x

Configuration

General Configuration

If this function is being used to stream from gzipped files:

  1. Set Timeout to, at least, 30 seconds.
  2. Set Memory limit to, at least, 512 MB.

Notes:

  • The recommended number of retries is 0 because retrying lambda execution can result in duplicate logs. It can be modified in Configuration > Asynchronous invocation.
  • Timeout and Memory limit might need to be increased if the file size is too big.

Triggers

Add S3 as a trigger with the following configuration:

  • Specify the bucket you want to stream from.
  • Specify the event types you want to capture.
  • Optional prefix and suffix options are related to object paths within the specified bucket.

Notes:

  • This S3 Lambda function and S3 Bucket must be in the same availability zone.
  • You can specify a bucket in only one trigger and/or S3 Lambda function because a bucket accepts only one subscription but one S3 Lambda function can stream from multiple buckets at the same time.

Permissions

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

Environment Variables

Set INGESTION_KEY variable to your LogDNA ingestion key.

Notes:

  • For more information about required and optional environment variables, please, check out this.

Monitoring

Enabling monitoring means forwarding the metrics and logs about the execution of the S3 Lambda function to CloudWatch. You can also use logdna-cloudwatch to monitor the performance of this S3 Lambda function.

Test

You can test the configuration and code package using the following test input containing the bucket name and the path to the file you want to test the lambda on:

{
  "Records": [
    {
      "s3": {
        "bucket": {
          "name": "<bucket-name>"
        },
        "object": {
          "key": "<object-path>"
        }
      }
    }
  ]
}

Guide for Migrating from v1 to v2

If you have been using v1 and want to switch to using the newer versions, check out this guide

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!

logdna-s3's People

Contributors

logdnabot avatar mdeltito avatar gjanco avatar

Stargazers

zoe zhang avatar Asseel Naji avatar Rushal Verma avatar Jorge Bay avatar

Watchers

 avatar Eric Satterwhite avatar James Cloos avatar Muaz Siddiqui avatar Tony Rogers avatar Kristina Demeshchik avatar Sergey Opria avatar Chris Nixon avatar Kevin Chan avatar Vivek Shah avatar Braxton avatar Shannon Dennis avatar Mark Curtis avatar Tana M Berry avatar Mike Huang avatar  avatar Jonathan D Kelley avatar  avatar Phil Ciampini avatar Wei Zou avatar

logdna-s3's Issues

Runtime.ImportModuleError

I've uploaded the .zip file into a new lambda and set S3 as a trigger but getting this error when the lambda is invoked -

Response
{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module './utils/index.js'\nRequire stack:\n- /var/task/lib/transformer.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module './utils/index.js'",
    "Require stack:",
    "- /var/task/lib/transformer.js",
    "- /var/task/index.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:1063:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)",
    "    at Module.load (internal/modules/cjs/loader.js:928:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:769:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}

Screenshots of the configurations-
Screen Shot 2021-05-31 at 4 33 36 PM

Screen Shot 2021-05-31 at 4 33 26 PM

Add test coverage

After finishing #2, the unit and integration tests must be added to have, at least, 90%-95% coverage.

Replace utils with @logdna/stdlib methods

In order to improve stability further and avoid duplication on implementation, replacing getProperty, hasProperty, and setProperty implementations with, respectively, object.get, object.has, and object.set from @logdna/stdlib must be done!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.