Define agent paths for Java application servers for Splunk Observability Cloud

This topic describes how to set the agent path to instrument your Java application, for supported Java servers.

To instrument your Java application for Splunk Observability Cloud, you must define the path to the agent from the Splunk Distribution of OpenTelemetry Java. The following sections describe how to set the agent path for each of the supported servers.

JBoss EAP and WildFly

Follow the instructions for your deployment mode.

Standalone mode

Add the javaagent argument to the standalone configuration file:

Linux

On Linux add the following line at the end of the standalone.conf file:

JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/splunk-otel-javaagent.jar"
Windows

On Windows, add the following line at the end of the standalone.conf.bat file:

set "JAVA_OPTS=%JAVA_OPTS% -javaagent:<Drive>:\path\to\splunk-otel-javaagent.jar"

Domain mode

Edit the domain.xml file to add the following option under server-groups.server-group.jvm.jvm-options:

<option value="-javaagent:/path/to/splunk-otel-javaagent.jar"/>

For more information, see the Red Hat documentation .

Note: Make sure to install the Java agent at each of the Server Group levels.

Jetty

Add the path to the JVM agent using the -javaagent argument:

java -javaagent:/path/to/splunk-otel-javaagent.jar -jar start.jar

Alternatively, you can add the -javaagent argument to your jetty.sh or start.ini files:

  • If you use the jetty.sh file to start Jetty, add the following line to the <jetty_home>/bin/jetty.sh file:

    JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:/path/to/splunk-otel-javaagent.jar"
  • If you use the start.ini file to define JVM arguments, add the javaagent argument below the --exec option:

    #===========================================================
    # Sample Jetty start.ini file
    #-----------------------------------------------------------
    --exec
    -javaagent:/path/to/splunk-otel-javaagent.jar

Glassfish and Payara

Add the path to the JVM agent to the settings using the asadmin command-line tool:

  • On Linux, enter the following command:

    <server_install_dir>/bin/asadmin create-jvm-options "-javaagent\:/path/to/splunk-otel-javaagent.jar"
  • On Windows, enter the following command:

    <server_install_dir>\bin\asadmin.bat create-jvm-options '-javaagent\:<Drive>\:\\path\\to\\splunk-otel-javaagent.jar'

You can also add the -javaagent argument from the Glassfish or Payara Admin Console:

  1. Open the GlassFish Admin Console at http://localhost:4848.

  2. Go to Configurations, then server-config.

  3. Select JVM Settings.

  4. Select JVM Options, then Add JVM Option.

  5. In the blank field, enter the path to the splunk-otel-javaagent.jar file:

    -javaagent:/path/to/splunk-otel-javaagent.jar

  6. Select Save and restart the server.

Note: Make sure that the domain.xml file in your domain directory contains a <jmv-options> entry for the agent.

Tomcat and TomEE

Add the path to the JVM agent to your Tomcat or TomEE startup script:

Linux

On Linux, add the following line to the <tomcat_home>/bin/setenv.sh file:

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/splunk-otel-javaagent.jar"
Windows

On Windows, add the following line to the <tomcat_home>\bin\setenv.bat file:

set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:"<Drive>:\path\to\splunk-otel-javaagent.jar"
Note: When running Tomcat as a Windows service, the setenv.bat script is not used. To add the Java agent to your Tomcat Windows service, run the tomcat<version-number>w.exe utility as an administrator, then add the -javaagent argument to the list of Java Options.

WebLogic

Add the path to the JVM agent to your WebLogic domain startup script:

  • On Linux, add the following line to the <domain_home>/bin/startWebLogic.sh file:

    export JAVA_OPTIONS="$JAVA_OPTIONS -javaagent:/path/to/splunk-otel-javaagent.jar"
  • On Windows, add the following line to the <domain_home>binstartWebLogic.cmd file:

    set JAVA_OPTIONS=%JAVA_OPTIONS% -javaagent:"<Drive>:\path\to\splunk-otel-javaagent.jar"
Note: For managed server instances, add the -javaagent argument using the admin console.

WebSphere Liberty Profile

Add the path to the JVM agent to the jvm.options file:

  1. Open the jvm.options file: - For a single server, create or edit the ${server.config.dir}/jvm.options file. - For all servers, create or edit the ${wlp.install.dir}/etc/jvm.options file.

  2. Add the following line:

    -javaagent:/path/to/splunk-otel-javaagent.jar
  3. Save the file and restart the server.

Note that WebSphere Liberty servers on mainframes is not supported.

WebSphere Traditional

Open the WebSphere Admin Console and follow these steps:

  1. Navigate to Servers, then Server type.

  2. Select WebSphere application servers.

  3. Select the desired server.

  4. Navigate to Java and Process Management, then Process Definition.

  5. Select Java Virtual Machine.

  6. In the Generic JVM arguments field, enter the path to Splunk Java agent:

    -javaagent:/path/to/splunk-otel-javaagent.jar
  7. Select OK. When asked, save the main configuration and restart the server.