Amazon EC2 and AWS App Mesh - AWS X-Ray

Amazon EC2 and AWS App Mesh

AWS X-Ray integrates with AWS App Mesh to manage Envoy proxies for microservices. App Mesh provides a version of Envoy that you can configure to send trace data to the X-Ray daemon running in a container of the same task or pod. X-Ray supports tracing with the following App Mesh compatible services:

  • Amazon Elastic Container Service (Amazon ECS)

  • Amazon Elastic Kubernetes Service (Amazon EKS)

  • Amazon Elastic Compute Cloud (Amazon EC2)

Use the following instructions to learn how to enable X-Ray tracing through App Mesh.

To configure the Envoy proxy to send data to X-Ray, set the ENABLE_ENVOY_XRAY_TRACING environment variable in its container definition.


The App Mesh version of Envoy does not currently send traces based on configured sampling rules. Instead, it uses a fixed sampling rate of 5% for Envoy version 1.16.3 or newer, or a 50% sampling rate for Envoy versions prior to 1.16.3.

Example Envoy container definition for Amazon ECS

{ "name": "envoy", "image": "", "essential": true, "environment": [ { "name": "APPMESH_VIRTUAL_NODE_NAME", "value": "mesh/myMesh/virtualNode/myNode" }, { "name": "ENABLE_ENVOY_XRAY_TRACING", "value": "1" } ], "healthCheck": { "command": [ "CMD-SHELL", "curl -s http://localhost:9901/server_info | cut -d' ' -f3 | grep -q live" ], "startPeriod": 10, "interval": 5, "timeout": 2, "retries": 3 }

To learn more about available Envoy region addresses, see Envoy image in the AWS App Mesh User Guide.

For details on running the X-Ray daemon in a container, see Running the X-Ray daemon on Amazon ECS. For a sample application that includes a service mesh, microservice, Envoy proxy, and X-Ray daemon, deploy the colorapp sample in the App Mesh Examples GitHub repository.