Point Java App to OTel and Validate Data
Add Java Auto-Instrumentation Library¶
- On the host running your Java app, go to the root directory of the app and download the auto-instrumentation library:
curl -L https://github.com/signalfx/splunk-otel-java/releases/latest/download/splunk-otel-javaagent.jar -o splunk-otel-javaagent.jar
-
Set the following environment variables (replace
<APP_NAME>
,<ENV_NAME>
, and<GATEWAY_IP>
):export OTEL_SERVICE_NAME='<APP_NAME>' export OTEL_RESOURCE_ATTRIBUTES='deployment.environment=<ENV_NAME>' export OTEL_EXPORTER_OTLP_ENDPOINT='http://<GATEWAY_IP>:4317'
-
Finally, run your app with the
javaagent
tag added to specify the auto-instrumentation library (<GATEWAY_IP>
may belocalhost
if the OTel collector is running on the same VM):If you are using the Spring PetClinic app, run this command instead, from the app's root directory:java -javaagent:./splunk-otel-javaagent.jar -Dsplunk.profiler.enabled=true -Dsplunk.metrics.enabled=true -Dsplunk.metrics.endpoint='http://<GATEWAY_IP>:9943' \ -jar myapp.jar
java -javaagent:./splunk-otel-javaagent.jar -Dsplunk.profiler.enabled=true -Dsplunk.metrics.enabled=true -Dsplunk.metrics.endpoint='http://<GATEWAY_IP>:9943' -jar target/spring-petclinic-*-SNAPSHOT.jar
Validate Data in Splunk Enterprise¶
- Trace search (in Splunk/SPL) for validating ingestion and search:
index = apm_traces (last 15 minutes)
-
Metric search for validating ingestion:
Metric search for validating search:| mcatalog values(metric_name) WHERE index=apm_metrics
| mstats avg(_value) prestats=t WHERE index=apm_metrics AND metric_name="runtime.jvm.memory.*" span=1m by metric_name | timechart avg(_value) as "Avg" span=1m by metric_name
-
Learn how to work with metric data in Splunk Enterprise/Cloud. See:
-
Splunk Enterprise/Cloud docs: Visualize metrics in the Analytics Workspace
-
Metrics and attributes collected by the Splunk OTel Java agent (JVM metrics)
Validate Data in Splunk Observability Cloud¶
-
Login to Splunk Observability Cloud and check for JVM metrics by searching
jvm
in Metric Finder. -
Check for traces in APM (on the service map and in the traces view), and also check for Code Profiling data in APM. If using a database, check DB Query Perfomance in APM.