Amazon CloudWatch Lambda Insights
CloudWatch Lambda Insights is a monitoring and troubleshooting solution for serverless applications running on AWS Lambda. The solution collects, aggregates, and summarizes system-level metrics including CPU time, memory, disk, and network. It also collects, aggregates, and summarizes diagnostic information such as cold starts and Lambda worker shutdowns to help you isolate issues with your Lambda functions and resolve them quickly.
Learn more about Amazon CloudWatch Lambda Insights from our documentation.
Go back you your Cloud9 environment and open your app workspace at serverless-observability-workshop/code/sample-app.
We are going to edit the serverless-observability-workshop/code/sample-app/template.yaml file to include the Lambda Layer
containing the Lambda Insights Extension
for all Lambda
functions present in our template. Open the your YAML template and locate the Global section. Add the Layers
attribute for Lambda and specify the desired version of your extension.
Globals:
Function:
Runtime: nodejs12.x
Timeout: 100
MemorySize: 128
CodeUri: ./
Environment:
Variables:
APP_NAME: !Ref SampleTable
SAMPLE_TABLE: !Ref SampleTable
SERVICE_NAME: item_service
ENABLE_DEBUG: false
# Enable usage of KeepAlive to reduce overhead of short-lived actions, like DynamoDB queries
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
Layers: # <----- ADD FOR LAMBDA INSIGHTS
- !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14" # <----- ADD FOR LAMBDA INSIGHTS
Save your changes to the serverless-observability-workshop/code/sample-app/template.yaml file.
Learn more about all available Lambda Insights Extensions versions from our documentation.
cd ~/environment/serverless-observability-workshop/code/sample-app
sam build && sam deploy
In order to make sure Lambda Insights is properly setup, go to AWS Lambda service console.
Click your-function > Configuration > Monitoring tools and make sure Enhanced Monitoring
is enabled.