Live:CloudOps Webinars & Hands-on Workshops ·Register ↗
Skip to main content

Lambda Monitoring

Overview​

Monitor AWS Lambda functions using CloudWatch native integration, X-Ray distributed tracing, and Lambda Insights for enhanced performance visibility. This solution requires zero external agents — it leverages built-in AWS capabilities.

Key observability features:

  • Invocation metrics (duration, errors, throttles, concurrency)
  • X-Ray traces for downstream call visibility
  • Lambda Insights for memory, CPU, and network metrics
  • Structured logging with embedded metric format (EMF)
  • Cost-per-invocation tracking
Needs refresh

This entry leads with Lambda Insights and native CloudWatch metrics. It predates the current recommendation and does not cover:

  • CloudWatch Application Signals for Lambda, which provides service-level latency, error rate, and dependency mapping
  • The AWS-managed OpenTelemetry Lambda layers for OTLP export
  • Transaction Search for trace-level analysis

The steps below still work and Lambda Insights remains useful for memory and cold-start analysis. Prefer Application Signals as the starting point for new functions.

Prerequisites​

  • AWS Lambda function(s) deployed
  • IAM execution role with AWSXRayDaemonWriteAccess (for tracing)
  • Lambda Insights layer ARN for your region
  • CloudWatch Logs enabled (default)

Architecture​

Lambda observability architecture with API Gateway integration

┌───────────────────────────────────────────────────┐
│ Lambda Function │
│ │
│ ┌────────────────┐ ┌──────────────────────────┐│
│ │ Function Code │ │ Lambda Insights Extension ││
│ │ + X-Ray SDK │ │ (Lambda Layer) ││
│ └───────┬────────┘ └────────────┬─────────────┘│
└──────────┼─────────────────────────┼──────────────┘
│ │
┌─────▼─────┐ ┌─────▼──────┐
│ X-Ray │ │ CloudWatch │
│ Traces │ │ Metrics + │
│ │ │ Logs │
└───────────┘ └────────────┘

Deploy​

Step 1: Enable X-Ray tracing​

aws lambda update-function-configuration \
--function-name my-function \
--tracing-config Mode=Active

Step 2: Add Lambda Insights layer​

aws lambda update-function-configuration \
--function-name my-function \
--layers "arn:aws:lambda:us-west-2:580247275435:layer:LambdaInsightsExtension:52"

Step 3: Add IAM permissions​

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"xray:PutTraceSegments",
"xray:PutTelemetryRecords"
],
"Resource": "*"
}
]
}

In your function code, emit metrics via Embedded Metric Format:

from aws_lambda_powertools import Logger, Metrics, Tracer

logger = Logger()
metrics = Metrics(namespace="MyApp")
tracer = Tracer()

@logger.inject_lambda_context
@metrics.log_metrics
@tracer.capture_lambda_handler
def handler(event, context):
metrics.add_metric(name="OrderProcessed", unit="Count", value=1)
# your logic here

Validate​

CloudWatch dashboard showing Lambda invocation metrics

X-Ray distributed trace map for Lambda function

Lambda Insights showing memory and CPU utilization

Lambda structured logging flow diagram

  1. Invoke your function:

    aws lambda invoke --function-name my-function output.json
  2. Check CloudWatch metrics: Navigate to CloudWatch > Metrics > AWS/Lambda.

  3. Check X-Ray traces: Navigate to CloudWatch > X-Ray traces > Trace map.

  4. Check Lambda Insights: Navigate to CloudWatch > Insights > Lambda Insights.

Troubleshoot​

SymptomLikely CauseFix
No traces in X-RayTracing not set to ActiveCheck function config
Lambda Insights no dataLayer not attachedVerify layer ARN matches region
High duration reportedCold startsEnable provisioned concurrency or SnapStart
Missing custom metricsEMF format errorValidate JSON structure in logs