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
Navigate to AWS CloudFormation Console.
Log in to the console portal.
Select the required region in which you would like to deploy the layer.
Click the Create stack.
Under Specify template section, choose a stack template by using Amazon S3 URL:
https://lambda-extension-logs.s3.amazonaws.com/lambda-extension.yaml
.Click Next.
Enter a name for your stack in the Stack name field.
Configure any additional parameters required by the CloudFormation template and click Next.
Review the stack details including template settings and parameters.
Click Create stack to start the deployment process.
Create a Stack Using Quick-Create Links
Click Here and navigate to AWS console to create stack using quick create link.
Choose the AWS region where you want to deploy the Lambda layer.
After the stack creation is complete, navigate to the Outputs tab in the CloudFormation console.
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:
- Navigate to AWS CloudFormation Console.
- From the navigation pane on the left, choose StackSets.
- At the top of the StackSets page, click Create StackSet.
- On the Prepare template page, select Template is ready.
- Choose Template source as Amazon S3 URL. Enter the URL
https://lambda-extension-logs.s3.amazonaws.com/lambda-extension.yaml
for the CloudFormation template. - Click Next.
- Provide a name for your StackSet in the StackSet name field.
- Choose Next.
- 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.
- Click Next.
- 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:
- Choose the Lambda function to which you want to attach the Lambda layer.
- In the Lambda function configuration, scroll down to the “Layers” section.
- Click Add a layer.
- Choose Specify an ARN and paste the Lambda layer ARN that you copied earlier.
- Click Verify to validate the ARN.
- Click Add.
- In the Lambda function configuration, select the Configuration tab.
- Scroll down to the Environment variables section and click Edit.
- Click Add environment variable.
- Enter destURL as the key. Paste the HTTP endpoint to push logs to OpsRamp as the value.
- 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.