Web application

Monitoring provides support for servlet based web applications.

MonitoringFilter

The monitoringFilter is a Servlet Filter to compute HTTP request serving performance. Simply add the following configuration to your WEB-INF/web.xml :

    <filter>
        <filter-name>Monitoring</filter-name>
        <filter-class>org.apache.commons.monitoring.servlet.MonitoringFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>Monitoring</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
         
Any incoming request will then be monitored and added to the repository. The monitor name is the requested URI path, and the extension is used to select a category.

MonitoringServlet

The monitoring serlvet give you access to the active repository. Using a selector path, you can select a set of monitors and get it rendered in any supported format (HTML, XML, JSON, ...). The selector path is a simple String to point to the expected objects :

  • /monitors will select all monitors in the repository.
  • /monitorsFromCategory/services will select all monitors for the category "services".
  • /monitorsFromSubsystem/admin will select all monitors for the subsystem "admin".

The monitoring serlvet also accepts parameter to filter the result :

  • Adding ?format=html will force the output to be formatted in HTML. By default the user-agent accept header is used to find a valid renderer, but this may produce
  • Adding ?role=performances will select the "performances" counter to get included in the output. By default all roles are displayed. If some role parameter is set in the URI, only those roles are displayed. You can specify many role=* parameter or use the shortcut roles=x,y,z .
  • Addind ?performances.value=false will remove the "current value" column from the output. You can specify many [role].[attribute]=[true|false] parameter or use the shortcut [role].columns=x,y,z .
  • Adding ?performances.unit=ms will format the "performances" counter values to use milliseconds as data unit. The parameter value must be a valid derived unit from the counter unit. For time based counters, this includes ns (nanoseconds), µs (microseconds), ms (milliseconds), s (seconds) ... Please refer to the org.apache.commons.monitoring.Unit javadoc for more infos on units.
By combining the request URI path and parameters, you can filter what is relevant for you. Bookmark the valuable URIs ! Example : http://myserver/monitoring/monitors?performances.unit=ms&performances.value=false&performances.sum=false

Web UI

The WebUI Servlet extends the monitoring serlvet and the HtmlRenderer to provide a simple Web UI. It uses the same URI filtering as MonitoringServlet, but also includes some CSS to render nicer and JQuery to sort data.