JDK Flight Recorder
Java Flight Recorder (JFR) is a multi-purpose tool for collecting various data for running Java applications and its JVM. JMS builds on top of it and enables fleet administrators to request JFR recordings on all applications discovered by JMS.
The burden of accessing the machines running the applications, using various tools to start JFR recordings, collect the JFR recordings and access the recordings from one place is reduced by using JMS. Since Java Flight Recorder can observe and collect many useful metrics provided by JVM like memory usage, garbage collection, thread usage, exceptions and so on, customers can easily track behavior of their applications.
OCI Cloud Console
- Sign in to the OCI Console as an administrator.
- Open the navigation menu, click Observability & Management, and then click Fleets under Java Management.
- Select your fleet.
- Click Managed instances and then click on the managed instance where the application is running.
- Click Applications and select the application on which the JFR recording should be started.
- Click Actions and select Run JDK Flight Recorder.
- Click Start.
- Once the work request is finished, click on the work request and in details navigate to JFR files located in your fleet's bucket.
OCI CLI
- Create targets payload template using the following command:
oci jms fleet request-jfr-recordings --generate-param-json-input targets
- Find details about your application, for example with:
oci jms application-installation-usage-summary summarize-application-installation-usage --display-name-contains $APP_NAME --fleet-id $FLEET_OCID
- Edit the payload json file, for
example:
[ { "applicationInstallationKey": "$APP_INSTALL_KEY", "applicationKey": "$APP_KEY", "jreKey": "$APP_JRE_KEY", "managedInstanceId": "$MANAGED_INSTANCE_OCID" } ]
- Execute the following command:
oci jms fleet request-jfr-recordings --fleet-id $FLEET_OCID --jfc-profile-name default.jfc --targets file://targets.json
Example
#!/usr/bin/env bash
# configuration variables
APP_INSTALL_LOCATION=/usr/share/tomcat
JFC_FILENAME=custom.jfc
FLEET_OCID=ocid1.jmsfleet.oc1.eu-frankfurt-1.amaaaaaaptiaquqa2qxxkco6hrguz7nyug2hcpgikhe5gz4d7uy6j6ilbtta
MANAGED_INSTANCE_OCID=ocid1.instance.oc1.eu-frankfurt-1.antheljtptiaquqcrjmnu7mxbjthm2jm5qzryu7xy4w27rfo56nxf4uwv6pq
# get application installation key
APP_INSTALL_KEY=$(oci jms application-installation-usage-summary summarize-application-installation-usage --app-installation-path-contains "$APP_INSTALL_LOCATION" --fleet-id $FLEET_OCID | jq -r '.data.items[]."application-installation-key"')
# create custom jfc file from default profile
jfr configure thread-dump=10s exceptions=all --output $JFC_FILENAME
ENCODED_JFC=$(cat $JFC_FILENAME | base64)
# start jfr recording with v2 custom profile for JDK 9 or higher
WORK_REQUEST_OCID=$(oci jms fleet request-jfr-recordings \
--fleet-id "$FLEET_OCID" \
--jfc-profile-name custom-profile \
--jfc-v2 "$ENCODED_JFC" \
--targets "[{\"applicationInstallationKey\":\"$APP_INSTALL_KEY\", \"managedInstanceId\":\"$MANAGED_INSTANCE_OCID\"}]" | jq -r '."opc-work-request-id"')
echo $WORK_REQUEST_OCID
# additionally you can add your own logic to check if work request is finished
# sleep 600
# oci jms work-request get --work-request-id "$WORK_REQUEST_OCID" | jq .data.status
Note:
jfr
command line utility is part of more recent JDK bundles.base64
command line utility may not be present on Windows platform.
Once the work request is complete the JFR is uploaded to the bucket associated with your fleet:
# list all the jfr recordings created during work request execution
oci jms work-request-log-entry list-work-request-logs --all --work-request-id "$WORK_REQUEST_OCID" | jq -r '.data.items[].message | fromjson | select(.objectName != null) | .objectName' | sort | uniq
JMS/JFR/ocid1.jmsfleet.oc1.eu-frankfurt-1.amaaaaaaptiaquqa2qxxkco6hrguz7nyug2hcpgikhe5gz4d7uy6j6ilbtta/ocid1.instance.oc1.eu-frankfurt-1.antheljtptiaquqcrjmnu7mxbjthm2jm5qzryu7xy4w27rfo56nxf4uwv6pq/20250710104111_155_0_91783_0_org.apache.catalina.startup.Bootstrap.jfr