Skip to content

ECS-EC2

Splunk APM Trace Generator Demo For AWS ECS EC2

This repo demonstrates a reference implemenation for a single AWS ECS EC2 task example of Splunk APM that will send spans directly to Splunk Observability Cloud.

ECS works very simply: just add the environment variables required by the Otel APM Instrumentation and the Instrumentation will do the rest.

To deploy this example, you must have an ECS environment ready to go with VPC, task roles for logs, etc. Instructions are below:


Setup

Configure ECS CLI Profile:

ecs-cli \
configure profile \
--access-key YOURAWSKEYHERE \
--secret-key YOURAWSSECRETKEYHERE \
--profile-name ecs-ec2-profile

Configure ECS EC2 Cluster:

configure ECS Cluster Config:
ecs-cli configure \
--cluster test-cluster \
--config-name test-cluster \
--region YOURREGIONHEREi.e.:us-east-1

Deploy ECS EC2 Cluster:

ecs-cli up \
--cluster test-cluster \
--region YOURREGIONHEREi.e.:us-east-1\
--size 1 \
--capability-iam \
--instance-type t2.xlarge \
--launch-type EC2 \
--ecs-profile test-profile \
--force


Deploy Task

Deploy with the following commands- you must change the variables in caps in these task .json files to suit your environment:

aws ecs register-task-definition \
--cli-input-json file://tracegen-java-otel-ecs-ec2.json

Note that the task definition will increment each time you try it- from 1 to 2 etc. To check which version is current use:

aws ecs list-task-definitions

Deploy trace generator task to cluster:

aws ecs create-service \
--cluster test-cluster \
--launch-type EC2 \
--scheduling-strategy DAEMON \
--service-name tracegen-java-otel-ecs-ec2 \
--task-definition tracegen-java-otel-ecs-ec2:VERSIONHEREi.e.1

After a few seconds check Splunk APM to see the trace generator service.


Cleanup

aws ecs delete-service --cluster test-cluster --service tracegen-java-otel-ecs-ec2 --force
ecs-cli down \
--cluster test-cluster \
--region us-east-1
aws ecs delete-cluster --cluster test-cluster


Extras

The ecs-cli-commands.md file offers helpful commands for ECS Fargate management for the AWS CLI.

Back to top