SECTION: 250-Configuration TITLE: 300stats QUESTION: Does Jetty support statistics gathering?
There are 2 sets of statistics available with Jetty. One is Jetty-specific, and the other conforms to the JSR77 specification. Both are accessible via the JMX console (see the README.TXT file for instructions on how to start Jetty with JMX) and the API.
Extended Jetty Statistics
To enable the Jetty-specific statistics, set statsOn
to true
in your Jetty configuration xml file before starting Jetty.
There is an example of this in $JETTY_HOME/etc/jetty.xml
. The relevant line is:
<Set name="statsOn">true</Set>
You can also control statistics at runtime by using the JMX console or the API to call methods on the Server instance to:
setStatsOn(false)
)
setStatsOn(true)
)
statsReset()
)
connections
- the number of connections accepted
connectionsOpen
- the number of currently open connections
connectionsOpenMax
- the max number of concurrently open connections
connectionsDurationAve
- sliding average duration in milliseconds of open connections
connectionsDurationMax
- maximum duration in milliseconds of an open connection
connectionsRequestsAve
- sliding average number of requests per connection
connectionsRequestsMax
- maximum number of requests per connection
errors
- number of errors generated while handling requests
requests
- number of requests
requestsActive
- number of requests currently active
requestsActiveMax
- maximum number of concurrently active requests
requestsDurationAve
- average duration in milliseconds of request handling
requestsDurationMax
- maximum duration in milliseconds of request handling
In addition to the Jetty-specific statistics, since Jetty 5.1 the JSR77 specification is also supported.
To enable JSR77 style statistics, you will need the extra/jsr77 subproject. You can download it as part of the pre-built full Jetty release, or the pre-built extras package, or build it yourself from source (cd extras/jsr77; ant).
To enable the JSR77 statistics:
$JETTY_HOME/etc/demo.xml
file):
<Set name="WebApplicationConfigurationClassNames">
<Array type="java.lang.String">
<Item>org.mortbay.jetty.servlet.XMLConfiguration</Item>
<Item>org.mortbay.jetty.servlet.JettyWebConfiguration</Item>
<Item>org.mortbay.jetty.servlet.jsr77.Configuration</Item>
</Array>
</Set>
java -DSTART=extra/etc/start-jsr77.config -jar start.jar <name of your config file>
For example, to enable JSR77 statistics for the demo shipped with Jetty:
java -DSTART=extra/etc/start-jsr77.config -jar start.jar etc/demo-jmx.xml
org.mortbay:J2EEServer=null,J2EEApplication=null,J2EEWebModule=<context-name>,j2EEType=Servlet,name=<servlet-name>
eg
org.mortbay:J2EEServer=null,J2EEApplication=null,J2EEWebModule=/servlets-examples,j2EEType=Servlet,name=HelloWorldExample
For more information, refer to the JSR77 specification.