Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

How to collect statistics

Jetty 6 currently has two levels of statistic collection:

  1. Connectors optionally collect statistics about connections
  2. The StatisticsHandler class may be used to collect request statistics.


To view statistics, you must be able to view mbeans with either jconsole or some other
mbean agent. By default Connector statistics are turned off and must either be configured
or turned on via the mbean interface.

Connector statistics

Detailed statitics on connection duration and number of requests is only collated when a connection is closed. The current, min and maximum number of connections is the only "live" statistic. The following example shows how to turn on connector statistics in jetty.xml (although this is not recommended and it is best to use an mbean agent to select statistics only when needed).

Code Block
  <New class="org.mortbay.jetty.nio.SelectChannelConnector">
    <Set name="port">8080</Set>
    <Set name="maxIdleTime">30000</Set>
    <Set name="lowResourceMaxIdleTime">3000</Set>
    <Set name="Acceptors">1</Set>
    <Set name="StatsOn">true</Set>

Request Statistics

To collect request statistics a StatisticsHandler must be configured as one of the handlers of the server. Typically this can be done as the top level handler, but you may wish to configure a statistics handler for just one context. The following jetty.xml fragment shows how to configure a top level statistics handler:

Code Block
<!-- =========================================================== -->
<!-- Set handler Collection Structure                            --> 
<!-- =========================================================== -->
<Set name="handler">
  <New class="org.mortbay.jetty.handler.StatisticsHandler">
    <Set name="handler">
      <New id="handlers" class="org.mortbay.jetty.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.mortbay.jetty.Handler">
           <Item><New id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/></Item>
           <Item><New id="defaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/></Item>
           <Item><New id="requestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/></Item>
Contact the core Jetty developers at
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery