How to use the Request Processing Analyzer to analyze the recent requests in AEM
By: Albin Issac
Tags: Aem, Adobe, CMS, Programming, Software Development

How to use the Request Processing Analyzer to analyze the recent requests in AEM Albin Issac Follow Jun 4 · 4 min read

The “Recent Requests” is a very useful feature on the OSGi Felix Console to know what going on at each request, how is Sling resolving the resources, and the time taken to load the sub-resources.

This will helps us to debug the resource resolution issues and also to capture the time taken to process the resources.

By default 20 recent request is captured into the recent request console — http://localhost:4502/system/console/requests

The value “Number of Requests to Record” can be changed in the Apache Sling Main Servlet through OSGI console — http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.SlingMainServlet

Also the “Recorded Request Path Patterns” can be specified in Apache Sling Main Servlet configuration to only capture the paths that match the pattern — e.g capture only the JSON requests.

Unfortunately, this will not help us to trace millions of requests through the console, and also only the recent values will be shown based on the configuration.

Sometimes we may need to analyze huge requests during the load testing to identify the time taken by individual requests and to identify the requests that taking more time to process.

Sling Request Processing Analyzer help to achieve the above scenario.

Sling Request Processing Analyzer logs each request in a special file — ${sling.home}/logs/requesttracker.txt with a header line providing core information on the request:

Start time stamp in ms since the Epoch

Request processing time in ms

Request Method

Request URL

Response content type (plus character encoding if available)

Response Status

After that first line, the complete data from the requests RequestProgressTracker is dumped.

Configuring Request Processing Analyzer

Download the Request Processing Analyzer bundle from https://github.com/apache/sling-org-apache-sling-reqanalyzer

Build the bundle — mvn clean install

Install the bundle(org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar) from target folder to server through OSGI console- http://localhost:4502/system/console/bundles

This will create a new log file — requesttracker.txt under ${sling.home}/logs and capture all the request details into the log file.

Analyzing the log file

The generated log file can be analyzed through the below command.

java -jar C:\sling-org-apache-sling-reqanalyzer-master\target\org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar requesttracker.txt

This will open the Swing GUI with basic request details — click on individual request to see more details about the request

Click on Analyze Now action, this will open the same Swing GUI shown above.

Dumping the details to separate log file

The Request Process details can also be dumped to a separate log file for reference through Apache Sling Request Progress Tracker Log Filter — no bundle is required to be installed but this file can’t be analyzed through the approach explained above. The dumped file details can be used for manual analysis.

Define a new logger with the below details.

Configure Apache Sling Request Progress Tracker Log Filter

Configure the Extension filter with required file extensions for those the request details should be captured.

Select “Compact Log Format” — this will print the logs fin a more readable format.

Conclusion

The Request Process Analyzer is a useful sling feature to analyze the processing times of Sling requests. This will helps us to debug the resource resolution issues and to capture the time taken to process the resources. Sometimes we may need to analyze huge requests during the load testing to find the time taken by individual request and to find the requests that taking more time to process the default “Recent Feature” will not help here as this capture only the limited number of recent requests but the Sling Request Processing Analyzer can be used to capture and analyze huge request data.