AWS Lambda

Configuring Lambda

Monitoring Options

In this lesson, we explore how to monitor AWS Lambda using Amazon CloudWatch, Lambda Insights, AWS X-Ray, and VPC Flow Logs. These tools provide metrics, logs, and tracing to help troubleshoot and optimize serverless applications at scale.

Amazon CloudWatch Metrics

AWS Lambda automatically sends key performance metrics to Amazon CloudWatch, allowing you to track function execution, errors, and performance trends.

MetricDescriptionDefault
InvocationsTotal number of function calls✔️
DurationTime taken per invocation (in milliseconds)✔️
ErrorsNumber of failed invocations✔️
ThrottlesInvocations throttled due to concurrency limit
IteratorAgeLag time for stream-based event sources
DeadLetterErrorsFailures delivering to a dead-letter queue
ConcurrentExecutionsReal-time concurrency usage

Note

To collect additional metrics, enable enhanced monitoring in your function’s configuration or use AWS CLI / AWS SDKs to customize metric filters.

If you need an aggregated view across all functions, CloudWatch dashboards can display combined metrics and alert on threshold breaches:

The image is an informational slide about Amazon CloudWatch, detailing its automatic monitoring capabilities and additional metrics available, such as request numbers, duration, and concurrency limits.

Lambda Insights

Lambda Insights extends CloudWatch with deeper visibility into function behavior, resource utilization, and performance anomalies.

Key benefits:

  • Comprehensive dashboard for all functions in an AWS account or region
  • Detailed per-function views of CPU, memory, disk, and network usage
  • Customizable alerts on unusual trends or resource spikes

The image shows a dashboard from AWS Lambda Insights, displaying performance monitoring metrics such as invocations, errors, duration, throttles, memory usage, CPU usage, and network usage.

Use Lambda Insights to:

  • Troubleshoot individual functions efficiently
  • Analyze resource utilization over time
  • Detect performance bottlenecks and anomalies

AWS X-Ray Tracing

AWS X-Ray provides distributed tracing for end-to-end request analysis. By instrumenting your Lambda functions with X-Ray, you can:

  • Visualize service maps and trace requests through microservices
  • Measure latency and identify performance hotspots
  • Pinpoint errors across the execution flow

Warning

Enabling AWS X-Ray may incur additional costs and slight latency overhead. Evaluate tracing requirements before enabling in production.

The image is a slide about AWS X-ray, a monitoring and troubleshooting tool, highlighting features like visual mapping and identifying performance bottlenecks and errors.

VPC Flow Logs for Network Monitoring

To capture TCP/IP-level details such as source and destination IP addresses, use VPC Flow Logs. Since Lambda functions run outside your VPC by default, you must configure them to run within a VPC to generate flow logs.

Steps to enable:

  1. Attach your Lambda function to a VPC subnet and security group.
  2. Create a VPC Flow Log to an Amazon CloudWatch Logs group or Amazon S3 bucket.
  3. Analyze logs for network performance and security insights.

Note

Ensure your Lambda execution role has permissions for both VPC configuration and flow log creation (ec2:CreateFlowLogs, logs:CreateLogGroup, logs:PutLogEvents).

References

Watch Video

Watch video content

Previous
Limitations