Step 2: Instrument your Java application for Splunk Observability Cloud

Attention:

Alpha features described in this document are provided by Splunk to you "as is" without any warranties, maintenance and support, or service-level commitments. Splunk makes this Alpha feature available at its sole discretion and may discontinue it at any time. These documents are not yet publicly available and we ask that you keep this information confidential.

Use of Alpha features is subject to the Splunk Pre-Release Agreement for Hosted Services. Use these links to navigate to topics within this private preview:

The Secure Application Java Virtual Machine (JVM) agent, splunk-otel-javaagent-csa, adds APM instrumentation to your Java application and sends the data it collects to the Splunk Distribution of OpenTelemetry Collector. Follow these steps to add the JVM agent to your application and configure it to send the OpenTelemetry events and logs that Secure Application needs.

Table 1. JVM agent parameters
Command-line parameterEnvironment variableDescription
otel.service.nameOTEL_SERVICE_NAMEService name of your Java application.
otel.resource.attributesOTEL_RESOURCE_ATTRIBUTESResource attributes to associate with your Java application. Recommended:
  • deployment.environment

  • service.name (set to same value as otel.service.name)
otel.exporter.otlp.endpointOTEL_EXPORTER_OTLP_ENDPOINTFQDN and gRPC port of your OpenTelemetry collector.

Example: http://otel-collector:4318

  1. Identify the version of the Secure Application JVM agent that you want to install from https://repo1.maven.org/maven2/com/splunk/splunk-otel-javaagent-csa/. Use a version greater than 2.21.0.
  2. Download the JAR file for the version you want to install:
    curl -L https://repo1.maven.org/maven2/com/splunk/splunk-otel-javaagent-csa/<version>/splunk-otel-javaagent-csa-<version>.jar -o splunk-otel-javaagent-csa.jar
  3. Start your application with the JVM agent. On the command line, configure the agent using system properties.

    Alternatively, you can set environment variables instead of providing them as system properties. System properties, if specified, override existing environment variables. For example, you can set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable instead of the specifying the system property otel.exporter.otlp.endpoint above.

    Substitute the variables with values specific to your environment:

    java -javaagent:./splunk-otel-javaagent-csa.jar \  
    -Dotel.service.name=<yourServiceName> \ 
    -Dotel.resource.attributes=deployment.environment=lab0,service.name=<yourServiceName> \
    -Dotel.exporter.otlp.endpoint=http://<collectorEndpoint>:<collectorPort> \
    -jar <myapp>.jar

    For example:

    java -javaagent:./splunk-otel-javaagent-csa.jar \ 
    -Dotel.service.name=myService \ 
    -Dotel.resource.attributes=deployment.environment=us0,service.name=myService \
    -Dotel.exporter.otlp.endpoint=http://otel-collector:4318 \
    -jar myapp.jar

    For help, see Instrument Java applications for Splunk Observability Cloud.

Your Java application launches with the JVM agent enabled. The JVM agent gathers a list of runtime libraries, formats them as OTLP logs, and sends the data to the OTLP exporter endpoint specified above. The JVM agent reports library data once at application startup and then every twenty four hours thereafter.