How to Installing APM agent injava applications

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:

===========
#!/bin/sh
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/appconfig.properties"
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=http://10.176.11.39:9210 -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 co.elastic.apm.agent.report.ApmServerHealthChecker - 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.
-D<name>=<value>
              set a system property
-verbose:[class|gc|jni]
              enable verbose output
-version      print product version and exit
-version:<value>
              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
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
              enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
-agentlib:<libname>[=<options>]
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
              load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
              load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
              show splash screen with specified image

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

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: Introduction | APM Java Agent Reference [1.x] | Elastic

1 Like

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=http://10.176.11.39:9210 -Delastic.apm.application_packages=org.example -Dcomponent=QueueMsg -cp $CLASSPATH QueueMSG "Instance1"
2019-04-10 13:57:26.773 [apm-server-healthcheck] WARN co.elastic.apm.agent.report.ApmServerHealthChecker - 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.

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.

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: http://10.176.11.39:9200
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 10.176.11.39:9369: 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. ?

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:

apm-server:
  host: "0.0.0.0:9210"

but suspect it's set to 9369 currently.

Hi Gil,

Thanks for your response. PFB details.

Kibana Service Status and It's port:

Elastic search Service status and its port:
image

Here is the apm-server config file:

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

https://wetransfer.com/downloads/c8d2b970e12976e8307bd2314b3306c920190411022038/a8414e822fb05a618abf5a6f356db9bd20190411022038/2d8498

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

apm-server:
  host: "10.176.11.39:9210"
# tons of comments ....
  host: "10.176.11.39:9369"

setup.kibana:
  host: "10.176.11.39:9369"

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

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.
    image

Could you please help me resolve my concerns.

Thanks in advance...

Hello,

Can anyone help me on this.

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

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