Elastic java APM agent connect to sample java application which have only db calls without any server connections

Hi all,
I need to collect data from java apm agent to apm server.
My jar is simple java application which has only internal db calls dont have any rest or serer and it is not a web application.

I need to monitor those db queries please help me with this.

Kibana version:7.2.1

Elasticsearch version:7.2.1

APM Server version:7.2.1

APM Agent language and version:1.14.0 java

Browser version:

Original install method (e.g. download page, yum, deb, from source, etc.) and version:download page

**Fresh install or upgraded from other version?**fresh install

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

Steps to reproduce:
1.
2.
3.

Errors in browser console (if relevant):

Provide logs and/or server output (if relevant):

Hi @renu_jessi,

What is the nature of your application ? does it have a GUI or any command-line interface ?

Agent has two main concepts to represent what is being executed within the application:

  • transaction: enclosing scope of what is observed, mostly entry point to the application like "processing an http request for a web-application".
  • spans: unit of work, which is often delegated to another service, like a database query, calling another web-service, ...

Having only an "internal" database would not make much difference, but for example if you have an application with a GUI our agent won't provide out-of-the-box support for common GUI frameworks like Swing or AWT, and you'll have to use agent API to define transactions.

it dont have any gui i have one main class whish has db connection details and executing one query.i have export this project as jar and attached to elastic apm.no data is captured fron elastic agent am getting

Ok, then you should be able to create transactions using agent API: https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html

Hi,

my application is not spring boot i dont have pom. xml how can i use this

You can download it from maven and use it in your application.

i had already tried..i had downloades that elastic apm agent jar file and added it in my build path still import statements are getting error

whixh jar i need to add.. i have actually added elastic-apm-agent.1.14.0.jar

apm-agent-api.version.jar

i tried this still getting error

Here I added simple example and readme for it.

Also, you have to make sure that elastic-apm-agent jar is not in your application dependencies, you should only add to the command line when starting the application using -javaagent argument.

HI,

I am getting below error after compiling from command line.but when i run from my eclipse it is working fine and getting result also.

ERROR:

javac -cp ./lib/apm-agent-api-0.6.1.jar:. -sourcepath src src/sample_apm/com/MessengerMain.java

By giving second command :

command:

java -javaagent:D:<user>\APM\elastic-apm-agent-.jar -Delastic.apm.service_name=NAME -Delastic.apm.server_url=http://localhost:8200 -Delastic.apm.application_packages=com -cp lib/apm-agent-api-0.6.1.jar:src/ com.Main

ERROR:
2020-04-08 17:38:54.761 [main] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
Error: Could not find or load main class sample_apm.com.MessengerMain
2020-04-08 17:38:57.109 [elastic-apm-init-instrumentation-shutdown-hook] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to STOPPED state

command:

java -javaagent:D:\1210353\APM\elastic-apm-agent-1.14.0.jar -Delastic.apm.service_name=ECI_Sample -Delastic.apm.server_url=http://localhost:8200 -Delastic.apm.application_packages=sample_apm.com -cp D:\1210353\APM\Project_jars\sample_apm.jar lib/apm-agent-api-0.6.1.jar:src/ sample_apm.com.MessengerMain

ERROR:

java.lang.IllegalStateException: Cannot locate field named span for class co.elastic.apm.api.TransactionImpl

Along with this my db call executed successfull.but agent status is still not success.

please help me with this

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.