cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to create an agent for my java application

alfredo_iglesia
Participant

2018-09-28-115147.png2018-09-28-115115.pngI have created a simple application with spring boot, consisting of a login and a CRUD, I packaged the application in a .jar, I would like what is the best way to create the agents that allow me to monitor. All the Java agents that I think appear disconnected in the Agent Overview.

I'm using the appmon trial.

Thanks


14 REPLIES 14

kyle_kowalski
Dynatrace Pro
Dynatrace Pro

When starting your Java file up you will need to add the argument as an additional parameter, I'm unsure of the exact syntax but I would guess its something like 'java -jar MYFILE.jar -agentpath<agentpathstring>'


BabarQayyum
Leader

Hello @Alfredo Iglesias S.

e.g. to instrument a Java application with a default installation of AppMon, all on one machine and all 64-bit, and the Agent mapping into the mySystemProfile, add one the following

-agentpath:C:\Program Files\dynaTrace\dynaTrace 7.0\agent\lib64\dtagent.dll=name=Java_mySystemProfile,collector=localhost

Have a look on the below link for better understanding.

https://www.dynatrace.com/support/doc/appmon/insta...

Regards,

Babar


I've tried several ways and I haven't been able...
Could it be that the JVM in which I am creating the agent is 64 bit and not 32?


Thanks for the help and apologies for the delay.


Can you look at the agent log file as it tries to start up, I believe its in <DTHOME>/agent/log


alfredo_iglesia
Participant

Hello @Alfredo Iglesias S.

In the screenshots, one thing is confusing that why the application is in the Dynatrace Agent folder. Secondly, do you have a different server for the collector or using the same one (AppMon Server)?

For Tomcat 7.x or later, it is recommend to configure environment variables in the setenv.bat or setenv.sh script located in CATALINA_BASE/bin or CATALINA_HOME/bin.

Have a look on the below link for more insight.

https://www.dynatrace.com/support/doc/appmon/installation/application-integration/apache-tomcat/

Also I would recommend to have a look on the below performance clinic.

https://www.youtube.com/watch?v=J4FbYIzixN8&index=3&list=PLqt2rd0eew1bmDn54E2_M2uvbhm_WxY_6

Regards,

Babar


alfredo_iglesia
Participant

Hello Babar Q,

First thank you for your patience.

The .jar is already out of Dynatrace Agent folder, it was a mistake on my part...


I think for the collector, I use the Appmon server, I'm not sure, the name of the server is the same as my computer (mc0yzqbc), in that aspect I didn't touch anything and I'm using the default configuration. I only have one server to choose from.


Regarding the application (manolito) is made in eclipse STS and with Spring boot; this uses its own server, ie not even have installed Tomcat or Apache in a "conventional" (or at least I can not find ...:( ). In the workspace there is a directory (Servers) containing Pivotal tc Server Developer Edition v4.0-config (dir), in which there are configuration files, so I'm confused about the setenv.bat.....I don't know where to create it.

Should I download Tomcat and Apache and install it?

Regards

eclipsests-portable-folder.png

pivotal-tc-server-developer-edition-v40-config.png


Hello @Alfredo Iglesias S.

I am not much aware about the application 'manolito' but you can follow the instructions from the below link to monitor the Java Spring Boot applications.

https://www.dynatrace.com/support/doc/appmon/installation/set-up-agents/java-agent-configuration/?_ga=2.191737002.108466200.1541914142-2117912594.1541409766

Following are the steps required to instrument the Apache Tomcat:

  • e.g. Dynatrace variable needs to be entered in the setenv.sh file in CATALINA_BASE/bin
    or CATALINA_HOME/bin which in your case we
    assume is /opt/apache/tomcat7.0/bin/
  • Create a shell script named setenv.sh if it
    doesn’t exist and once created add the below line to the
    setenv.sh file
CATALINA_OPTS="$CATALINA_OPTS -agentpath:/opt/apm/dynatrace-7.0/agent/lib64/libdtagent.so=name=agent_name,server=collector_server:9998"; export CATALINA_OPTS
  • Once
    added kindly restart TomCat for changes to take effect.
  • If
    Tomcat picks up then we should be able to see the agent connected on Dynatrace.
    If not we may need to try to incorporate the lines in the startup.sh script itself
  • Custom
    Tomcat installations behave differently depending on customization and we may
    need to try different methods and entry formats until Tomcat picks up the
    Dynatrace entries.

Regards,

Babar


sjoerd1
Advisor

Hi,

You are using an embedded TomCat, so no need to first download tomcat etc.

Maybe you can change the order of your java command, to:

java -agentpath:.... -jar manolito-....

because the agentpath is an option to java, not an argument to your jarfile.

Once AppMon starts connecting, and it finds issues, it will also write log details in the agentlog file which you can find in the .....\agent\lib64\logs directory.

Good luck!

Regards,

Sjoerd


alfredo_iglesia
Participant

Hello

I have installed a 2.4 apache and a tomcat 8.5 on the computer, packaged my application in a .war and will deploy it on the tomcat.

The agent of the Web Server I think I connected it, but the one of the tomcat I'm not able....and I think I've followed all your instructions, I send you screenshots of the last things I did.
The error appears in the cmd capture.

Will the license have anything to do with it?


It's frustrating.


Greetings

2018-11-12-192616.png

2018-11-12-192637.png

2018-11-12-192651.png

2018-11-12-192703.png

2018-11-12-192739.png

2018-11-12-192751.png

2018-11-12-193227.png


sjoerd1
Advisor

In the last image you just start java -agentpath .... without any command for java to execute... That's why java complains that it cannot load any archive. So no licensing issue.

Did you try to start (without apache and tomcat etc) by just typing the commands in the correct order (as I mentioned in my earlier comment)?

You can just execute the java command:

java -agentpath:<your agentpath> -jar <your manolito jarfile>

Of course you can also install tomcat separately, but that only adds complexity if you just want to testdrive, as you then need to understand the workings of TomCat as well.


Just to add a little to the previous comment:

The -agentpath option is to load the dynaTrace Appmon agent as a native part into the JVM, while starting your own application. So it is not a standalone process that hooks into your jvm, but an integral part of the JVM that runs your application.

In the logfile you can see the lines containing [native], that indicate that the agent is being loaded, but then, since you didn't supply the command to start your application in the same jvm (by e.g. the -jar command), the jvm terminates with the error that it has nothing to do.


alfredo_iglesia
Participant

Hello Sojoerd B.

Indeed you were right!!.

Yesterday I had done it but I had changed a port on the server in one of my attempts and that's why the error when executing the command.


Thank you all for your help!

2018-11-13-094455.png

2018-11-13-094518.png


sjoerd1
Advisor

Nice!! Can you please "Accept" my answer, so that people with similar issues can easily find the solution?

Good luck in your Dynatrace AppMon trial!