if I have multiple Java flight recorder files (.JFR) , how do I merge them together to see them at Java mission control in one time

Viewed 977

I received for analysis a bunch of multiple JFR files , like 170 , and it is taking too long to open one by one, can I put them in one single file, starting from the fact that I only have the files and I cannot configure the JVM and obtain the JFR again. for example

  • 2020_03_30_20_37_01_2333_0.jfr
  • 2020_03_30_21_37_01_2333_0.jfr
  • 2020_03_30_22_37_01_2333_0.jfr
  • 2020_03_30_23_37_01_2333_0.jfr

    . . .

  • N
2 Answers

You can use the 'jfr' tool located in JDK_HOME/bin from 11.06 or later.

$ jfr assemble <repository> <file>

where repository is the directory where the files are located and file is the name of the recording file (.jfr) to create.

A recording file is just a concatenation of chunk files so you could do it in the shell as well. For example, using the copy /b command in Windows

 $ copy /b 1.jfr + 2.jfr + 3.jfr combined.jfr 

Here is a script in windows powershell to concatenate the JFR files, just take care of the size of the final concatenated file, it might be too large, in that case you might want to reduce the files to concatenate

    $Location = ""
    $outputConcatenatedJFR = "all_2333_1.jfr"
    $items = Get-ChildItem -Path . -Filter *2333_1.jfr | Sort-Object -Property Name
    New-Item $outputConcatenatedJFR -ItemType file
    ForEach ($item in $items) {
       Write-Host "Processing file - " $item
       cmd /c copy /b $outputConcatenatedJFR+$item $outputConcatenatedJFR
    }
Related