Introduction

AWS Lambda allows you to stream logs directly to various AWS services like Amazon CloudWatch Logs for easy monitoring and troubleshooting of your serverless applications.

Create Lambda layer using AWS Cloudformation stack

To create a Lambda layer using AWS CloudFormation stack, you have two methods as described below:

Create stack using AWS CloudFormation console

  1. Navigate to AWS CloudFormation Console.

  2. Log in to the console portal.

  3. Select the required region in which you would like to deploy the layer.

  4. Click the Create stack.

  5. Under Specify template section, choose a stack template by using Amazon S3 URL: https://lambda-extension-logs.s3.amazonaws.com/lambda-extension.yaml.

  6. Click Next.

  7. Enter a name for your stack in the Stack name field.

  8. Configure any additional parameters required by the CloudFormation template and click Next.

  9. Review the stack details including template settings and parameters.

  10. Click Create stack to start the deployment process.

  1. Click Here and navigate to AWS console to create stack using quick create link.

  2. Choose the AWS region where you want to deploy the Lambda layer.

  3. After the stack creation is complete, navigate to the Outputs tab in the CloudFormation console.

  4. Copy the Lambda layer ARN provided in the outputs for future reference or use.

Create Lambda layer in multiple regions

To create a Lambda layer in multiple regions using AWS CloudFormation StackSet, follow these detailed steps:

  1. Navigate to AWS CloudFormation Console.
  2. From the navigation pane on the left, choose StackSets.
  3. At the top of the StackSets page, click Create StackSet.
  4. On the Prepare template page, select Template is ready.
  5. Choose Template source as Amazon S3 URL. Enter the URL https://lambda-extension-logs.s3.amazonaws.com/lambda-extension.yaml for the CloudFormation template.
  6. Click Next.
  7. Provide a name for your StackSet in the StackSet name field.
  8. Choose Next.
  9. For Execution configuration, choose Active to allow StackSets to perform non-conflicting operations concurrently and queue conflicting operations.
    • Accounts: Under “Deploy stacks in accounts”, paste the target AWS account numbers into the text box, separating multiple numbers with commas.
    • Regions: Under “Specify regions”, select the AWS regions where you want to deploy the Lambda layer stacks. You can select multiple regions, including the same region where the StackSet is being created.
    • Maximum concurrent accounts: Keep the default setting of “Number” and “1”. This means AWS CloudFormation will deploy your stack in only one account at a time.
    • Failure tolerance: Keep the default setting of “Number” and “0”. This allows for a maximum of one stack deployment failure per specified region before AWS CloudFormation stops deployment in that region and cancels deployment in remaining regions.
  10. Click Next.
  11. Review the stack set details and choose Create stack set.

Attach the Lambda layer to Lambda function

To attach a Lambda layer to a Lambda function and configure environment variables, follow below steps:

  1. Choose the Lambda function to which you want to attach the Lambda layer.
  2. In the Lambda function configuration, scroll down to the “Layers” section.
  3. Click Add a layer.
  4. Choose Specify an ARN and paste the Lambda layer ARN that you copied earlier.
  5. Click Verify to validate the ARN.
  6. Click Add.
  7. In the Lambda function configuration, select the Configuration tab.
  8. Scroll down to the Environment variables section and click Edit.
  9. Click Add environment variable.
  10. Enter destURL as the key. Paste the HTTP endpoint to push logs to OpsRamp as the value.
  11. After adding the environment variable, click Save to update the Lambda function configuration.

Supported Labels

When integrating AWS Lambda logs with OpsRamp, the following labels can be used to categorize and manage your log data effectively:

  • extResourceId
  • owner
  • resourceType

Resource identification

In order to identify the resource, you ned to add the extResourceId and resourceType labels in the group by field in the log alert definition.