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.

  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 or environment variables. System properties override environment variables.

    Table 1. JVM agent parameters
    System propertyEnvironment variableDescription
    otel.exporter.otlp.endpointOTEL_EXPORTER_OTLP_ENDPOINTFQDN and gRPC port of your OpenTelemetry collector.

    Example: http://otel-collector:4318

    otel.resource.attributesOTEL_RESOURCE_ATTRIBUTES

    Resource attributes to associate with your Java application.

    Required:

    • service.name (set to same value as otel.service.name)
    • service.namespace

    Recommended:

    • deployment.environment
    otel.service.nameOTEL_SERVICE_NAMEService name of your Java application.
    Note: You must include the service.namespace parameter in otel.resource.attributes. For information about this parameter, see Service Attributes. For help with the JVM agent, see Instrument Java applications for Splunk Observability Cloud.

    Syntax:

    java -javaagent:./splunk-otel-javaagent-csa.jar \  
    -Dotel.service.name=<service-name> \ 
    -Dotel.resource.attributes=deployment.environment=<environment-name>,service.name=<service-name>,service.namespace=<namespace-name> \
    -Dotel.exporter.otlp.endpoint=http://<collector-endpoint>:<collector-port> \
    -jar <myapp>.jar

    Substitute placeholders with values specific to your environment. For example:

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

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 24 hours thereafter.