cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Abhi.Bajaj
AppDynamics Team

In this article we will try to get your ECS Java application monitored by AppDynamics Java Agent.
For starters I am assuming you have an application ready, if not a sample tomcat application image will be used in our task definition file.

{
"family": "aws-opensource-otel",
"containerDefinitions": [

##### Application image
{
"name": "aws-otel-emitter",
"image": "docker.io/abhimanyubajaj98/tomcat-app-buildx:latest",
"cpu": 0,
"portMappings": [
{
"name": "aws-otel-emitter",
"containerPort": 8080,
"hostPort": 8080,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [
{
"name": "APPDYNAMICS_AGENT_ACCOUNT_NAME",
"value": "XXXXX"
},
{
"name": "APPDYNAMICS_AGENT_TIER_NAME",
"value": "abhi-tomcat-ecs"
},
{
"name": "APPDYNAMICS_CONTROLLER_PORT",
"value": "443"
},
{
"name": "JAVA_TOOL_OPTIONS",
"value": "-javaagent:/opt/appdynamics/javaagent.jar"
},
{
"name": "APPDYNAMICS_AGENT_APPLICATION_NAME",
"value": "abhi-ecs-fargate"
},
{
"name": "APPDYNAMICS_CONTROLLER_HOST_NAME",
"value": "XXXXX.saas.appdynamics.com"
},
{
"name": "APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME_PREFIX",
"value": "abhi-tomcat-ecs"
},
{
"name": "APPDYNAMICS_CONTROLLER_SSL_ENABLED",
"value": "true"
},
{
"name": "APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY",
"value": "XXXXX"
},
{
"name": "APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME",
"value": "true"
}
],
"mountPoints": [],
"volumesFrom": [
{
"sourceContainer": "appdynamics-java-agent"
}
],
"dependsOn": [
{
"containerName": "appdynamics-java-agent",
"condition": "START"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "True",
"awslogs-group": "/ecs/ecs-aws-otel-java-tomcat-app",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs"
}
},
"healthCheck": {
"command": [
"CMD-SHELL",
"curl -f http://localhost:8080/sample || exit1"
],
"interval": 300,
"timeout": 60,
"retries": 10,
"startPeriod": 300
}
},

#####Java Agent configuration
{
"name": "appdynamics-java-agent",
"image": "docker.io/abhimanyubajaj98/java-agent-ecs",
"cpu": 0,
"portMappings": [],
"essential": false,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/java-agent-ecs",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs"
}
}
}
],
"taskRoleArn": "arn:aws:iam::778192218178:role/ADOTRole",
"executionRoleArn": "arn:aws:iam::778192218178:role/ADOTTaskRole",
"networkMode": "bridge",
"requiresCompatibilities": [
"EC2"
],
"cpu": "256",
"memory": "512"
}

You will need to edit all the sections with “XXXXX”

Your ECS task should have the appropriate permission. In my case I created a taskRole ADOTRole and taskexecutionrole ADOTTaskRole. The permission.
The policy for ADOTRole looks like->

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:PutLogEvents",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:DescribeLogGroups",
"logs:PutRetentionPolicy",
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries",
"cloudwatch:PutMetricData",
"ec2:DescribeVolumes",
"ec2:DescribeTags",
"ssm:GetParameters"
],
"Resource": "*"
}
]
}

The policy for ADOTTaskRole looks like ->

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:PutLogEvents",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:DescribeLogGroups",
"logs:PutRetentionPolicy",
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries",
"cloudwatch:PutMetricData",
"ec2:DescribeVolumes",
"ec2:DescribeTags",
"ssm:GetParameters"
],
"Resource": "*"
}
]
}

Going back to the template, you can build your own image as well. The dockerfile for the image can be found here along with task definition file
https://github.com/Abhimanyu9988/ecs-java-agent

To understand more about AppDynamics Java Agent, Please refer to below document->
https://docs.appdynamics.com/appd/22.x/22.12/en/application-monitoring/install-app-server-agents/jav...

For any queries, you can reach out to me on LinkedIn or simply post your question on github.

Version history
Last update:
‎03-15-2024 09:35 AM
Updated by:
On-Demand Webinar
Discover new Splunk integrations and AI innovations for Cisco AppDynamics.


Register Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here
Contributors