Skip to content

Streaming Logs: AWS Lambda


Overview

This topic describes how user may setup log streaming for web applications running on serverless runtime such as AWS Lambda.

Streaming Logs

Install Agent - AWS Lambda

CloudAEye SaaS console shows the instructions to setup agent for logs streaming.

To view the instructions in console, select Logs Services from the left navigation menu. User will see a list of logs services that are already created in the system. Click on the name of the logs service under Service Name column.

Configure App for Log Collection

Under Configure App for Log Collection section, select Lambda from the drop-down menu.

LambdaBasic

Provide the following information:

  • App Name: Name of your application
  • AWS Region: AWS region where your application is running
  • Function Names: Use * for all functions. Or, enter each function name and enter.
  • Collect CloudWatch Metrics: Enable check box if you want to collect lambda metrics of your application.
  • Metrics Collection Frequency: Select the metrics collection frequency from a drop-down of 1, 2, 5, 10 mins. Pick higher value if you are okay with less frequent metrics data collection and would like to reduce your AWS cost.

Click Create button. The agent setup instructions for Lambda will be shown. You may also click on the View Commands icon on the app to see the agent setup instructions.

Step 1: Download the script

LambdaStep1

You will see a command similar to the following:

curl -o aws_lambda_agent.py https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/lambda/scripts/aws_lambda_agent.py

Run this command on AWS CloudShell.

Step 2: Install boto3

LambdaStep2

Run the following command on AWS CloudStell.

pip3 install boto3 requests

Step 3: Install Agent

LambdaStep3

Run a command similar to the following on AWS CloudShell.

python3 aws_lambda_agent.py \
   --agent-mode create \
   --lambda-function-names 'CheckoutCart,MigrateCart,CartDBStream,ListCart,GetProduct,DeleteFromCart,GetCartTotal,UpdateCart,GetProducts,AddToCart' \
   --lambda-aws-region us-west-1 \
   --enable-logs 'true' \
   --cloud-env aws \
   --logs-destination http \
   --destination-http-url ${deatination-url} \
   --app-name 'ShoppingCart' \
   --app-key SHOPPINGCART \
   --service-name shoppingcart-logs \
   --user-tenant-key 104 \
   --user-key ${user-key} \
   --user-secret ${user-secret} \
   --collect-cloudwatch-metric false \
  --metrics-collection-frequency 1 \
  --collect-invocation-payloads false \
  --collect-cloudwatch-aws-srv-metrics true \
  --cloudwatch-aws-srv-metrics-collection-frequency 1
AWS Services Logs & Metrics

Please refer to AWS Services integrations to learn more.

Agent Details

Please refer to agent description under Troubleshooting section for details.

Troubleshooting

Please refer to log streaming description under Troubleshooting section for details.