Based on the JVM version (1.4, 5, 6, 7, 8, 9), JVM vendor (Oracle, IBM, HP, Azul, Android), GC algorithm (Serial, Parallel, CMS, G1, Shenandoah) and few other settings, GC log format changes. Thus, today the world has ended up with several GC log formats.
‘GC Log standardization API’ normalizes GC Logs and provides a standardized JSON format as shown below.
Graphs provided by GCeasy is great, but some engineers would like to study every event of the GC log in detail. This standardized JSON format gives them that flexibility. Besides, that engineers can import this data to Excel or Tableau or any other visualization tool.
How to invoke Garbage Collection log standardization API?
Invoking Garbage Collection log analysis is very simple:
1). Register with us. We will email you the API key. This is a one-time setup process. Note: If you have purchased enterprise version, you don’t have to register. API key will be provided to you as a part of installation instruction.
2). Post HTTP request to http://api.gceasy.io/std-format-api?apiKey={API_KEY_SENT_IN_EMAIL}
3). The body of the HTTP request should contain the Garbage collection log that needs to be analyzed.
4). HTTP Response will be sent back in JSON format. JSON has several important stats about the GC log. Primary element to look in the JSON response is: “isProblem“. This element will have value to be “true” if any memory/performance problems have been discovered. “problem” element will contain the detailed description of the memory problem.
CURL command
Assuming your GC log file is located in “./my-app-gc.log,” then CURL command to invoke the API is:
curl -X POST --data-binary @./my-app-gc.log http://api.gceasy.io/std-format-api?apiKey= --header "Content-Type:text"
It can’t get any more simpler than that? Isn’t it?
Note:use the option “–data-binary” in the CURL instead of using “–data” option. In “–data” new line breaks will be not preserved in the request. New Line breaks should be preserved for legitimate parsing.
Other Tools
You can also invoke the API using any web service client tools such as SOAP UI, Postman Browser Plugin,…..
postman.jpg
Fig: POSTing GC logs through PostMan plugin
Sample Response
{ "gcEvents": [ { "timeStamp": "15:49:55", "gcType": "YOUNG", "durationInSecs": 0.077381, "reclaimedBytes": "387.64258 mb", "heapSizeBeforeGC": "1031.0488 mb", "heapSizeAfterGC": "643.40625 mb", "youngGenSizeBeforeGC": "1024.0 mb", "youngGenSizeAfterGC": "636.3584 mb", "oldGenSizeBeforeGC": "7.048828 mb", "oldGenSizeAfterGC": "7.048828 mb" }, { "timeStamp": "15:51:15", "gcType": "FULL", "durationInSecs": 0.344394, "reclaimedBytes": "6.053711 mb", "heapSizeBeforeGC": "1663.5732 mb", "heapSizeAfterGC": "1657.5195 mb", "youngGenSizeBeforeGC": "671.3916 mb", "youngGenSizeAfterGC": "668.2207 mb", "oldGenSizeBeforeGC": "992.18164 mb", "oldGenSizeAfterGC": "989.2988 mb" }, { "timeStamp": "15:53:19", "gcType": "YOUNG", "durationInSecs": 0.021699, "reclaimedBytes": "737.67676 mb", "heapSizeBeforeGC": "2220.624 mb", "heapSizeAfterGC": "1482.9473 mb", "youngGenSizeBeforeGC": "1024.0 mb", "youngGenSizeAfterGC": "282.53516 mb", "oldGenSizeBeforeGC": "1196.624 mb", "oldGenSizeAfterGC": "1200.4131 mb" } ] }
JSON Response Elements
Element Description gcEvents This is the top-level root element. It will contain an array of GC events. For every GC event reported in the GC Log, you will see an element in this array. timeStamp Timestamp at which particular GC event ran gcType YOUNG – if it’s a young GC event type.
FULL – if it’s full GC event type.durationInSecs Duration for which GC event ran reclaimedBytes Amount of bytes reclaimed in this GC event heapSizeBeforeGC Overall Heap size before this GC event ran heapSizeAfterGC Overall Heap size after this GC event ran youngGenSizeBeforeGC Young Generation size before this GC event ran youngGenSizeAfterGC Young Generation size after this GC event ran oldGenSizeBeforeGC Old Generation size before this GC event ran oldGenSizeAfterGC Old Generation size after this GC event ran permGenSizeBeforeGC Perm Generation size before this GC event ran permGenSizeAfterGC Perm Generation size after this GC event ran metaSpaceSizeBeforeGC Metaspace size before this GC event ran metaSpaceSizeAfterGC Metaspace size after this GC event ran
Reference article: https://blog.gceasy.io/2017/08/15/gc...rdization-api/