Enable metrics logging | ColdFusion MX

ColdFusion MX offers multiple ways to generate runtime usage data. Performance Monitor integration, cfstat, and application logging all allow administrators to gather important statistics on a sites usage. One additional tool that is available with the ColdFusion MX Server configuration and ColdFusion MX J2EE with JRun configuration is JRun's metrics service. JRun's metrics service gathers and logs statistics on a number of important performance metrics including:

Metric Description
listenTh Threads listening for a new connection
idleTh Threads waiting for a new request
delayTh Threads waiting to run
busyTh Threads currently running
totalTh Total worker thread count
delayRq Requests delayed due to high concurrency
droppedRq Requests dropped
handledRq Requests handled
handledMs Milliseconds spent servicing requests not including any delay time (delayMs)
delayMs Milliseconds spent in delay state
bytesIn Bytes read from request
bytesOut Bytes written to response
freeMemory Kilobytes of free memory in the heap
totalMemory Total Kilobytes in the heap (in use and free)
sessions Current number of active J2EE sessions
sessionsInMem Number of J2EE sessions in memory

Note: Metrics calculating thread statistics combine all HTTP request threads, and add requests coming from the connector to requests from the ColdFusion MX internal web server.

To enable JRun metrics logging, follow these steps:

  1. Open the jrun.xml file for editing.

    Server configuration:cf_root/runtime/servers/default/SERVER-INF/jrun.xml

    J2EE with JRun configuration:jrun_root/servers/cfusion/SERVER-INF/jrun.xml
  2. Verify that the metrics service section is uncommented. The following are examples of the XML:



    Server configuration:
    <!-- ================================================================== --><!-- This Service provides metrics information --><!-- ================================================================== --><service outputclass="coldfusion.server.jrun4.metrics.MetricsServiceAdapter" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
    <!-- ================================================================== --><!-- This Service provides metrics information --><!-- ================================================================== --><service outputclass="coldfusion.server.jrun4.metrics.MetricsServiceAdapter" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
    <!-- ================================================================== --><!-- This Service provides metrics information                          --><!-- ================================================================== --><service outputclass="coldfusion.server.jrun4.metrics.MetricsServiceAdapter" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
    J2EE with JRun configuration:
    <!-- ================================================================== --><!-- This Service provides metrics information --><!-- ================================================================== --><service outputclass="jrunx.metrics.MetricsService" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
    <!-- ================================================================== --><!-- This Service provides metrics information --><!-- ================================================================== --><service outputclass="jrunx.metrics.MetricsService" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
    <!-- ================================================================== --><!-- This Service provides metrics information                          --><!-- ================================================================== --><service outputclass="jrunx.metrics.MetricsService" name="MetricsService"><attribute name="bindToJNDI">true</attribute></service>
  3. Change the metricsEnabled attribute to true:
    <service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">60</attribute>
    <service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">60</attribute>
    <service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">60</attribute>
  4. Save the changes to the file.
  5. Restart the ColdFusion Application server for the changes to take effect.

The metrics logger writes data to the server's log file at the interval specified in the metricsLogFrequency attribute. The default value is 60 seconds. For J2EE with JRun configurations, the metrics data are written to the default-event.log. For Server configurations, the metrics data is logged to the default-event.log (Windows) or cfserver.log and default-event.log (Unix).

The metricsFormat attribute controls the format of the data written to the server's logs. It can contain literal text in combination with any or all of the available metrics variables (which are listed in the table above).

The following example shows how to configure themetricsFormat attributes for the metrics logger:

<service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">10</attribute><attribute name="metricsFormat">Web threads (busy/total/idle): {busyTh}/{totalTh}/{idleTh} J2EE Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>
<service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">10</attribute><attribute name="metricsFormat">Web threads (busy/total/idle): {busyTh}/{totalTh}/{idleTh} J2EE Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>
<service outputclass="jrunx.logger.LoggerService" name="LoggerService"><attribute name="errorEnabled">true</attribute><attribute name="warningEnabled">true</attribute><attribute name="infoEnabled">true</attribute><attribute name="debugEnabled">false</attribute><attribute name="metricsEnabled">true</attribute><attribute name="metricsLogFrequency">10</attribute><attribute name="metricsFormat">Web threads (busy/total/idle): {busyTh}/{totalTh}/{idleTh} J2EE Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>

The following example shows a log message generated with this format:

02/14 16:11:53 metrics Web threads (busy/total/idle): 0/2/0 J2EE Sessions: 2 Total Memory=7252 Free=3103
02/14 16:11:53 metrics Web threads (busy/total/idle): 0/2/0 J2EE Sessions: 2 Total Memory=7252 Free=3103
02/14 16:11:53 metrics Web threads (busy/total/idle): 0/2/0 J2EE Sessions: 2 Total Memory=7252 Free=3103

Note: Due to Macromedia issue 46500, the JWS and web server metrics for ColdFusion MX Server configuration are combined when using the default metricsFormat in jrun.xml. To obtain accurate statistics, remove any instances of jrpp preceding a metric attribute. For example, change {jrpp.busyTh}/{jrpp.totalTh} to {busyTh}/{totalTh}.

The following indicates (in highlighted text and italics), which text to remove from the default jrun.xml (Server configuration only):

<attribute name="metricsFormat">Web threads (busy/total): {jrpp.busyTh}/{jrpp.totalTh} Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>
<attribute name="metricsFormat">Web threads (busy/total): {jrpp.busyTh}/{jrpp.totalTh} Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>
<attribute name="metricsFormat">Web threads (busy/total): {jrpp.busyTh}/{jrpp.totalTh} Sessions: {sessions} Total Memory={totalMemory} Free={freeMemory}</attribute>

Logging performance metrics adds additional load to the server as well as log files which increase in size. Therefore, Adobe doesn't recommend leaving the metrics service enabled for extended periods of time.

Get help faster and easier

New user?