Example workflows using other Amazon services - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Example workflows using other Amazon services

Amazon Lambda integrates with other Amazon services to help you monitor, trace, debug, and troubleshoot your Lambda functions. This page shows workflows you can use with Amazon X-Ray and Amazon Trusted Advisor to trace and troubleshoot your Lambda functions.


The following section describes the steps to using Amazon X-Ray and Trusted Advisor to troubleshoot your Lambda functions.

Using Amazon X-Ray

Amazon X-Ray needs to be enabled on the Lambda console to complete the Amazon X-Ray workflows on this page. If your execution role does not have the required permissions, the Lambda console will attempt to add them to your execution role.

To enable Amazon X-Ray on the Lambda console
  1. Open the Functions page of the Lambda console.

  2. Choose your function.

  3. Choose the Configuration tab.

  4. On the Monitoring tools pane, choose Edit.

  5. Under Amazon X-Ray, turn on Active tracing.

  6. Choose Save.

Using Amazon Trusted Advisor

Amazon Trusted Advisor inspects your Amazon environment and makes recommendations on ways you can save money, improve system availability and performance, and help close security gaps. You can use Trusted Advisor checks to evaluate the Lambda functions and applications in your Amazon account. The checks provide recommended steps to take and resources for more information.


  • With Amazon X-Ray you pay only for what you use, based on the number of traces recorded, retrieved, and scanned. For more information, see Amazon X-Ray Pricing.

  • Trusted Advisor cost optimization checks are included with Amazon Business and Enterprise support subscriptions. For more information, see Amazon Trusted Advisor Pricing.

Example Amazon X-Ray workflow to view a trace map

If you've enabled Amazon X-Ray, you can view a trace map on the CloudWatch console. A trace map displays your service endpoints and resources as nodes and highlights the traffic, latency, and errors for each node and its connections.

You can choose a node to see detailed insights about the correlated metrics, logs, and traces associated with that part of the service. This enables you to investigate problems and their effect on an application.

To view trace map and traces using the CloudWatch console
  1. Open the Functions page of the Lambda console.

  2. Choose a function.

  3. Choose Monitoring.

  4. Choose View X-Ray traces.

  5. Choose Trace Map under X-Ray traces from the left navigation pane.

  6. Choose from the predefined time ranges, or choose a custom time range.

  7. To troubleshoot requests, choose a filter.

Example Amazon X-Ray workflow to view trace details

If you've enabled Amazon X-Ray, you can use the single-function view on the CloudWatch Lambda Insights dashboard to show the distributed trace data of a function invocation error. For example, if the application logs message shows an error, you can open the trace map to see the distributed trace data and the other services handling the transaction.

To view trace details of a function
  1. Open the single-function view in the CloudWatch console.

  2. Choose the Application logs tab.

  3. Use the Timestamp or Message to identify the invocation request that you want to troubleshoot.

  4. To show the Most recent 1000 invocations, choose the Invocations tab.

    Sorting the most recent 1000 invocations by request ID.
  5. Choose the Request ID column to sort entries in ascending alphabetical order.

  6. In the Trace column, choose View.

    The Trace details page opens in the trace map view.

    Function trace details in the trace map view.

Example Amazon Trusted Advisor workflow to view recommendations

Trusted Advisor checks Lambda functions in all Amazon Regions to identify functions with the highest potential cost savings, and deliver actionable recommendations for optimization. It analyzes your Lambda usage data such as function execution time, billed duration, memory used, memory configured, timeout configuration and errors.

For example, the Lambda Functions with High Error Rate check recommends that you use Amazon X-Ray or CloudWatch to detect errors with your Lambda functions.

To check for functions with high error rates
  1. Open the Trusted Advisor console.

  2. Choose the Cost Optimization category.

  3. Scroll down to Amazon Lambda Functions with High Error Rates. Expand the section to see the results and the recommended actions.

What's next?