Query Analyzer Tool Usage
Ensure that the JMX support is enabled using the following system properties regardless of the application that uses the support, such as Cortex or a standalone application:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<PORT>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Where PORT
is the port number, for example 6969
. When you start Cortex using Maven, add the parameters to the MAVEN_OPTS
environment variable.
You can use the Query Analyzer tool from an OSGi container or a command line. When used from an OSGi container, the tool is deployed as a bundle, while from the command line it is run as an executable JAR
. Regardless of the usage, only one JAR
is created.
The tool uses the trace lines that is found in ep-cortex.log
and are enabled through a JMX connection to the Logback MBean. The following classes provide the trace output:
OpenJPA**
com.elasticpath.rest.resource.dispatch.operator.AnnotatedMethodDispatcher
com.elasticpath.rest.resource.dispatch.linker.ResourceLinker
com.elasticpath.rest.helix.runtime.server.PrototypeDispatcherResourceServer
All JPA classes, AnnotatedMethodDispatcher
, ResourceLinker
, and PrototypeDispatcherResourceServer
classes provide trace output for Query Analyzer. The OpenJPA trace lines provide JPA
and SQL
statistics. The Cortex traces provide correlation between Cortex requests and JPA/DB
queries, so that Cortex operation can report the database statistics.
For more information about the details provided, see Overview
To use the tool from the command line, run the following command:
java -jar </ep-commerce/commerce-engine/ep-query-analyzer>
Use the command line tool when Cortex log already contains the required trace lines. You can override the following default values using system properties:
-Dlog.file.path=<ABSOLUTE_PATH_TO_CORTEX_LOG>
Specifies the default location of Cortex log file. The parser accesses the Cortex log file at this location if you set the location. If not, parser reads the default Cortex log file,
USER_HOME/ep/logs/ep-cortex.log
.-Dprint.json.to.console.only
Displays JSON output only in console.
If this property is set to a value, such as
-Dprint.json.to.console.only=X
or-Dprint.json.to.console.only=EP
, the system displays the JSON output file only in the console and does not save the output to a file irrespective of the value.-Doutput.json.file.path
Saves the output in an external file at the specified path. By default, the output is saved at
USER_HOME/ep/db_statistics.json
All system properties are defined in the com.elasticpath.repo.performancetools.queryanalyzer.utils.SystemProperties
module.