1

I am trying to get AWS X-Ray working in a multi-container Beanstalk app as described in the docs. I found a community-built X-Ray container which I can run alongside my app: pottava/xray:2.0. According to docker stats and docker ps this container is running and receiving/sending network traffic (the traces are sent via UDP to the container). But there is no tracing data showing up in the AWS console.

I have not enabled X-Ray via a .ebextensions/ config file as suggested here. Trying this failed the deployment to Beanstalk. In fact, the multi-container environment is not listed as a supported platform. So while plenty of docs mention using X-Ray on Beanstalk, I am not sure if there is a way to configure this on my multi-Docker environment.

  • Can X-Ray configured in multi-Docker Beanstalk? If yes, how?
  • What's the best way to troubleshoot the collection & delivery of traces?
Ingo
  • 1,552
  • 10
  • 31

2 Answers2

2

The community-built Docker container to which you've linked should work as desired in AWS Elastic Beanstalk.

Have you added the necessary AWSXrayWriteOnlyAccess managed policy to your Elastic Beanstalk instance profile?

To further troubleshoot, please find the AWS X-Ray daemon logs from within the daemon's Docker container. The log will report any attempted calls to the PutTraceSegments API, as well as any errors which may result. In the linked Docker container, this file is located at /var/log/xray-daemon.log.

James Bowman
  • 151
  • 2
1
  • Can X-Ray configured in multi-Docker Beanstalk? If yes, how?

Yes, but it's not as simple as the X-ray daemon that can be enabled via .ebextensions as described in Running the X-Ray daemon on AWS Elastic Beanstalk. That won't work on Docker platforms (without significant networking hacks). According to the article, Elastic Beanstalk does not provide the X-Ray daemon on the Multicontainer Docker (Amazon ECS) platform. Also, it's worth noting that neither Docker platform is listed under Supported Platforms in the article, Configuring AWS X-Ray debugging.

For the Docker platform (Amazon Linux 2), you can use docker-compose to run the X-ray daemon in a container alongside your application. Here is a simple example of the docker-compose.yml that I use in a simple API app:

version: "3.9"
services:
    api: # my app instrumented with the AWS X-Ray SDK
        build: 
            context: .
            dockerfile: Dockerfile-awseb
        ports:
            - "80:3000"
        environment:
            - AWS_XRAY_DAEMON_ADDRESS=xray:2000
        env_file: .env
    xray:
        image: "amazon/aws-xray-daemon"

For the Multicontainer platform, the Scorekeep example in the article, Instrumenting Amazon ECS applications, shows a more elaborate example of instrumenting in a multicontainer Docker environment in Elastic Beanstalk.

  • What's the best way to troubleshoot the collection & delivery of traces?

Some high-level tips...

When using a supported platform, you might find additional guidance in Configuring AWS X-Ray debugging.

J. Christian
  • 495
  • 1
  • 7
  • 14
  • I found this out the hard way, while unsuccessfully attempting to use the [.ebextensions configuration for AWS X-ray daemon](https://docs.aws.amazon.com/xray/latest/devguide/xray-daemon-beanstalk.html) on a single-container Docker runtime. [This answer](https://stackoverflow.com/a/53980295) is a helpful example of working through that situation – J. Christian Apr 28 '21 at 17:36