How to Installing APM agent injava applications

(Sajid Md) #1

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text :slight_smile:

Kibana version: -6.2.1-

Elasticsearch version: -6.2.1

APM Server version: 6.2.0

APM Agent language and version: I need support JAVA application version of agent.

Browser version: latest chrome

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

Fresh install

I want to setup APM agents for java supported applications. i tried multiple links but could not able to setup the agent. could you please share link to download APM agent for java apps.

I have tried to setup for one java application by imorting into system prop. while starting getting below error.

Startup file config:

cd $(dirname $0)
export JAVA_HOME=/usr/java/jdk1.8.0_91
export JAVA_OPTS="$JAVA_OPTS -Xmx2048m"
export JAVA_OPTS="$JAVA_OPTS -Dprop.appconfig.path=../conf/"
export CLASSPATH=../lib/*:.
exec /usr/java/jdk1.8.0_91/bin/java -javaagent:../lib/elastic-apm-agent-1.5.0.jar $JAVA_OPTS -Delastic.apm.service_name=my-application -Delastic.apm.server_url= -Delastic.apm.application_packages=org.example
exec /usr/java/jdk1.8.0_91/bin/java $JAVA_OPTS -Dcomponent=QueueMsg -cp $CLASSPATH QueueMSG "Instance1"

Getting below errors:
2019-04-10 11:27:00.176 [apm-server-healthcheck] WARN - Elastic APM server is not available (Connection refused)
2019-04-10 11:27:00.206 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.5.0 as my-service on Java 1.8.0_91 (Oracle Corporation) Linux 3.10.0-514.el7.x86_64
2019-04-10 11:27:00.206 [main] WARN co.elastic.apm.agent.configuration.StartupInfo - To enable all features and to increase startup times, please configure application_packages
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A : separated list of directories, JAR archives,
              and ZIP archives to search for class files.
              set a system property
              enable verbose output
-version      print product version and exit
              Warning: this feature is deprecated and will be removed
              in a future release.
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              Warning: this feature is deprecated and will be removed
              in a future release.
              include/exclude user private JREs in the version search
-? -help      print this help message
-X            print help on non-standard options
              enable assertions with specified granularity
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
              load native agent library by full pathname
              load Java programming language agent, see java.lang.instrument
              show splash screen with specified image

Any one can help on this to setup agents and dashboard for my applications.

(Felix Barnsteiner) #2

It seems like you have the line exec /usr/java/jdk1.8.0_91/bin/java $JAVA_OPTS twice in your startup script. Maybe that's the cause of the error?

Note that the Java agent requires at least APM Server version 6.5.0. For more info check out the docs:

(Sajid Md) #3

Dear Felixbarny,

Thanks for your feedback.

if i run with single java also am getting the same issue. PFB logs.

[root@dpdp9-testing-vm--2 bin]# /usr/java/jdk1.8.0_91/bin/java -javaagent:../lib/elastic-apm-agent-1.5.0.jar $JAVA_OPTS -Delastic.apm.service_name=my-application -Delastic.apm.server_url= -Delastic.apm.application_packages=org.example -Dcomponent=QueueMsg -cp $CLASSPATH QueueMSG "Instance1"
2019-04-10 13:57:26.773 [apm-server-healthcheck] WARN - Elastic APM server is not available (It seems like you are using a version of the APM Server which is not compatible with this agent. Please use APM Server 6.5.0 or newer.)
2019-04-10 13:57:26.814 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.5.0 as my-application on Java 1.8.0_91 (Oracle Corporation) Linux 3.10.0-514.el7.x86_64
2019-04-10 13:57:26.814 [main] WARN co.elastic.apm.agent.configuration.StartupInfo - Detected usage of an old configuration key: 'server_url'. Please use 'server_urls' instead.

(Felix Barnsteiner) #4

This is actually a different error now. It indicates that setting the config has worked now. But you need to use APM Server 6.5.0 or newer with the Java agent.

(Sajid Md) #5

Hi Felixbarny,

now i have updated APM server to 6.5.0. but while starting apm servers its throwing error for Kibana port.

im running kibana on 9369
ES on 9200
APM server configure with 9210

2019-04-10T18:44:24.111+0500 INFO instance/beat.go:302 Setup Beat: apm-server; Version: 6.5.0
2019-04-10T18:44:24.112+0500 INFO elasticsearch/client.go:163 Elasticsearch url:
2019-04-10T18:44:24.112+0500 INFO [publisher] pipeline/module.go:110 Beat name: dpdp9-testing-vm--2
2019-04-10T18:44:24.112+0500 INFO [beater] beater/beater.go:81 No pipeline callback registered
2019-04-10T18:44:24.112+0500 INFO instance/beat.go:424 apm-server start running.
2019-04-10T18:44:24.112+0500 INFO [beater] beater/beater.go:178 self instrumentation is disabled
2019-04-10T18:44:24.113+0500 ERROR [beater] beater/beater.go:142 failed to listen:listen tcp bind: address already in use
2019-04-10T18:44:24.113+0500 INFO instance/beat.go:434 apm-server stopped.

can you please let me know why apm-server is truing to deploy on Kibana port. ?

(Gil Raphaelli) #6

I'm glad you were able to get apm-server updated. Can you double check your configuration (or share it here)? Based on the information provided, I would expect it to include:

  host: ""

but suspect it's set to 9369 currently.

(Sajid Md) #7

Hi Gil,

Thanks for your response. PFB details.

Kibana Service Status and It's port:

Elastic search Service status and its port:

Here is the apm-server config file:

am not able to paste complete file here. Attached link here for apm-server.yml

(Gil Raphaelli) #8

@Sajid_Md Thanks for providing that information. The [tricky] problem is that in the apm-server.yml provided, the host is set like this:

  host: ""
# tons of comments ....
  host: ""

  host: ""

The last setting for wins - Remove that middle host entry and you should be all set.

(Sajid Md) #10

HI @gil .

Thanks for the update. Now it's working fine. the agent has been up and running now.

But In Kibana dashboard APM tab was not added, it's showing in dashboard list like below. How to add APM as a separate tab in Kibana dashboard.

Also I have few quesions:

  • Which type of data will be pushing into APM server from agent applications.
  • For example, I added an agent for one application that will take the input from one application and insert into DB servers. here which type of logs I can expect into APM server?
  • In the APM dashboard, I can see a total of 5 tabs for APM in that Span details is not showing for my applications.
  • Error details and Error dashboard tabs will show when we are having errors from applications?
  • How to add the main APM tab in my Kibana dashboard like below.

Could you please help me resolve my concerns.

Thanks in advance...

(Sajid Md) #11


Can anyone help me on this.

(Andrew Wilkins) #12

I have answered these questions over at What Kind of logs will push to ES via APM.