Debug School

viswanath reddy
viswanath reddy

Posted on

How to enable the APM for the Apache Tomcat Application and Visualize the Metrics in Datadog dashboard

Create a AWS Ec2 Instance

Login to to the AWS and check for the Ec2 service and launch the t2.medium instance.

Install the Datadog Agent

In the Datadog Dashboard --> Integrations --> Agent--> Select the Ubuntu and Use our easy one-step install.
DD_API_KEY= DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"

Install Java 11

$ sudo apt-get update
$ sudo apt-get install openjdk-11-jdk -y
$ apt install openjdk-11-jdk-headless -y

4 Install Apache Tomcat

$ sudo apt-get install wget unzip -y --> Unzip packge
$ sudo su -
$ cd /opt/
$ wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.73/bin/apache-tomcat-9.0.73.zip
$ unzip apache-tomcat-9.0.73.zip
$ cd apache-tomcat-9.0.73/bin
$ chmod -R 755 .
$ ls -ltr

Install the APM Agent

Go to Datadog dash board click on APM --> Setup &Configuration --> Service Setup --> Select Host-based --> Choose Your Language--> Java

$ cd /opt
$ mkdir datadog --> create directory to install the APM agent
$ cd datadog
$ wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'

Instrument your Application

Add the service name and environment in the details and enable required options for the application testing. Then Parameter's should be as below. After that code snippet as below.

java -javaagent:/opt/datadog/dd-java-agent.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.trace.sample.rate=1 -Ddd.appsec.enabled=true -Ddd.service=devops_school -Ddd.env=test -Ddd.version=1.0"

$ cd /opt/apache-tomcat-9.0.73/bin
$ vi catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/datadog/dd-java-agent.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.trace.sample.rate=1 -Ddd.appsec.enabled=true -Ddd.service=devops_school -Ddd.env=test -Ddd.version=1.0"

-Ddd.version=1.0 --> Ex: Added the Release version

$ systemctl restart datadog-agent
$ ./shutdown.sh
$ ./startup.sh
$ ps -eaf | grep tomcat | grep dd

Create a Traffic and Run the Traffic

For this we need to install the JMeter to run the traffic.
https://www.devopsschool.com/blog/how-to-install-and-configure-jemeter/

Visualize the Metrics in Datadog Dashboard

click on APM --> Services --> Click on service name and see the details i.e Error Tracking, Incidents, Latency, Traces

Under deployment --> Requests --> how many No. of requests are hitting in a period of time.
Under deployment --> p95Latency
Under deployment --> Errors

Top comments (0)