Lambda Monitoring & X-Ray Tracing
Logging and Monitoring
- We can use CloudWatch Logs.
- Make sure you have IAM policy attached to your lambda to write into Cloudwatch logs
- We also have CloudWatch Metrics for AWS Lambda
- Invocations, durations, concurrent execution
- Error counts, failure, throttle, etc..
Tracing with X-Ray
- Enable in Lambda configuration (Active Tracing)
- Don't need to runs X-Ray daemon since Lambda does it for you
- Remember to use the X-Ray SDK and ensure that you have the correct Lambda Execution Role (IAM Role) to write to Xray
- managed policy:
AWSXrayDaemonWriteAccess
- managed policy:
- Environment variables to communicate with X-Ray
_X_AMZN_TRACE_ID
: contains tracing headersAWS_XRAY_CONTEXT_MISSING
: default set toLOG_ERROR
to prevent throwing exceptionAWS_XRAY_DAEMON_ADDRESS
: the X-Ray daemon IP_ADDRESS:PORT