Monitoring performance for your serverless application ensures that your application is running all its processes as expected. To gain insight into your Lambda function performance and help you identify issues and opportunities for optimization, you can enable X-Ray tracing, also known as active tracing, for your Amazon Lambda functions. This monitoring feature uses Amazon X-Ray, a distributed tracing service in the AWS cloud that can help you to trace and analyze requests for performance issues and troubleshoot the requests that resulted in an error. Once the monitoring feature is enabled, Amazon Lambda sends trace data to Amazon X-Ray, and the X-Ray service processes the trace data to generate a service map with searchable trace summaries.
Remediation Steps
To enable X-Ray tracing for your Amazon Lambda function via AWS Management Console:
- Access the Amazon Lambda console at https://console.aws.amazon.com/lambda/ and choose Functions.
- Open the Amazon Lambda function that you want to configure.
- Choose the Configuration tab, select Monitoring and operations tools, and choose Edit.
- In the AWS X-Ray section, toggle the Active tracing button to enable active tracing with Amazon X-Ray.
- Choose Save to apply the changes. Amazon Lambda will automatically create an IAM role with the following permissions: "xray:PutTraceSegments", "xray:PutTelemetryRecords" to allow the cloud service to write to X-Ray.
Useful Links
- Amazon Lambda Service FAQs
- Using AWS Lambda with AWS X-Ray
- Configure Amazon Lambda functions
- update-function-configuration CLI command
- create-role CLI command
- attach-role-policy CLI command