Data analysis

Some common commands that can be used to validate, inspect, and analyze the JDK Flight Recorder (JFR) recordings are as follows.
Note:
  1. macOS and Windows limitation: Due to the lack of a public API for retrieving command-line arguments for arbitrary processes on macOS and Windows, the SystemProcess JFR event is currently limited to displaying only the executable path on these platforms. This limitation will be addressed when a suitable public API becomes available.
View summary of the recording
To obtain a high-level summary of the JFR recording, use the following command.
$ jfr summary <filename>

The jfr summary command provides a concise overview of a JFR recording. It lists the types of events captured, how many times each event occurred, and the total size each event type occupies in the recording file. This helps users quickly understand what kind of data has been collected and assess the recording’s composition without diving into detailed analysis.

Figure 1. jfr_summary
JFR summary
View metadata of the recording
To display metadata information from the JFR recording, use the following command.
$ jfr metadata <filename>

This command prints the JFR metadata such as event structures and the data types of the fields as shown in the following sample. The JFR metadata is useful for understanding the context and structure of the data collected. It tells how the data is structured by describing the layout and schema of each event type recorded.

Figure 2. jfr_metadata
jfr metadata
Print all events
To display all the events captured in a JFR recording, use the following command.
 $ jfr print <filename>

This displays the full list of events contained in the file specified in <filename>, for example, peak.jfr file as shown in the following example.

Analyzing the events recorded by JFR provides insights into an application's runtime behavior and performance characteristics. For example, analyzing class loading events can reveal critical information about the class loading characteristics. If the number of loaded classes keeps increasing over time without corresponding number of unloads, it could be a sign of a memory leak.

Figure 3. jfr_print
jfr print
Print specific events
To print specific events captured during the recording, use the jfr print command with the --events option.
$ jfr print --events "jdk.ExecutionSample" <filename>
Figure 4. jfr_print_specific
jfr_print_specific

In this example, the jdk.ExecutionSample event is a profiling event. It provides periodic snapshots of what the application threads are doing. It helps to identify bottlenecks or inefficient loops. It also helps to highlight which threads or methods are consuming a large amount of CPU and provides an insight into the activity in the background threads.

Figure 5. JDK Physical Memory
JDK Physical Memory

In this example, the jdk.PhysicalMemory event in a JFR recording provides valuable insight into the system's memory usage during the recording period. The event data is useful to understand how the application behaves under different memory pressures. It also helps to diagnose memory-related performance issues.

Figure 6. JDK Thread End
JDK Thread End

In this example, the jdk.ThreadEnd event indicates when a thread has finished execution. It helps to understand the lifecycle of threads in the application. Identifying if threads are properly terminating can help detect thread leaks that may be causing resource exhaustion.

Print events in XML format
To print the event data in XML format, use the following command.
$ jfr print --xml --events "jdk.ExecutionSample" peak.jfr

This exports JFR event data as XML, which is useful for viewing structured event information, sharing data in a standard format, or processing with XML tools.

Print events in JSON format
To output the event data in JSON format, use the following command.
$ jfr print --json --events "jdk.ExecutionSample" peak.jfr

The JSON output formats JFR event data in a way that is easy for many monitoring tools and programs to use. It’s helpful when you want to include JFR data in dashboards or analyze it with scripts written in languages like JavaScript or Python that work natively with JSON data

Print events with stack depth
To limit the number of frames when printing events that contain method call stacks, use the following command.
$ jfr print --stack-depth 10 --events "jdk.ExecutionSample" peak.jfr
Note: The default frame count is 5.