AWS CloudWatch
Cloudwatch Insights X Ray and Service Map
Demo Setting up X Ray with a Sample Application
In this guide, you’ll learn how to deploy a demo app on AWS, instrument it with AWS X-Ray, and analyze traces and service maps in Amazon CloudWatch. By the end, you’ll have end-to-end visibility into a microservices architecture using HTTP endpoints, ECS, and DynamoDB.
Prerequisites
- An AWS account with permissions for CloudWatch, X-Ray, CloudFormation, ECS, DynamoDB, and IAM
- AWS CLI or Console access
Note
Make sure your IAM user or role has the required permissions for deploying CloudFormation stacks and viewing X-Ray service maps.
Step 1: Deploy the Sample Application via CloudFormation
- Log in to the AWS Console and open CloudWatch.
- In the left sidebar, expand X-Ray Traces and select Service Map.
- Click Setup Demo App, then choose Create Sample Application with CloudFormation.
- Proceed through the wizard without changing defaults:
- Next → Next
- Acknowledge IAM capabilities → Submit
This creates a CloudFormation stack named xray-sample
.
Warning
The demo stack provisions ECS clusters, an Application Load Balancer, and DynamoDB tables. You may incur AWS charges—remember to delete the stack when you're done.
Step 2: Wait for Stack Completion
Monitor the stack events and wait until the status changes to CREATE_COMPLETE.
Step 3: Retrieve the Load Balancer URL
- Once complete, switch to the Outputs tab.
- Copy the LoadBalancerUrl value.
Step 4: Launch the Scorekeep Web App
Paste the LoadBalancerUrl into your browser to open the Scorekeep application.
Step 5: Create and Play a Game Session
- Click Create.
- Enter a session name (e.g., “ABC Tools Tic-Tac-Toe”).
- Click Create, then Play.
Play several rounds of tic-tac-toe. AWS X-Ray collects traces for every request behind the scenes.
Step 6: View the Service Map
- In the Scorekeep UI, click View Service Map.
- This opens the X-Ray console displaying your microservices topology.
Drill Into Nodes and Traces
- Select any node (e.g., DynamoDB for user data).
- View metrics, latency distributions, and HTTP metadata.
- Click View traces to access individual X-Ray segments.
Opening a specific trace reveals each segment’s timeline:
Here you’ll see:
- A
GET
call to the Scorekeep endpoint - The corresponding GetItem action on DynamoDB
- Latency and HTTP status codes for each segment
This full-stack visibility helps you pinpoint latency spikes, errors, and resource bottlenecks.
AWS X-Ray Key Components
Resource | Purpose | AWS Service |
---|---|---|
ECS Container | Hosts the Scorekeep application | Amazon ECS |
Load Balancer | Routes HTTP traffic to containers | Application Load Balancer |
DynamoDB Table | Stores game session and move data | Amazon DynamoDB |
SNS Topic | Publishes game events notifications | Amazon SNS |
Best Practices
- Enable X-Ray tracing in production by integrating the AWS X-Ray SDK into your code.
- Use sampling rules to control data volume and cost.
- Tag resources for trace grouping and filtering.
Note
Regularly review your service map to detect anomalies and optimize the performance of microservices.
References
Watch Video
Watch video content