Enable X-Ray tracing for Lambda functions
Enable X-Ray tracing for Lambda functions

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:

  1. Access the Amazon Lambda console at https://console.aws.amazon.com/lambda/ and choose Functions.
  2. Open the Amazon Lambda function that you want to configure.
  3. Choose the Configuration tab, select Monitoring and operations tools, and choose Edit.
  4. In the AWS X-Ray section, toggle the Active tracing button to enable active tracing with Amazon X-Ray.
  5. 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

  1. Amazon Lambda Service FAQs
  2. Using AWS Lambda with AWS X-Ray
  3. Configure Amazon Lambda functions
  4. update-function-configuration CLI command
  5. create-role CLI command
  6. attach-role-policy CLI command
Blog

Learn cloud security with our research blog